Leaked source code of windows server 2003
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.

371 lines
8.9 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1995-1999 Microsoft Corporation
  3. Module Name:
  4. swndr3p.h
  5. Abstract:
  6. Definitions of all constants and types for the Sidewinder 3p joystick.
  7. Author:
  8. edbriggs 30-Nov-95
  9. Revision History:
  10. --*/
  11. #ifndef __NTDDSJOY_H__
  12. #define __NTDDSJOY_H__
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define UnusedParameter(x) x = x
  20. //
  21. // Device Name
  22. //
  23. #define JOY_DD_DEVICE_NAME "\\Device\\IBMJOY"
  24. #define JOY_DD_DEVICE_NAME_U L"\\Device\\IBMJOY"
  25. //
  26. // Device Parameters
  27. //
  28. #define JOY_DD_NAXES "NumberOfAxes"
  29. #define JOY_DD_NAXES_U L"NumberOfAxes"
  30. #define JOY_DD_DEVICE_TYPE "DeviceType"
  31. #define JOY_DD_DEVICE_TYPE_U L"DeviceType"
  32. #define JOY_DD_DEVICE_ADDRESS "DeviceAddress"
  33. #define JOY_DD_DEVICE_ADDRESS_U L"DeviceAddress"
  34. //
  35. // Device Types
  36. //
  37. #define JOY_TYPE_UNKNOWN 0x00
  38. #define JOY_TYPE_SIDEWINDER 0x01
  39. //
  40. // Device I/O Port Address
  41. //
  42. #define JOY_IO_PORT_ADDRESS 0x201
  43. //
  44. // Device specific bitmasks
  45. //
  46. #define X_AXIS_BITMASK 0x01
  47. #define CLOCK_BITMASK 0x10
  48. #define DATA0_BITMASK 0x20
  49. #define DATA1_BITMASK 0x40
  50. #define DATA2_BITMASK 0x80
  51. #define ALLDATA_BITMASK 0xE0
  52. #define ALLAXIS_BITMASK 0x0F
  53. //
  54. // Analog joystick bitmasks
  55. //
  56. #define JOYSTICK2_BUTTON2 0x80
  57. #define JOYSTICK2_BUTTON1 0x40
  58. #define JOYSTICK1_BUTTON2 0x20
  59. #define JOYSTICK1_BUTTON1 0x10
  60. #define JOYSTICK2_Y_MASK 0x08
  61. #define JOYSTICK2_X_MASK 0x04
  62. #define JOYSTICK1_R_MASK 0x08
  63. #define JOYSTICK1_Z_MASK 0x04
  64. #define JOYSTICK1_Y_MASK 0x02
  65. #define JOYSTICK1_X_MASK 0x01
  66. #define JOY_START_TIMERS 0
  67. //
  68. // Device specific timer values
  69. //
  70. #define ANALOG_POLL_TIMEOUT 5000 // 5 mS upper bound on analog polling
  71. #define ANALOG_POLL_RESOLUTION 100 // 100 uS accuracy on polling time
  72. #define ANALOG_XA_VERYSLOW 1500
  73. #define ANALOG_XA_SLOW 1200
  74. #define ANALOG_XA_MEDIUM 900
  75. #define ANALOG_XA_FAST 300
  76. #define ANALOG_XA_VERYFAST 100
  77. #define DIGITAL_XA_VERYSLOW 1100
  78. #define DIGITAL_XA_SLOW 700
  79. #define DIGITAL_XA_MEDIUM 510
  80. #define DIGITAL_XA_FAST 100
  81. #define DIGITAL_XA_VERYFAST 50
  82. #define GODIGITAL_BASEDELAY_VERYSLOW 25
  83. #define GODIGITAL_BASEDELAY_SLOW 50
  84. #define GODIGITAL_BASEDELAY_MEDIUM 75
  85. #define GODIGITAL_BASEDELAY_FAST 120
  86. #define GODIGITAL_BASEDELAY_VERYFAST 130
  87. //
  88. // Device specific operating mode. Both INVALID_MODE and MAXIMUM_MODE are for
  89. // assertion checking and do not correspond to real operating modes
  90. //
  91. #define SIDEWINDER3P_INVALID_MODE 0
  92. #define SIDEWINDER3P_ANALOG_MODE 1
  93. #define SIDEWINDER3P_DIGITAL_MODE 2
  94. #define SIDEWINDER3P_ENHANCED_DIGITAL_MODE 3
  95. #define SIDEWINDER3P_MAXIMUM_MODE 4
  96. #define CLOCK_RISING_EDGE 0
  97. #define CLOCK_FALLING_EDGE 1
  98. //
  99. // These constants define how polling errors will be handled
  100. //
  101. #define MAX_ENHANCEDMODE_ATTEMPTS 10
  102. //
  103. // Joystick position information is transfered from the device driver to other
  104. // drivers or applications using the JOY_DD_INPUT_DATA structure. Since
  105. // the type of data returned varies whether the device is in analog mode or
  106. // digital mode, a union is formed to convey both types of data. The Mode
  107. // variable allows the recipient of the data to determing how to interpret
  108. // the data.
  109. //
  110. typedef struct {
  111. //
  112. // True if the device is unplugged. This is determined by a timeout
  113. // mechanism
  114. //
  115. BOOL Unplugged;
  116. //
  117. // The mode is a value used to allow the recipient to determine how to
  118. // interpret the data and the union. Valid values are:
  119. //
  120. // SIDEWINDER3P_ANALOG_MODE,
  121. // SIDEWINDER3P_DIGITAL_MODE,
  122. // SIDEWINDER3P_ENHANCED_DIGITAL_MODE
  123. //
  124. DWORD Mode;
  125. union {
  126. //
  127. // Digital mode data packet
  128. //
  129. struct {
  130. //
  131. // Digital Positioning information values as follows
  132. //
  133. // name range direction
  134. // ---- ----- ---------
  135. //
  136. // XOffset [0..1024) 0 = leftmost, 1023 = rightmost
  137. // YOffset [0..1024) 0 = up, 1023 = down
  138. // RzOffset [0..512) 0 = left, 511 = right
  139. // TOffset [0..1024) Throttle position
  140. //
  141. WORD XOffset;
  142. WORD YOffset;
  143. WORD RzOffset;
  144. WORD TOffset;
  145. //
  146. // hat position. The hat is an eight position switch.
  147. // 0 = Not Pressed; 1 = 0 degrees, 2 = 45, 3 = 90 ... 8 = 315
  148. // 0 degrees is up.
  149. //
  150. BYTE Hat;
  151. //
  152. // Button states. Buttons are bitmapped into the low order
  153. // bit 0 - 7. Depressed = 0, released = 1.
  154. //
  155. BYTE Buttons;
  156. //
  157. // Checksum for packet
  158. //
  159. BYTE Checksum;
  160. //
  161. // Switch indicating whether we are emulating a CH Joystick or a
  162. // Thrustmaster Joystick.
  163. //
  164. BYTE Switch_CH_TM;
  165. //
  166. // Driver Internal processing determines if the checksum and framing
  167. // of the packet are correct. The following boolean values reflect
  168. // the findings
  169. //
  170. BOOL fChecksumCorrect;
  171. BOOL fSyncBitsCorrect;
  172. } DigitalData;
  173. //
  174. // Analog mode data packet
  175. //
  176. struct {
  177. //
  178. // The number of axi configured for this device (specified in the
  179. // registry).
  180. //
  181. DWORD Axi;
  182. //
  183. // current button state bitmask
  184. //
  185. DWORD Buttons;
  186. //
  187. // X, Y, Z, and T axi positioning information contained below. The
  188. // values are expressed interms of microseconds. The values are
  189. // generated by measuring the duration of a pulse supplied by
  190. // the IBM compatable or Soundblaster game port. This is the raw
  191. // data, and it is the callers responsibility to perform
  192. // calibration, ranging, hysteresis, etc.
  193. //
  194. // Because of inaccuracies in sampling this data, there is some
  195. // variation in readings of a stationary joystick.
  196. //
  197. //
  198. // Analog Positioning information for Microsoft Sidewinder IIId P
  199. // values as follows (range information measured using a
  200. // Soundblaster analog game port.
  201. //
  202. // apprx
  203. // name range direction
  204. // ---- ----- ---------
  205. //
  206. // XTime 20..1600 uS 20 = leftmost, 1600 = rightmost
  207. // YTime 20..1600 uS 20 = up, 1600 = down
  208. // ZTime 20..1600 uS 20 = left, 1600 = right
  209. // TTime 20..1600 uS 20 = forward 1600 = back
  210. //
  211. DWORD XTime; // Time in microseconds for X
  212. DWORD YTime; // Time in microseconds for Y
  213. DWORD ZTime; // Time in microseconds for Z if 3-axis
  214. DWORD TTime; // Time in microseconds for Throttle if 4 axis
  215. } AnalogData;
  216. } u;
  217. } JOY_DD_INPUT_DATA, *PJOY_DD_INPUT_DATA;
  218. //
  219. // The following IOCTL codes are used for testing the device driver. They
  220. // export internal functions of the driver which will not be needed in the
  221. // final version of the driver
  222. //
  223. #define JOY_TYPE 40001
  224. #define IOCTL_JOY_GET_DRIVER_MODE_DWORD \
  225. CTL_CODE( JOY_TYPE, 0x900, METHOD_BUFFERED, FILE_READ_ACCESS)
  226. #define IOCTL_JOY_GET_DEVICE_MODE_DWORD \
  227. CTL_CODE( JOY_TYPE, 0x901, METHOD_BUFFERED, FILE_READ_ACCESS)
  228. #define IOCTL_JOY_SET_DIGITAL_MODE \
  229. CTL_CODE( JOY_TYPE, 0x902, METHOD_BUFFERED, FILE_READ_ACCESS)
  230. #define IOCTL_JOY_GET_STATISTICS \
  231. CTL_CODE( JOY_TYPE, 0x903, METHOD_BUFFERED, FILE_READ_ACCESS)
  232. #define IOCTL_JOY_SET_ENHANCED_MODE \
  233. CTL_CODE( JOY_TYPE, 0x904, METHOD_BUFFERED, FILE_READ_ACCESS)
  234. #define IOCTL_JOY_SET_ANALOG_MODE \
  235. CTL_CODE( JOY_TYPE, 0x905, METHOD_BUFFERED, FILE_READ_ACCESS)
  236. #define IOCTL_JOY_GET_JOYREGHWCONFIG \
  237. CTL_CODE( JOY_TYPE, 0x906, METHOD_BUFFERED, FILE_READ_ACCESS)
  238. typedef union
  239. {
  240. BYTE Byte;
  241. WORD Word;
  242. DWORD Dword;
  243. } JOY_IOCTL_INFO, *PJOY_IOCTL_INFO;
  244. typedef struct
  245. {
  246. DWORD Retries[MAX_ENHANCEDMODE_ATTEMPTS];
  247. DWORD EnhancedPolls;
  248. DWORD EnhancedPollTimeouts;
  249. DWORD EnhancedPollErrors;
  250. DWORD Frequency;
  251. DWORD dwQPCLatency;
  252. LONG nReadLoopMax;
  253. DWORD nVersion;
  254. DWORD nPolledTooSoon;
  255. DWORD nReset;
  256. } JOY_STATISTICS, *PJOY_STATISTICS;
  257. #ifdef __cplusplus
  258. }
  259. #endif
  260. #endif // __NTDDJOY_H__