Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
6.2 KiB

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