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