stash
[wine/wine64.git] / include / pktdef.h
bloba1622062658c380c03943ede7e4b26affa353c78
1 /*
2 * Copyright (C) 1991-1998 by LCS/Telegraphics
3 * Copyright (C) 2002 Patrik Stridvall
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_PKTDEF_H
21 #define __WINE_PKTDEF_H
23 /***********************************************************************
24 * How to use pktdef.h:
26 * 1. Include wintab.h
27 * 2. if using just one packet format:
28 * a. Define PACKETDATA and PACKETMODE as or'ed combinations of WTPKT bits
29 * (use the PK_* identifiers).
30 * b. Include pktdef.h.
31 * c. The generated structure typedef will be called PACKET. Use PACKETDATA
32 * and PACKETMODE to fill in the LOGCONTEXT structure.
33 * 3. If using multiple packet formats, for each one:
34 * a. Define PACKETNAME. Its text value will be a prefix for this packet's
35 * parameters and names.
36 * b. Define <PACKETNAME>PACKETDATA and <PACKETNAME>PACKETMODE similar to
37 * 2.a. above.
38 * c. Include pktdef.h.
39 * d. The generated structure typedef will be called
40 * <PACKETNAME>PACKET. Compare with 2.c. above and example #2 below.
41 * 4. If using extension packet data, do the following additional steps
42 * for each extension:
43 * a. Before including pktdef.h, define <PACKETNAME>PACKET<EXTENSION>
44 * as either PKEXT_ABSOLUTE or PKEXT_RELATIVE.
45 * b. The generated structure typedef will contain a field for the
46 * extension data.
47 * c. Scan the WTI_EXTENSION categories to find the extension's
48 * packet mask bit.
49 * d. OR the packet mask bit with <PACKETNAME>PACKETDATA and use the
50 * result in the lcPktData field of the LOGCONTEXT structure.
51 * e. If <PACKETNAME>PACKET<EXTENSION> was PKEXT_RELATIVE, OR the
52 * packet mask bit with <PACKETNAME>PACKETMODE and use the result
53 * in the lcPktMode field of the LOGCONTEXT structure.
56 * Example #1. -- single packet format
58 * #include <wintab.h>
59 * #define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/
60 * #define PACKETMODE PK_BUTTONS /@ buttons relative mode @/
61 * #include <pktdef.h>
62 * ...
63 * lc.lcPktData = PACKETDATA;
64 * lc.lcPktMode = PACKETMODE;
66 * Example #2. -- multiple formats
68 * #include <wintab.h>
69 * #define PACKETNAME MOE
70 * #define MOEPACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/
71 * #define MOEPACKETMODE PK_BUTTONS /@ buttons relative mode @/
72 * #include <pktdef.h>
73 * #define PACKETNAME LARRY
74 * #define LARRYPACKETDATA PK_Y | PK_Z | PK_BUTTONS /@ y, z, buttons @/
75 * #define LARRYPACKETMODE PK_BUTTONS /@ buttons relative mode @/
76 * #include <pktdef.h>
77 * #define PACKETNAME CURLY
78 * #define CURLYPACKETDATA PK_X | PK_Z | PK_BUTTONS /@ x, z, buttons @/
79 * #define CURLYPACKETMODE PK_BUTTONS /@ buttons relative mode @/
80 * #include <pktdef.h>
81 * ...
82 * lcMOE.lcPktData = MOEPACKETDATA;
83 * lcMOE.lcPktMode = MOEPACKETMODE;
84 * ...
85 * lcLARRY.lcPktData = LARRYPACKETDATA;
86 * lcLARRY.lcPktMode = LARRYPACKETMODE;
87 * ...
88 * lcCURLY.lcPktData = CURLYPACKETDATA;
89 * lcCURLY.lcPktMode = CURLYPACKETMODE;
91 * Example #3. -- extension packet data "XFOO".
93 * #include <wintab.h>
94 * #define PACKETDATA PK_X | PK_Y | PK_BUTTONS /@ x, y, buttons @/
95 * #define PACKETMODE PK_BUTTONS /@ buttons relative mode @/
96 * #define PACKETXFOO PKEXT_ABSOLUTE /@ XFOO absolute mode @/
97 * #include <pktdef.h>
98 * ...
99 * UINT ScanExts(UINT wTag)
101 * UINT i;
102 * UINT wScanTag;
104 * /@ scan for wTag's info category. @/
105 * for (i = 0; WTInfo(WTI_EXTENSIONS + i, EXT_TAG, &wScanTag); i++) {
106 * if (wTag == wScanTag) {
107 * /@ return category offset from WTI_EXTENSIONS. @/
108 * return i;
111 * /@ return error code. @/
112 * return 0xFFFF;
114 * ...
115 * lc.lcPktData = PACKETDATA;
116 * lc.lcPktMode = PACKETMODE;
117 * #ifdef PACKETXFOO
118 * categoryXFOO = ScanExts(WTX_XFOO);
119 * WTInfo(WTI_EXTENSIONS + categoryXFOO, EXT_MASK, &maskXFOO);
120 * lc.lcPktData |= maskXFOO;
121 * #if PACKETXFOO == PKEXT_RELATIVE
122 * lc.lcPktMode |= maskXFOO;
123 * #endif
124 * #endif
125 * WTOpen(hWnd, &lc, TRUE);
128 #ifdef __cplusplus
129 extern "C" {
130 #endif /* defined(__cplusplus) */
132 #ifndef PACKETNAME
133 /* if no packet name prefix */
134 # define __PFX(x) x
135 # define __IFX(x,y) x ## y
136 #else
137 /* add prefixes and infixes to packet format names */
138 # define __PFX(x) __PFX2(PACKETNAME,x)
139 # define __PFX2(p,x) __PFX3(p,x)
140 # define __PFX3(p,x) p ## x
141 # define __IFX(x,y) __IFX2(x,PACKETNAME,y)
142 # define __IFX2(x,i,y) __IFX3(x,i,y)
143 # define __IFX3(x,i,y) x ## i ## y
144 #endif
146 #define __SFX2(x,s) __SFX3(x,s)
147 #define __SFX3(x,s) x ## s
149 #define __TAG __IFX(tag,PACKET)
150 #define __TYPES \
151 __PFX(PACKET), * __IFX(P,PACKET), \
152 * __IFX(NP,PACKET), * __IFX(LP,PACKET)
154 #define __DATA (__PFX(PACKETDATA))
155 #define __MODE (__PFX(PACKETMODE))
156 #define __EXT(x) __SFX2(__PFX(PACKET),x)
158 typedef struct __TAG {
159 #if (__DATA & PK_CONTEXT)
160 HCTX pkContext;
161 #endif
162 #if (__DATA & PK_STATUS)
163 UINT pkStatus;
164 #endif
165 #if (__DATA & PK_TIME)
166 DWORD pkTime;
167 #endif
168 #if (__DATA & PK_CHANGED)
169 WTPKT pkChanged;
170 #endif
171 #if (__DATA & PK_SERIAL_NUMBER)
172 UINT pkSerialNumber;
173 #endif
174 #if (__DATA & PK_CURSOR)
175 UINT pkCursor;
176 #endif
177 #if (__DATA & PK_BUTTONS)
178 DWORD pkButtons;
179 #endif
180 #if (__DATA & PK_X)
181 LONG pkX;
182 #endif
183 #if (__DATA & PK_Y)
184 LONG pkY;
185 #endif
186 #if (__DATA & PK_Z)
187 LONG pkZ;
188 #endif
189 #if (__DATA & PK_NORMAL_PRESSURE)
190 # if (__MODE & PK_NORMAL_PRESSURE)
191 /* relative */
192 int pkNormalPressure;
193 # else
194 /* absolute */
195 UINT pkNormalPressure;
196 # endif
197 #endif
198 #if (__DATA & PK_TANGENT_PRESSURE)
199 # if (__MODE & PK_TANGENT_PRESSURE)
200 /* relative */
201 int pkTangentPressure;
202 # else
203 /* absolute */
204 UINT pkTangentPressure;
205 # endif
206 #endif
207 #if (__DATA & PK_ORIENTATION)
208 ORIENTATION pkOrientation;
209 #endif
210 #if (__DATA & PK_ROTATION)
211 ROTATION pkRotation; /* 1.1 */
212 #endif
214 #ifndef NOWTEXTENSIONS
215 /* extensions begin here. */
217 #if (__EXT(FKEYS) == PKEXT_RELATIVE) || (__EXT(FKEYS) == PKEXT_ABSOLUTE)
218 UINT pkFKeys;
219 #endif
220 #if (__EXT(TILT) == PKEXT_RELATIVE) || (__EXT(TILT) == PKEXT_ABSOLUTE)
221 TILT pkTilt;
222 #endif
224 #endif
226 } __TYPES;
228 #undef PACKETNAME
229 #undef __TAG
230 #undef __TAG2
231 #undef __TYPES
232 #undef __TYPES2
233 #undef __DATA
234 #undef __MODE
235 #undef __PFX
236 #undef __PFX2
237 #undef __PFX3
238 #undef __IFX
239 #undef __IFX2
240 #undef __IFX3
241 #undef __SFX2
242 #undef __SFX3
244 #ifdef __cplusplus
245 } /* extern "C" */
246 #endif /* defined(__cplusplus) */
248 #endif /* defined(__WINE_PKTDEF_H */