Mercurial > sdl-ios-xcode
annotate src/video/win32/wactab/pktdef.h @ 3727:51900b161948 gsoc2009_unit_tests
Fixed accidentle broken compile.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sat, 11 Jul 2009 19:08:06 +0000 |
parents | f23ebf1ddac4 |
children |
rev | line source |
---|---|
2726
f23ebf1ddac4
Dynamically load wintab32.dll
Sam Lantinga <slouken@libsdl.org>
parents:
2724
diff
changeset
|
1 /* *INDENT-OFF* */ |
2724 | 2 /* -------------------------------- pktdef.h -------------------------------- */ |
3 /* Combined 16 & 32-bit version. */ | |
4 | |
5 /*------------------------------------------------------------------------------ | |
6 The text and information contained in this file may be freely used, | |
7 copied, or distributed without compensation or licensing restrictions. | |
8 | |
9 This file is copyright 1991-1998 by LCS/Telegraphics. | |
10 ------------------------------------------------------------------------------*/ | |
11 /*------------------------------------------------------------------------------ | |
12 | |
13 How to use pktdef.h: | |
14 | |
15 1. Include wintab.h | |
16 2. if using just one packet format: | |
17 a. Define PACKETDATA and PACKETMODE as or'ed combinations of WTPKT bits | |
18 (use the PK_* identifiers). | |
19 b. Include pktdef.h. | |
20 c. The generated structure typedef will be called PACKET. Use PACKETDATA | |
21 and PACKETMODE to fill in the LOGCONTEXT structure. | |
22 3. If using multiple packet formats, for each one: | |
23 a. Define PACKETNAME. Its text value will be a prefix for this packet's | |
24 parameters and names. | |
25 b. Define <PACKETNAME>PACKETDATA and <PACKETNAME>PACKETMODE similar to | |
26 2.a. above. | |
27 c. Include pktdef.h. | |
28 d. The generated structure typedef will be called | |
29 <PACKETNAME>PACKET. Compare with 2.c. above and example #2 below. | |
30 4. If using extension packet data, do the following additional steps | |
31 for each extension: | |
32 a. Before including pktdef.h, define <PACKETNAME>PACKET<EXTENSION> | |
33 as either PKEXT_ABSOLUTE or PKEXT_RELATIVE. | |
34 b. The generated structure typedef will contain a field for the | |
35 extension data. | |
36 c. Scan the WTI_EXTENSION categories to find the extension's | |
37 packet mask bit. | |
38 d. OR the packet mask bit with <PACKETNAME>PACKETDATA and use the | |
39 result in the lcPktData field of the LOGCONTEXT structure. | |
40 e. If <PACKETNAME>PACKET<EXTENSION> was PKEXT_RELATIVE, OR the | |
41 packet mask bit with <PACKETNAME>PACKETMODE and use the result | |
42 in the lcPktMode field of the LOGCONTEXT structure. | |
43 | |
44 | |
45 Example #1. -- single packet format | |
46 | |
47 #include <wintab.h> | |
48 #define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/ | |
49 #define PACKETMODE PK_BUTTONS /@ buttons relative mode @/ | |
50 #include <pktdef.h> | |
51 ... | |
52 lc.lcPktData = PACKETDATA; | |
53 lc.lcPktMode = PACKETMODE; | |
54 | |
55 Example #2. -- multiple formats | |
56 | |
57 #include <wintab.h> | |
58 #define PACKETNAME MOE | |
59 #define MOEPACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/ | |
60 #define MOEPACKETMODE PK_BUTTONS /@ buttons relative mode @/ | |
61 #include <pktdef.h> | |
62 #define PACKETNAME LARRY | |
63 #define LARRYPACKETDATA PK_Y | PK_Z | PK_BUTTONS /@ y, z, buttons @/ | |
64 #define LARRYPACKETMODE PK_BUTTONS /@ buttons relative mode @/ | |
65 #include <pktdef.h> | |
66 #define PACKETNAME CURLY | |
67 #define CURLYPACKETDATA PK_X | PK_Z | PK_BUTTONS /@ x, z, buttons @/ | |
68 #define CURLYPACKETMODE PK_BUTTONS /@ buttons relative mode @/ | |
69 #include <pktdef.h> | |
70 ... | |
71 lcMOE.lcPktData = MOEPACKETDATA; | |
72 lcMOE.lcPktMode = MOEPACKETMODE; | |
73 ... | |
74 lcLARRY.lcPktData = LARRYPACKETDATA; | |
75 lcLARRY.lcPktMode = LARRYPACKETMODE; | |
76 ... | |
77 lcCURLY.lcPktData = CURLYPACKETDATA; | |
78 lcCURLY.lcPktMode = CURLYPACKETMODE; | |
79 | |
80 Example #3. -- extension packet data "XFOO". | |
81 | |
82 #include <wintab.h> | |
83 #define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/ | |
84 #define PACKETMODE PK_BUTTONS /@ buttons relative mode @/ | |
85 #define PACKETXFOO PKEXT_ABSOLUTE /@ XFOO absolute mode @/ | |
86 #include <pktdef.h> | |
87 ... | |
88 UINT ScanExts(UINT wTag) | |
89 { | |
90 UINT i; | |
91 UINT wScanTag; | |
92 | |
93 /@ scan for wTag's info category. @/ | |
94 for (i = 0; WTInfo(WTI_EXTENSIONS + i, EXT_TAG, &wScanTag); i++) { | |
95 if (wTag == wScanTag) { | |
96 /@ return category offset from WTI_EXTENSIONS. @/ | |
97 return i; | |
98 } | |
99 } | |
100 /@ return error code. @/ | |
101 return 0xFFFF; | |
102 } | |
103 ... | |
104 lc.lcPktData = PACKETDATA; | |
105 lc.lcPktMode = PACKETMODE; | |
106 #ifdef PACKETXFOO | |
107 categoryXFOO = ScanExts(WTX_XFOO); | |
108 WTInfo(WTI_EXTENSIONS + categoryXFOO, EXT_MASK, &maskXFOO); | |
109 lc.lcPktData |= maskXFOO; | |
110 #if PACKETXFOO == PKEXT_RELATIVE | |
111 lc.lcPktMode |= maskXFOO; | |
112 #endif | |
113 #endif | |
114 WTOpen(hWnd, &lc, TRUE); | |
115 | |
116 | |
117 ------------------------------------------------------------------------------*/ | |
118 #ifdef __cplusplus | |
119 extern "C" { | |
120 #endif /* __cplusplus */ | |
121 | |
122 #ifndef PACKETNAME | |
123 /* if no packet name prefix */ | |
124 #define __PFX(x) x | |
125 #define __IFX(x,y) x ## y | |
126 #else | |
127 /* add prefixes and infixes to packet format names */ | |
128 #define __PFX(x) __PFX2(PACKETNAME,x) | |
129 #define __PFX2(p,x) __PFX3(p,x) | |
130 #define __PFX3(p,x) p ## x | |
131 #define __IFX(x,y) __IFX2(x,PACKETNAME,y) | |
132 #define __IFX2(x,i,y) __IFX3(x,i,y) | |
133 #define __IFX3(x,i,y) x ## i ## y | |
134 #endif | |
135 | |
136 #define __SFX2(x,s) __SFX3(x,s) | |
137 #define __SFX3(x,s) x ## s | |
138 | |
139 #define __TAG __IFX(tag,PACKET) | |
140 #define __TYPES __PFX(PACKET), * __IFX(P,PACKET), NEAR * __IFX(NP,PACKET), \ | |
141 FAR * __IFX(LP,PACKET) | |
142 | |
143 #define __DATA (__PFX(PACKETDATA)) | |
144 #define __MODE (__PFX(PACKETMODE)) | |
145 #define __EXT(x) __SFX2(__PFX(PACKET),x) | |
146 | |
147 | |
148 typedef struct __TAG { | |
149 #if (__DATA & PK_CONTEXT) | |
150 HCTX pkContext; | |
151 #endif | |
152 #if (__DATA & PK_STATUS) | |
153 UINT pkStatus; | |
154 #endif | |
155 #if (__DATA & PK_TIME) | |
156 DWORD pkTime; | |
157 #endif | |
158 #if (__DATA & PK_CHANGED) | |
159 WTPKT pkChanged; | |
160 #endif | |
161 #if (__DATA & PK_SERIAL_NUMBER) | |
162 UINT pkSerialNumber; | |
163 #endif | |
164 #if (__DATA & PK_CURSOR) | |
165 UINT pkCursor; | |
166 #endif | |
167 #if (__DATA & PK_BUTTONS) | |
168 DWORD pkButtons; | |
169 #endif | |
170 #if (__DATA & PK_X) | |
171 LONG pkX; | |
172 #endif | |
173 #if (__DATA & PK_Y) | |
174 LONG pkY; | |
175 #endif | |
176 #if (__DATA & PK_Z) | |
177 LONG pkZ; | |
178 #endif | |
179 #if (__DATA & PK_NORMAL_PRESSURE) | |
180 #if (__MODE & PK_NORMAL_PRESSURE) | |
181 /* relative */ | |
182 int pkNormalPressure; | |
183 #else | |
184 /* absolute */ | |
185 UINT pkNormalPressure; | |
186 #endif | |
187 #endif | |
188 #if (__DATA & PK_TANGENT_PRESSURE) | |
189 #if (__MODE & PK_TANGENT_PRESSURE) | |
190 /* relative */ | |
191 int pkTangentPressure; | |
192 #else | |
193 /* absolute */ | |
194 UINT pkTangentPressure; | |
195 #endif | |
196 #endif | |
197 #if (__DATA & PK_ORIENTATION) | |
198 ORIENTATION pkOrientation; | |
199 #endif | |
200 #if (__DATA & PK_ROTATION) | |
201 ROTATION pkRotation; /* 1.1 */ | |
202 #endif | |
203 | |
204 #ifndef NOWTEXTENSIONS | |
205 /* extensions begin here. */ | |
206 #if (__EXT(FKEYS) == PKEXT_RELATIVE) || (__EXT(FKEYS) == PKEXT_ABSOLUTE) | |
207 UINT pkFKeys; | |
208 #endif | |
209 #if (__EXT(TILT) == PKEXT_RELATIVE) || (__EXT(TILT) == PKEXT_ABSOLUTE) | |
210 TILT pkTilt; | |
211 #endif | |
212 #if (__EXT(EXPKEYS) == PKEXT_RELATIVE) || (__EXT(EXPKEYS) == PKEXT_ABSOLUTE) | |
213 WORD pkExpKeys[4]; /* 1.3 */ | |
214 #endif | |
215 #endif | |
216 | |
217 } __TYPES ; | |
218 | |
219 #undef PACKETNAME | |
220 #undef __TAG | |
221 #undef __TAG2 | |
222 #undef __TYPES | |
223 #undef __TYPES2 | |
224 #undef __DATA | |
225 #undef __MODE | |
226 #undef __PFX | |
227 #undef __PFX2 | |
228 #undef __PFX3 | |
229 #undef __IFX | |
230 #undef __IFX2 | |
231 #undef __IFX3 | |
232 #undef __SFX2 | |
233 #undef __SFX3 | |
234 | |
235 #ifdef __cplusplus | |
236 } | |
237 #endif /* __cplusplus */ |