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.

365 lines
8.3 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntddkbd.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. accessing the keyboard device.
  8. Author:
  9. Lee A. Smith (lees) 02-Aug-1991.
  10. Revision History:
  11. --*/
  12. #ifndef _NTDDKBD_
  13. #define _NTDDKBD_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // Device Name - this string is the name of the device. It is the name
  22. // that should be passed to NtOpenFile when accessing the device.
  23. //
  24. // Note: For devices that support multiple units, it should be suffixed
  25. // with the Ascii representation of the unit number.
  26. //
  27. #define DD_KEYBOARD_DEVICE_NAME "\\Device\\KeyboardClass"
  28. #define DD_KEYBOARD_DEVICE_NAME_U L"\\Device\\KeyboardClass"
  29. //
  30. // NtDeviceIoControlFile IoControlCode values for this device.
  31. //
  32. // Warning: Remember that the low two bits of the code specify how the
  33. // buffers are passed to the driver!
  34. //
  35. #define IOCTL_KEYBOARD_QUERY_ATTRIBUTES CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  36. #define IOCTL_KEYBOARD_SET_TYPEMATIC CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0001, METHOD_BUFFERED, FILE_ANY_ACCESS)
  37. #define IOCTL_KEYBOARD_SET_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0002, METHOD_BUFFERED, FILE_ANY_ACCESS)
  38. #define IOCTL_KEYBOARD_QUERY_TYPEMATIC CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  39. #define IOCTL_KEYBOARD_QUERY_INDICATORS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  40. #define IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0020, METHOD_BUFFERED, FILE_ANY_ACCESS)
  41. #define IOCTL_KEYBOARD_INSERT_DATA CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0040, METHOD_BUFFERED, FILE_ANY_ACCESS)
  42. //
  43. // These Device IO control query/set IME status to keyboard hardware.
  44. //
  45. #define IOCTL_KEYBOARD_QUERY_IME_STATUS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0400, METHOD_BUFFERED, FILE_ANY_ACCESS)
  46. #define IOCTL_KEYBOARD_SET_IME_STATUS CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0401, METHOD_BUFFERED, FILE_ANY_ACCESS)
  47. //
  48. // Declare the GUID that represents the device interface for keyboards.
  49. //
  50. #ifndef FAR
  51. #define FAR
  52. #endif
  53. DEFINE_GUID( GUID_DEVINTERFACE_KEYBOARD, 0x884b96c3, 0x56ef, 0x11d1, \
  54. 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd);
  55. //
  56. // Obsolete device interface class GUID name.
  57. // (use of above GUID_DEVINTERFACE_* name is recommended).
  58. //
  59. #define GUID_CLASS_KEYBOARD GUID_DEVINTERFACE_KEYBOARD
  60. //
  61. // NtReadFile Output Buffer record structures for this device.
  62. //
  63. typedef struct _KEYBOARD_INPUT_DATA {
  64. //
  65. // Unit number. E.g., for \Device\KeyboardPort0 the unit is '0',
  66. // for \Device\KeyboardPort1 the unit is '1', and so on.
  67. //
  68. USHORT UnitId;
  69. //
  70. // The "make" scan code (key depression).
  71. //
  72. USHORT MakeCode;
  73. //
  74. // The flags field indicates a "break" (key release) and other
  75. // miscellaneous scan code information defined below.
  76. //
  77. USHORT Flags;
  78. USHORT Reserved;
  79. //
  80. // Device-specific additional information for the event.
  81. //
  82. ULONG ExtraInformation;
  83. } KEYBOARD_INPUT_DATA, *PKEYBOARD_INPUT_DATA;
  84. //
  85. // Define the keyboard overrun MakeCode.
  86. //
  87. #define KEYBOARD_OVERRUN_MAKE_CODE 0xFF
  88. //
  89. // Define the keyboard input data Flags.
  90. //
  91. #define KEY_MAKE 0
  92. #define KEY_BREAK 1
  93. #define KEY_E0 2
  94. #define KEY_E1 4
  95. #define KEY_TERMSRV_SET_LED 8
  96. #define KEY_TERMSRV_SHADOW 0x10
  97. #define KEY_TERMSRV_VKPACKET 0x20
  98. //
  99. // NtDeviceIoControlFile Input/Output Buffer record structures for
  100. // IOCTL_KEYBOARD_QUERY_TYPEMATIC/IOCTL_KEYBOARD_SET_TYPEMATIC.
  101. //
  102. typedef struct _KEYBOARD_TYPEMATIC_PARAMETERS {
  103. //
  104. // Unit identifier. Specifies the device unit for which this
  105. // request is intended.
  106. //
  107. USHORT UnitId;
  108. //
  109. // Typematic rate, in repeats per second.
  110. //
  111. USHORT Rate;
  112. //
  113. // Typematic delay, in milliseconds.
  114. //
  115. USHORT Delay;
  116. } KEYBOARD_TYPEMATIC_PARAMETERS, *PKEYBOARD_TYPEMATIC_PARAMETERS;
  117. //
  118. // NtDeviceIoControlFile OutputBuffer record structures for
  119. // IOCTL_KEYBOARD_QUERY_ATTRIBUTES.
  120. //
  121. typedef struct _KEYBOARD_ID {
  122. UCHAR Type; // Keyboard type
  123. UCHAR Subtype; // Keyboard subtype (OEM-dependent value)
  124. } KEYBOARD_ID, *PKEYBOARD_ID;
  125. typedef struct _KEYBOARD_ATTRIBUTES {
  126. //
  127. // Keyboard ID value. Used to distinguish between keyboard types.
  128. //
  129. KEYBOARD_ID KeyboardIdentifier;
  130. //
  131. // Scan code mode.
  132. //
  133. USHORT KeyboardMode;
  134. //
  135. // Number of function keys located on the keyboard.
  136. //
  137. USHORT NumberOfFunctionKeys;
  138. //
  139. // Number of LEDs located on the keyboard.
  140. //
  141. USHORT NumberOfIndicators;
  142. //
  143. // Total number of keys located on the keyboard.
  144. //
  145. USHORT NumberOfKeysTotal;
  146. //
  147. // Length of the typeahead buffer, in bytes.
  148. //
  149. ULONG InputDataQueueLength;
  150. //
  151. // Minimum allowable values of keyboard typematic rate and delay.
  152. //
  153. KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMinimum;
  154. //
  155. // Maximum allowable values of keyboard typematic rate and delay.
  156. //
  157. KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMaximum;
  158. } KEYBOARD_ATTRIBUTES, *PKEYBOARD_ATTRIBUTES;
  159. //
  160. // ENHANCED_KEYBOARD() is TRUE if the value for keyboard type indicates an
  161. // Enhanced (101- or 102-key) or compatible keyboard. The result is FALSE
  162. // if the keyboard is an old-style AT keyboard (83- or 84- or 86-key keyboard).
  163. //
  164. #define ENHANCED_KEYBOARD(Id) ((Id).Type == 2 || (Id).Type == 4 || FAREAST_KEYBOARD(Id))
  165. //
  166. // Japanese keyboard(7) and Korean keyboard(8) are also Enhanced (101-)
  167. // or compatible keyboard.
  168. //
  169. #define FAREAST_KEYBOARD(Id) ((Id).Type == 7 || (Id).Type == 8)
  170. //
  171. // NtDeviceIoControlFile Input/Output Buffer record structures for
  172. // IOCTL_KEYBOARD_QUERY_INDICATORS/IOCTL_KEYBOARD_SET_INDICATORS.
  173. //
  174. typedef struct _KEYBOARD_INDICATOR_PARAMETERS {
  175. //
  176. // Unit identifier. Specifies the device unit for which this
  177. // request is intended.
  178. //
  179. USHORT UnitId;
  180. //
  181. // LED indicator state.
  182. //
  183. USHORT LedFlags;
  184. } KEYBOARD_INDICATOR_PARAMETERS, *PKEYBOARD_INDICATOR_PARAMETERS;
  185. //
  186. // NtDeviceIoControlFile Output Buffer record structures for
  187. // IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION.
  188. //
  189. typedef struct _INDICATOR_LIST {
  190. //
  191. // The "make" scan code (key depression).
  192. //
  193. USHORT MakeCode;
  194. //
  195. // The associated LED indicators.
  196. //
  197. USHORT IndicatorFlags;
  198. } INDICATOR_LIST, *PINDICATOR_LIST;
  199. typedef struct _KEYBOARD_INDICATOR_TRANSLATION {
  200. //
  201. // Number of entries in IndicatorList.
  202. //
  203. USHORT NumberOfIndicatorKeys;
  204. //
  205. // List of the scancode-to-indicator mappings.
  206. //
  207. INDICATOR_LIST IndicatorList[1];
  208. } KEYBOARD_INDICATOR_TRANSLATION, *PKEYBOARD_INDICATOR_TRANSLATION;
  209. //
  210. // Define the keyboard indicators.
  211. //
  212. #define KEYBOARD_LED_INJECTED 0x8000 //Used by Terminal Server
  213. #define KEYBOARD_SHADOW 0x4000 //Used by Terminal Server
  214. //#if defined(FE_SB) || defined(WINDOWS_FE) || defined(DBCS)
  215. #define KEYBOARD_KANA_LOCK_ON 8 // Japanese keyboard
  216. //#endif // defined(FE_SB) || defined(WINDOWS_FE) || defined(DBCS)
  217. #define KEYBOARD_CAPS_LOCK_ON 4
  218. #define KEYBOARD_NUM_LOCK_ON 2
  219. #define KEYBOARD_SCROLL_LOCK_ON 1
  220. //
  221. // Generic NtDeviceIoControlFile Input Buffer record structure for
  222. // various keyboard IOCTLs.
  223. //
  224. typedef struct _KEYBOARD_UNIT_ID_PARAMETER {
  225. //
  226. // Unit identifier. Specifies the device unit for which this
  227. // request is intended.
  228. //
  229. USHORT UnitId;
  230. } KEYBOARD_UNIT_ID_PARAMETER, *PKEYBOARD_UNIT_ID_PARAMETER;
  231. //
  232. // Define the base values for the keyboard error log packet's
  233. // UniqueErrorValue field.
  234. //
  235. #define KEYBOARD_ERROR_VALUE_BASE 10000
  236. //
  237. // NtDeviceIoControlFile Input/Output Buffer record structures for
  238. // IOCTL_KEYBOARD_QUERY_IME_STATUS/IOCTL_KEYBOARD_SET_IME_STATUS.
  239. //
  240. typedef struct _KEYBOARD_IME_STATUS {
  241. //
  242. // Unit identifier. Specifies the device unit for which this
  243. // request is intended.
  244. //
  245. USHORT UnitId;
  246. //
  247. // Ime open or close status.
  248. //
  249. ULONG ImeOpen;
  250. //
  251. // Ime conversion status.
  252. //
  253. ULONG ImeConvMode;
  254. } KEYBOARD_IME_STATUS, *PKEYBOARD_IME_STATUS;
  255. #ifdef __cplusplus
  256. }
  257. #endif
  258. #endif // _NTDDKBD_