pktdef.h 7.1 KB

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