1 /* 2 * ntddkbd.h 3 * 4 * Keyboard IOCTL interface 5 * 6 * This file is part of the w32api package. 7 * 8 * Contributors: 9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net> 10 * 11 * THIS SOFTWARE IS NOT COPYRIGHTED 12 * 13 * This source code is offered for use in the public domain. You may 14 * use, modify or distribute it freely. 15 * 16 * This code is distributed in the hope that it will be useful but 17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 18 * DISCLAIMED. This includes but is not limited to warranties of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 */ 22 23 #pragma once 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define DD_KEYBOARD_DEVICE_NAME "\\Device\\KeyboardClass" 30 #define DD_KEYBOARD_DEVICE_NAME_U L"\\Device\\KeyboardClass" 31 32 #define IOCTL_KEYBOARD_QUERY_ATTRIBUTES \ 33 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS) 34 35 #define IOCTL_KEYBOARD_QUERY_INDICATORS \ 36 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS) 37 38 #define IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION \ 39 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0020, METHOD_BUFFERED, FILE_ANY_ACCESS) 40 41 #define IOCTL_KEYBOARD_QUERY_TYPEMATIC \ 42 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS) 43 44 #define IOCTL_KEYBOARD_SET_TYPEMATIC \ 45 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0001, METHOD_BUFFERED, FILE_ANY_ACCESS) 46 47 #define IOCTL_KEYBOARD_SET_INDICATORS \ 48 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0002, METHOD_BUFFERED, FILE_ANY_ACCESS) 49 50 #define IOCTL_KEYBOARD_INSERT_DATA \ 51 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0040, METHOD_BUFFERED, FILE_ANY_ACCESS) 52 53 #define IOCTL_KEYBOARD_QUERY_IME_STATUS \ 54 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0400, METHOD_BUFFERED, FILE_ANY_ACCESS) 55 56 #define IOCTL_KEYBOARD_SET_IME_STATUS \ 57 CTL_CODE(FILE_DEVICE_KEYBOARD, 0x0401, METHOD_BUFFERED, FILE_ANY_ACCESS) 58 59 DEFINE_GUID(GUID_DEVINTERFACE_KEYBOARD, \ 60 0x884b96c3, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd); 61 62 #define GUID_CLASS_KEYBOARD GUID_DEVINTERFACE_KEYBOARD /* Obsolete */ 63 64 #define KEYBOARD_ERROR_VALUE_BASE 10000 65 66 /* KEYBOARD_INPUT_DATA.MakeCode constants */ 67 #define KEYBOARD_OVERRUN_MAKE_CODE 0xFF 68 69 /* KEYBOARD_INPUT_DATA.Flags constants */ 70 #define KEY_MAKE 0 71 #define KEY_BREAK 1 72 #define KEY_E0 2 73 #define KEY_E1 4 74 #define KEY_TERMSRV_SET_LED 8 75 #define KEY_TERMSRV_SHADOW 0x10 76 #define KEY_TERMSRV_VKPACKET 0x20 77 78 #define KEYBOARD_LED_INJECTED 0x8000 79 #define KEYBOARD_SHADOW 0x4000 80 #define KEYBOARD_KANA_LOCK_ON 8 81 #define KEYBOARD_CAPS_LOCK_ON 4 82 #define KEYBOARD_NUM_LOCK_ON 2 83 #define KEYBOARD_SCROLL_LOCK_ON 1 84 85 typedef struct _KEYBOARD_INPUT_DATA { 86 USHORT UnitId; 87 USHORT MakeCode; 88 USHORT Flags; 89 USHORT Reserved; 90 ULONG ExtraInformation; 91 } KEYBOARD_INPUT_DATA, *PKEYBOARD_INPUT_DATA; 92 93 94 typedef struct _KEYBOARD_TYPEMATIC_PARAMETERS { 95 USHORT UnitId; 96 USHORT Rate; 97 USHORT Delay; 98 } KEYBOARD_TYPEMATIC_PARAMETERS, *PKEYBOARD_TYPEMATIC_PARAMETERS; 99 100 typedef struct _KEYBOARD_ID { 101 UCHAR Type; 102 UCHAR Subtype; 103 } KEYBOARD_ID, *PKEYBOARD_ID; 104 105 #define ENHANCED_KEYBOARD(Id) ((Id).Type == 2 || (Id).Type == 4 || FAREAST_KEYBOARD(Id)) 106 #define FAREAST_KEYBOARD(Id) ((Id).Type == 7 || (Id).Type == 8) 107 108 typedef struct _KEYBOARD_INDICATOR_PARAMETERS { 109 USHORT UnitId; 110 USHORT LedFlags; 111 } KEYBOARD_INDICATOR_PARAMETERS, *PKEYBOARD_INDICATOR_PARAMETERS; 112 113 typedef struct _INDICATOR_LIST { 114 USHORT MakeCode; 115 USHORT IndicatorFlags; 116 } INDICATOR_LIST, *PINDICATOR_LIST; 117 118 typedef struct _KEYBOARD_INDICATOR_TRANSLATION { 119 USHORT NumberOfIndicatorKeys; 120 INDICATOR_LIST IndicatorList[1]; 121 } KEYBOARD_INDICATOR_TRANSLATION, *PKEYBOARD_INDICATOR_TRANSLATION; 122 123 typedef struct _KEYBOARD_ATTRIBUTES { 124 KEYBOARD_ID KeyboardIdentifier; 125 USHORT KeyboardMode; 126 USHORT NumberOfFunctionKeys; 127 USHORT NumberOfIndicators; 128 USHORT NumberOfKeysTotal; 129 ULONG InputDataQueueLength; 130 KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMinimum; 131 KEYBOARD_TYPEMATIC_PARAMETERS KeyRepeatMaximum; 132 } KEYBOARD_ATTRIBUTES, *PKEYBOARD_ATTRIBUTES; 133 134 typedef struct _KEYBOARD_UNIT_ID_PARAMETER { 135 USHORT UnitId; 136 } KEYBOARD_UNIT_ID_PARAMETER, *PKEYBOARD_UNIT_ID_PARAMETER; 137 138 typedef struct _KEYBOARD_IME_STATUS { 139 USHORT UnitId; 140 ULONG ImeOpen; 141 ULONG ImeConvMode; 142 } KEYBOARD_IME_STATUS, *PKEYBOARD_IME_STATUS; 143 144 #ifdef __cplusplus 145 } 146 #endif 147