xref: /reactos/win32ss/user/ntuser/input.h (revision 9cfd8dd9)
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 CODE_SEG("INIT") NTSTATUS NTAPI InitInputImpl(VOID);
63 VOID NTAPI RawInputThreadMain(VOID);
64 BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
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 CODE_SEG("INIT") 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 extern INT gLayoutToggleKeyState;
81 extern DWORD gdwLayoutToggleKey;
82 
83 /* Mouse */
84 WORD FASTCALL UserGetMouseButtonsState(VOID);
85 VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA pMouseInputData);
86 BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pMouseInput, BOOL bInjected);
87 
88 /* IMM */
89 UINT FASTCALL IntImmProcessKey(PUSER_MESSAGE_QUEUE, PWND, UINT, WPARAM, LPARAM);
90 VOID FASTCALL IntFreeImeHotKeys(VOID);
91 
92 extern DWORD gSystemFS;
93 extern UINT gSystemCPCharSet;
94 extern HANDLE ghKeyboardDevice;
95 extern PTHREADINFO ptiRawInput;
96 extern BYTE gafAsyncKeyState[256 * 2 / 8]; // 2 bits per key
97 
98 #define GET_KS_BYTE(vk) ((vk) * 2 / 8)
99 #define GET_KS_DOWN_BIT(vk) (1 << (((vk) % 4)*2))
100 #define GET_KS_LOCK_BIT(vk) (1 << (((vk) % 4)*2 + 1))
101 #define IS_KEY_DOWN(ks, vk) (((ks)[GET_KS_BYTE(vk)] & GET_KS_DOWN_BIT(vk)) ? TRUE : FALSE)
102 #define IS_KEY_LOCKED(ks, vk) (((ks)[GET_KS_BYTE(vk)] & GET_KS_LOCK_BIT(vk)) ? TRUE : FALSE)
103 #define SET_KEY_DOWN(ks, vk, down) (ks)[GET_KS_BYTE(vk)] = ((down) ? \
104                                                             ((ks)[GET_KS_BYTE(vk)] | GET_KS_DOWN_BIT(vk)) : \
105                                                             ((ks)[GET_KS_BYTE(vk)] & ~GET_KS_DOWN_BIT(vk)))
106 #define SET_KEY_LOCKED(ks, vk, down) (ks)[GET_KS_BYTE(vk)] = ((down) ? \
107                                                               ((ks)[GET_KS_BYTE(vk)] | GET_KS_LOCK_BIT(vk)) : \
108                                                               ((ks)[GET_KS_BYTE(vk)] & ~GET_KS_LOCK_BIT(vk)))
109 
110 extern PKL gspklBaseLayout;
111 extern KEYBOARD_ATTRIBUTES gKeyboardInfo;
112