1 #pragma once 2 3 #include <ndk/kbd.h> 4 5 typedef struct tagKBDNLSLAYER 6 { 7 USHORT OEMIdentifier; 8 USHORT LayoutInformation; 9 UINT NumOfVkToF; 10 struct _VK_TO_FUNCTION_TABLE *pVkToF; 11 INT NumOfMouseVKey; 12 PUSHORT pusMouseVKey; 13 } KBDNLSLAYER, *PKBDNLSLAYER; 14 15 typedef struct tagKBDFILE 16 { 17 HEAD head; 18 struct tagKBDFILE *pkfNext; 19 WCHAR awchKF[20]; 20 HANDLE hBase; 21 struct _KBDTABLES *pKbdTbl; 22 ULONG Size; 23 PKBDNLSLAYER pKbdNlsTbl; 24 } KBDFILE, *PKBDFILE; 25 26 typedef struct tagKL 27 { 28 HEAD head; 29 struct tagKL *pklNext; 30 struct tagKL *pklPrev; 31 DWORD dwKL_Flags; 32 HKL hkl; 33 PKBDFILE spkf; 34 DWORD dwFontSigs; 35 UINT iBaseCharset; 36 USHORT CodePage; 37 WCHAR wchDiacritic; 38 PIMEINFOEX piiex; 39 } KL, *PKL; 40 41 typedef struct _ATTACHINFO 42 { 43 struct _ATTACHINFO *paiNext; 44 PTHREADINFO pti1; 45 PTHREADINFO pti2; 46 } ATTACHINFO, *PATTACHINFO; 47 48 extern PATTACHINFO gpai; 49 50 /* Keyboard layout undocumented flags */ 51 #define KLF_UNLOAD 0x20000000 52 53 /* Key States */ 54 #define KS_DOWN_BIT 0x80 55 #define KS_LOCK_BIT 0x01 56 /* Scan Codes */ 57 #define SC_KEY_UP 0x8000 58 /* lParam bits */ 59 #define LP_DO_NOT_CARE_BIT (1<<25) // For GetKeyNameText 60 61 /* General */ 62 INIT_FUNCTION NTSTATUS NTAPI InitInputImpl(VOID); 63 BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt); 64 DWORD NTAPI CreateSystemThreads(UINT Type); 65 NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL); 66 BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO); 67 VOID FASTCALL DoTheScreenSaver(VOID); 68 #define ThreadHasInputAccess(W32Thread) (TRUE) 69 70 /* Keyboard */ 71 INIT_FUNCTION NTSTATUS NTAPI InitKeyboardImpl(VOID); 72 VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice); 73 PKL W32kGetDefaultKeyLayout(VOID); 74 VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKeyInput); 75 BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected); 76 PKL NTAPI UserHklToKbl(HKL hKl); 77 BOOL NTAPI UserSetDefaultInputLang(HKL hKl); 78 extern int gLanguageToggleKeyState; 79 extern DWORD gdwLanguageToggleKey; 80 81 /* Mouse */ 82 WORD FASTCALL UserGetMouseButtonsState(VOID); 83 VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA pMouseInputData); 84 BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pMouseInput, BOOL bInjected); 85 86 /* IMM */ 87 UINT FASTCALL IntImmProcessKey(PUSER_MESSAGE_QUEUE, PWND, UINT, WPARAM, LPARAM); 88 89 extern DWORD gSystemFS; 90 extern UINT gSystemCPCharSet; 91 extern HANDLE ghKeyboardDevice; 92 extern PTHREADINFO ptiRawInput; 93 extern BYTE gafAsyncKeyState[256 * 2 / 8]; // 2 bits per key 94 95 #define GET_KS_BYTE(vk) ((vk) * 2 / 8) 96 #define GET_KS_DOWN_BIT(vk) (1 << (((vk) % 4)*2)) 97 #define GET_KS_LOCK_BIT(vk) (1 << (((vk) % 4)*2 + 1)) 98 #define IS_KEY_DOWN(ks, vk) (((ks)[GET_KS_BYTE(vk)] & GET_KS_DOWN_BIT(vk)) ? TRUE : FALSE) 99 #define IS_KEY_LOCKED(ks, vk) (((ks)[GET_KS_BYTE(vk)] & GET_KS_LOCK_BIT(vk)) ? TRUE : FALSE) 100 #define SET_KEY_DOWN(ks, vk, down) (ks)[GET_KS_BYTE(vk)] = ((down) ? \ 101 ((ks)[GET_KS_BYTE(vk)] | GET_KS_DOWN_BIT(vk)) : \ 102 ((ks)[GET_KS_BYTE(vk)] & ~GET_KS_DOWN_BIT(vk))) 103 #define SET_KEY_LOCKED(ks, vk, down) (ks)[GET_KS_BYTE(vk)] = ((down) ? \ 104 ((ks)[GET_KS_BYTE(vk)] | GET_KS_LOCK_BIT(vk)) : \ 105 ((ks)[GET_KS_BYTE(vk)] & ~GET_KS_LOCK_BIT(vk))) 106 107 extern PKL gspklBaseLayout; 108 extern KEYBOARD_ATTRIBUTES gKeyboardInfo; 109