Source code of Windows XP (NT5)
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.

199 lines
5.0 KiB

  1. /***** Normal use, default configuration *****/
  2. // global keyboard hook entry
  3. #define WM_GLOBAL_KBDHOOK WM_USER+3
  4. BOOL APIENTRY RegisterHookSendWindow(HWND hwnd, UINT uiMsg);
  5. // hidden switch window information
  6. #define SWITCH_TIMER 1015
  7. void SwitchOnCreate(HWND hWnd);
  8. void SwitchOnEndSession(HWND hWnd);
  9. void SwitchOnTimer(HWND hWnd);
  10. void SwitchOnPollMsg(HWND hWnd);
  11. BOOL SwitchOnCopyData(WPARAM wParam, LPARAM lParam);
  12. // msswch.dll header information
  13. typedef HANDLE HSWITCHPORT;
  14. HSWITCHPORT APIENTRY swchOpenSwitchPort(
  15. HWND hWnd,
  16. DWORD dwPortStyle );
  17. #define PS_POLLING 1
  18. #define PS_EVENTS 2
  19. BOOL APIENTRY swchCloseSwitchPort(
  20. HSWITCHPORT hSwitchPort );
  21. #define NUM_SWITCHES 6
  22. #define BIT_SWITCHES 0x003F
  23. #define SWITCH_NONE 0x0000
  24. #define SWITCH_1 0x0001
  25. #define SWITCH_2 0x0002
  26. #define SWITCH_3 0x0004
  27. #define SWITCH_4 0x0008
  28. #define SWITCH_5 0x0010
  29. #define SWITCH_6 0x0020
  30. // These messages need to be reserved with Microsoft
  31. #define SW_SWITCHDOWNBASE 0x00E0
  32. #define SW_SWITCH1DOWN (SW_SWITCHDOWNBASE + 1)
  33. #define SW_SWITCH2DOWN (SW_SWITCHDOWNBASE + 2)
  34. #define SW_SWITCH3DOWN (SW_SWITCHDOWNBASE + 3)
  35. #define SW_SWITCH4DOWN (SW_SWITCHDOWNBASE + 4)
  36. #define SW_SWITCH5DOWN (SW_SWITCHDOWNBASE + 5)
  37. #define SW_SWITCH6DOWN (SW_SWITCHDOWNBASE + 6)
  38. // These messages need to be reserved with Microsoft
  39. #define SW_SWITCHUPBASE 0x00F0
  40. #define SW_SWITCH1UP (SW_SWITCHUPBASE + 1)
  41. #define SW_SWITCH2UP (SW_SWITCHUPBASE + 2)
  42. #define SW_SWITCH3UP (SW_SWITCHUPBASE + 3)
  43. #define SW_SWITCH4UP (SW_SWITCHUPBASE + 4)
  44. #define SW_SWITCH5UP (SW_SWITCHUPBASE + 5)
  45. #define SW_SWITCH6UP (SW_SWITCHUPBASE + 6)
  46. /***** Configuration *****/
  47. typedef HANDLE HSWITCHDEVICE;
  48. // make this a dword rather then a handle this is to make this 64 bit portable
  49. typedef DWORD HJOYDEVICE;
  50. // This message needs to be reserved with Microsoft
  51. #define SW_SWITCHCONFIGCHANGED 0x00D0
  52. #define SC_TYPE_COM 1
  53. #define SC_TYPE_LPT 2
  54. #define SC_TYPE_JOYSTICK 3
  55. #define SC_TYPE_KEYS 4
  56. // Not defined yet
  57. #define SC_TYPE_USB 5
  58. #define SC_TYPE_1394 6
  59. typedef struct _SWITCHLIST {
  60. DWORD dwSwitchCount;
  61. HSWITCHDEVICE hsd[ANYSIZE_ARRAY];
  62. } SWITCHLIST, *PSWITCHLIST;
  63. typedef struct _SWITCHCONFIG_LPT {
  64. DWORD dwReserved1; // possible future Status register preset
  65. DWORD dwReserved2; // possible future Data register preset
  66. } SWITCHCONFIG_LPT, *PSWITCHCONFIG_LPT;
  67. typedef struct _SWITCHCONFIG_JOYSTICK {
  68. DWORD dwJoySubType;
  69. DWORD dwJoyThresholdMinX;
  70. DWORD dwJoyThresholdMaxX;
  71. DWORD dwJoyThresholdMinY;
  72. DWORD dwJoyThresholdMaxY;
  73. DWORD dwJoyHysteresis;
  74. } SWITCHCONFIG_JOYSTICK, *PSWITCHCONFIG_JOYSTICK;
  75. typedef struct _SWITCHCONFIG_KEYS {
  76. DWORD dwKeySwitch1;
  77. DWORD dwKeySwitch2;
  78. } SWITCHCONFIG_KEYS, *PSWITCHCONFIG_KEYS;
  79. typedef struct _SWITCHCONFIG_USB {
  80. // *** NOT DEFINED YET ***
  81. DWORD dwReserved;
  82. } SWITCHCONFIG_USB, *PSWITCHCONFIG_USB;
  83. typedef struct _SWITCHCONFIG_IEEE1394 {
  84. // *** NOT DEFINED YET ***
  85. DWORD dwReserved;
  86. } SWITCHCONFIG_IEEE1394, *PSWITCHCONFIG_IEEE1394;
  87. typedef struct _SWITCHCONFIG_COM {
  88. DWORD dwComStatus;
  89. } SWITCHCONFIG_COM, *PSWITCHCONFIG_COM;
  90. typedef struct _SWITCHCONFIG {
  91. DWORD cbSize;
  92. UINT uiDeviceType;
  93. UINT uiDeviceNumber;
  94. DWORD dwFlags;
  95. DWORD dwSwitches;
  96. DWORD dwErrorCode;
  97. union {
  98. SWITCHCONFIG_COM Com;
  99. SWITCHCONFIG_LPT Lpt;
  100. SWITCHCONFIG_JOYSTICK Joystick;
  101. SWITCHCONFIG_KEYS Keys;
  102. SWITCHCONFIG_USB USB;
  103. SWITCHCONFIG_IEEE1394 IEEE1394;
  104. } u;
  105. } SWITCHCONFIG, *PSWITCHCONFIG;
  106. HSWITCHDEVICE swchGetSwitchDevice(
  107. HSWITCHPORT hSwitchPort,
  108. UINT uiDeviceType,
  109. UINT uiDeviceNumber );
  110. UINT swchGetDeviceType(
  111. HSWITCHPORT hSwitchPort,
  112. HSWITCHDEVICE hsd );
  113. UINT swchGetPortNumber(
  114. HSWITCHPORT hSwitchPort,
  115. HSWITCHDEVICE hsd );
  116. BOOL swchGetSwitchConfig(
  117. HSWITCHPORT hSwitchPort,
  118. HSWITCHDEVICE hsd,
  119. PSWITCHCONFIG psc );
  120. BOOL swchSetSwitchConfig(
  121. HSWITCHPORT hSwitchPort,
  122. HSWITCHDEVICE hsd,
  123. PSWITCHCONFIG psc );
  124. //v-mjgran: API to modify return value in keyboard hook. Avoid to send the scan char.
  125. void APIENTRY swchCheckForScanChar (BOOL fCheckForScanKey);
  126. LRESULT CALLBACK swcKeyboardHookProc( int nCode, WPARAM wParam, LPARAM lParam );
  127. // bitflags
  128. #define SC_FLAG_ACTIVE 0x00000001
  129. #define SC_FLAG_DEFAULT 0x00000002
  130. #define SC_FLAG_ERROR 0x00000004
  131. #define SC_FLAG_UNAVAILABLE 0x00000080
  132. // bitflags
  133. #define SC_COM_DTR 0x00000010
  134. #define SC_COM_RTS 0x00000020
  135. #define SC_COM_DEFAULT SC_COM_RTS
  136. // bitflags
  137. #define SC_LPT_STROBE 0x00000100
  138. #define SC_LPT_AF 0x00000200
  139. #define SC_LPT_INIT 0x00000400
  140. #define SC_LPT_SLCTIN 0x00000800
  141. #define SC_LPT_DEFAULT 0
  142. #define SC_LPTDATA_DEFAULT 0x000000FF
  143. #define SC_JOY_BUTTONS 0
  144. #define SC_JOY_XYSWITCH 1
  145. #define SC_JOY_XYANALOG 2
  146. #define SC_JOY_DEFAULT SC_JOY_BUTTONS
  147. #define SC_JOYVALUE_DEFAULT 0
  148. // Error return values
  149. #define SWCHERR_NO_ERROR 0
  150. #define SWCHERR_ERROR 1
  151. #define SWCHERR_INVALID_PARAMETER 2
  152. #define SWCHERR_MAXIMUM_USERS 3
  153. #define SWCHERR_ALREADY_OPEN 4
  154. #define SWCHERR_NULL_POINTER 5
  155. #define SWCHERR_INVALID_BUFFER_SIZE 6
  156. #define SWCHERR_ALLOCATING_MEMORY 7