xref: /reactos/win32ss/user/ntuser/input.h (revision 7dd081e9)
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 /* Key States */
51 #define KS_DOWN_BIT      0x80
52 #define KS_LOCK_BIT      0x01
53 /* Scan Codes */
54 #define SC_KEY_UP        0x8000
55 /* lParam bits */
56 #define LP_DO_NOT_CARE_BIT (1<<25) // For GetKeyNameText
57 
58 /* General */
59 CODE_SEG("INIT") NTSTATUS NTAPI InitInputImpl(VOID);
60 VOID NTAPI RawInputThreadMain(VOID);
61 BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt);
62 NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL);
63 BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO);
64 VOID FASTCALL DoTheScreenSaver(VOID);
65 #define ThreadHasInputAccess(W32Thread) (TRUE)
66 
67 /* Keyboard */
68 CODE_SEG("INIT") NTSTATUS NTAPI InitKeyboardImpl(VOID);
69 VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice);
70 PKL W32kGetDefaultKeyLayout(VOID);
71 VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKeyInput);
72 BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected);
73 PKL NTAPI UserHklToKbl(HKL hKl);
74 BOOL NTAPI UserSetDefaultInputLang(HKL hKl);
75 extern INT gLanguageToggleKeyState;
76 extern DWORD gdwLanguageToggleKey;
77 extern INT gLayoutToggleKeyState;
78 extern DWORD gdwLayoutToggleKey;
79 
80 /* Mouse */
81 WORD FASTCALL UserGetMouseButtonsState(VOID);
82 VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA pMouseInputData);
83 BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pMouseInput, BOOL bInjected);
84 
85 /* IMM */
86 UINT FASTCALL IntImmProcessKey(PUSER_MESSAGE_QUEUE, PWND, UINT, WPARAM, LPARAM);
87 VOID FASTCALL IntFreeImeHotKeys(VOID);
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