ReactOS  0.4.12-dev-919-gfc3b8d5
input.h File Reference
#include <ndk/kbd.h>
Include dependency graph for input.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagKBDNLSLAYER
 
struct  tagKBDFILE
 
struct  tagKL
 
struct  _ATTACHINFO
 

Macros

#define KLF_UNLOAD   0x20000000
 
#define KS_DOWN_BIT   0x80
 
#define KS_LOCK_BIT   0x01
 
#define SC_KEY_UP   0x8000
 
#define LP_DO_NOT_CARE_BIT   (1<<25)
 
#define ThreadHasInputAccess(W32Thread)   (TRUE)
 
#define GET_KS_BYTE(vk)   ((vk) * 2 / 8)
 
#define GET_KS_DOWN_BIT(vk)   (1 << (((vk) % 4)*2))
 
#define GET_KS_LOCK_BIT(vk)   (1 << (((vk) % 4)*2 + 1))
 
#define IS_KEY_DOWN(ks, vk)   (((ks)[GET_KS_BYTE(vk)] & GET_KS_DOWN_BIT(vk)) ? TRUE : FALSE)
 
#define IS_KEY_LOCKED(ks, vk)   (((ks)[GET_KS_BYTE(vk)] & GET_KS_LOCK_BIT(vk)) ? TRUE : FALSE)
 
#define SET_KEY_DOWN(ks, vk, down)
 
#define SET_KEY_LOCKED(ks, vk, down)
 

Typedefs

typedef struct tagKBDNLSLAYER KBDNLSLAYER
 
typedef struct tagKBDNLSLAYERPKBDNLSLAYER
 
typedef struct tagKBDFILE KBDFILE
 
typedef struct tagKBDFILEPKBDFILE
 
typedef struct tagKL KL
 
typedef struct tagKLPKL
 
typedef struct _ATTACHINFO ATTACHINFO
 
typedef struct _ATTACHINFOPATTACHINFO
 

Functions

INIT_FUNCTION NTSTATUS NTAPI InitInputImpl (VOID)
 
VOID NTAPI RawInputThreadMain (VOID)
 
BOOL FASTCALL IntBlockInput (PTHREADINFO W32Thread, BOOL BlockIt)
 
NTSTATUS FASTCALL UserAttachThreadInput (PTHREADINFO, PTHREADINFO, BOOL)
 
BOOL FASTCALL IsRemoveAttachThread (PTHREADINFO)
 
VOID FASTCALL DoTheScreenSaver (VOID)
 
INIT_FUNCTION NTSTATUS NTAPI InitKeyboardImpl (VOID)
 
VOID NTAPI UserInitKeyboard (HANDLE hKeyboardDevice)
 
PKL W32kGetDefaultKeyLayout (VOID)
 
VOID NTAPI UserProcessKeyboardInput (PKEYBOARD_INPUT_DATA pKeyInput)
 
BOOL NTAPI UserSendKeyboardInput (KEYBDINPUT *pKbdInput, BOOL bInjected)
 
PKL NTAPI UserHklToKbl (HKL hKl)
 
BOOL NTAPI UserSetDefaultInputLang (HKL hKl)
 
WORD FASTCALL UserGetMouseButtonsState (VOID)
 
VOID NTAPI UserProcessMouseInput (PMOUSE_INPUT_DATA pMouseInputData)
 
BOOL NTAPI UserSendMouseInput (MOUSEINPUT *pMouseInput, BOOL bInjected)
 
UINT FASTCALL IntImmProcessKey (PUSER_MESSAGE_QUEUE, PWND, UINT, WPARAM, LPARAM)
 

Variables

PATTACHINFO gpai
 
int gLanguageToggleKeyState
 
DWORD gdwLanguageToggleKey
 
DWORD gSystemFS
 
UINT gSystemCPCharSet
 
HANDLE ghKeyboardDevice
 
PTHREADINFO ptiRawInput
 
BYTE gafAsyncKeyState [256 *2/8]
 
PKL gspklBaseLayout
 
KEYBOARD_ATTRIBUTES gKeyboardInfo
 

Macro Definition Documentation

◆ GET_KS_BYTE

#define GET_KS_BYTE (   vk)    ((vk) * 2 / 8)

Definition at line 95 of file input.h.

◆ GET_KS_DOWN_BIT

#define GET_KS_DOWN_BIT (   vk)    (1 << (((vk) % 4)*2))

Definition at line 96 of file input.h.

◆ GET_KS_LOCK_BIT

#define GET_KS_LOCK_BIT (   vk)    (1 << (((vk) % 4)*2 + 1))

Definition at line 97 of file input.h.

◆ IS_KEY_DOWN

#define IS_KEY_DOWN (   ks,
  vk 
)    (((ks)[GET_KS_BYTE(vk)] & GET_KS_DOWN_BIT(vk)) ? TRUE : FALSE)

Definition at line 98 of file input.h.

◆ IS_KEY_LOCKED

#define IS_KEY_LOCKED (   ks,
  vk 
)    (((ks)[GET_KS_BYTE(vk)] & GET_KS_LOCK_BIT(vk)) ? TRUE : FALSE)

Definition at line 99 of file input.h.

◆ KLF_UNLOAD

#define KLF_UNLOAD   0x20000000

Definition at line 51 of file input.h.

◆ KS_DOWN_BIT

#define KS_DOWN_BIT   0x80

Definition at line 54 of file input.h.

◆ KS_LOCK_BIT

#define KS_LOCK_BIT   0x01

Definition at line 55 of file input.h.

◆ LP_DO_NOT_CARE_BIT

#define LP_DO_NOT_CARE_BIT   (1<<25)

Definition at line 59 of file input.h.

◆ SC_KEY_UP

#define SC_KEY_UP   0x8000

Definition at line 57 of file input.h.

◆ SET_KEY_DOWN

#define SET_KEY_DOWN (   ks,
  vk,
  down 
)
Value:
(ks)[GET_KS_BYTE(vk)] = ((down) ? \
((ks)[GET_KS_BYTE(vk)] | GET_KS_DOWN_BIT(vk)) : \
((ks)[GET_KS_BYTE(vk)] & ~GET_KS_DOWN_BIT(vk)))
#define down(mutex)
Definition: glue.h:29
#define GET_KS_BYTE(vk)
Definition: input.h:95
#define GET_KS_DOWN_BIT(vk)
Definition: input.h:96

Definition at line 100 of file input.h.

◆ SET_KEY_LOCKED

#define SET_KEY_LOCKED (   ks,
  vk,
  down 
)
Value:
(ks)[GET_KS_BYTE(vk)] = ((down) ? \
((ks)[GET_KS_BYTE(vk)] | GET_KS_LOCK_BIT(vk)) : \
((ks)[GET_KS_BYTE(vk)] & ~GET_KS_LOCK_BIT(vk)))
#define down(mutex)
Definition: glue.h:29
#define GET_KS_LOCK_BIT(vk)
Definition: input.h:97
#define GET_KS_BYTE(vk)
Definition: input.h:95

Definition at line 103 of file input.h.

◆ ThreadHasInputAccess

#define ThreadHasInputAccess (   W32Thread)    (TRUE)

Definition at line 68 of file input.h.

Typedef Documentation

◆ ATTACHINFO

◆ KBDFILE

◆ KBDNLSLAYER

◆ KL

typedef struct tagKL KL

◆ PATTACHINFO

◆ PKBDFILE

◆ PKBDNLSLAYER

◆ PKL

typedef struct tagKL * PKL

Function Documentation

◆ DoTheScreenSaver()

VOID FASTCALL DoTheScreenSaver ( VOID  )

Definition at line 50 of file input.c.

51 {
52  LARGE_INTEGER TickCount;
53  DWORD Test, TO;
54 
55  if (gspv.iScrSaverTimeout > 0) // Zero means Off.
56  {
57  KeQueryTickCount(&TickCount);
58  Test = MsqCalculateMessageTime(&TickCount);
60  TO = 1000 * gspv.iScrSaverTimeout;
61  if (Test > TO)
62  {
63  TRACE("Screensaver Message Start! Tick %lu Timeout %d \n", Test, gspv.iScrSaverTimeout);
64 
65  if (ppiScrnSaver) // We are or we are not the screensaver, prevent reentry...
66  {
67  if (!(ppiScrnSaver->W32PF_flags & W32PF_IDLESCREENSAVER))
68  {
69  ppiScrnSaver->W32PF_flags |= W32PF_IDLESCREENSAVER;
70  ERR("Screensaver is Idle\n");
71  }
72  }
73  else
74  {
75  PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
76  if (ForegroundQueue && ForegroundQueue->spwndActive)
77  UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_START_SCREENSAVE, 1); // lParam 1 == Secure
78  else
80  }
81  }
82  }
83 }
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1189
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
INT iScrSaverTimeout
Definition: sysparams.h:110
static __inline LONG MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount)
Definition: msgqueue.h:253
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1271
#define LN_START_SCREENSAVE
Definition: undocuser.h:119
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
HWND hwndSAS
Definition: winsta.c:24
#define TRACE(s)
Definition: solgame.cpp:4
SPIVALUES gspv
Definition: sysparams.c:17
unsigned long DWORD
Definition: ntddk_ex.h:95
#define W32PF_IDLESCREENSAVER
Definition: win32.h:27
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
#define ERR(fmt,...)
Definition: debug.h:109
static DWORD LastInputTick
Definition: input.c:21

Referenced by HungAppSysTimerProc().

◆ InitInputImpl()

INIT_FUNCTION NTSTATUS NTAPI InitInputImpl ( VOID  )

Definition at line 364 of file input.c.

365 {
367  if (!MasterTimer)
368  {
369  ERR("Failed to allocate memory\n");
370  ASSERT(FALSE);
371  return STATUS_UNSUCCESSFUL;
372  }
374 
375  return STATUS_SUCCESS;
376 }
PKTIMER MasterTimer
Definition: input.c:16
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define USERTAG_SYSTEM
Definition: tags.h:281
#define ERR(fmt,...)
Definition: debug.h:109
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by DriverEntry().

◆ InitKeyboardImpl()

INIT_FUNCTION NTSTATUS NTAPI InitKeyboardImpl ( VOID  )

Definition at line 31 of file keyboard.c.

32 {
35  // Clear and set default information.
37  gKeyboardInfo.KeyboardIdentifier.Type = 4; /* AT-101 */
38  gKeyboardInfo.NumberOfFunctionKeys = 12; /* We're doing an 101 for now, so return 12 F-keys */
39  return STATUS_SUCCESS;
40 }
UCHAR Type
Definition: ntddkbd.h:101
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
static BYTE gafAsyncKeyStateRecentDown[256/8]
Definition: keyboard.c:14
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by DriverEntry().

◆ IntBlockInput()

BOOL FASTCALL IntBlockInput ( PTHREADINFO  W32Thread,
BOOL  BlockIt 
)

Definition at line 379 of file input.c.

380 {
381  PTHREADINFO OldBlock;
382  ASSERT(pti);
383 
384  if(!pti->rpdesk || ((pti->TIF_flags & TIF_INCLEANUP) && BlockIt))
385  {
386  /*
387  * Fail blocking if exiting the thread
388  */
389 
390  return FALSE;
391  }
392 
393  /*
394  * FIXME: Check access rights of the window station
395  * e.g. services running in the service window station cannot block input
396  */
397  if(!ThreadHasInputAccess(pti) ||
398  !IntIsActiveDesktop(pti->rpdesk))
399  {
401  return FALSE;
402  }
403 
404  ASSERT(pti->rpdesk);
405  OldBlock = pti->rpdesk->BlockInputThread;
406  if(OldBlock)
407  {
408  if(OldBlock != pti)
409  {
411  return FALSE;
412  }
413  pti->rpdesk->BlockInputThread = (BlockIt ? pti : NULL);
414  return OldBlock == NULL;
415  }
416 
417  pti->rpdesk->BlockInputThread = (BlockIt ? pti : NULL);
418  return OldBlock == NULL;
419 }
struct _DESKTOP * rpdesk
Definition: win32.h:91
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define ThreadHasInputAccess(W32Thread)
Definition: input.h:68
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IntIsActiveDesktop(Desktop)
Definition: desktop.h:198
#define TIF_INCLEANUP
Definition: ntuser.h:240
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by ExitThreadCallback(), and NtUserBlockInput().

◆ IntImmProcessKey()

UINT FASTCALL IntImmProcessKey ( PUSER_MESSAGE_QUEUE  ,
PWND  ,
UINT  ,
WPARAM  ,
LPARAM   
)

Definition at line 14 of file ime.c.

15 {
16  PKL pKbdLayout;
17 
18  ASSERT_REFS_CO(pWnd);
19 
20  if ( Msg == WM_KEYDOWN ||
21  Msg == WM_SYSKEYDOWN ||
22  Msg == WM_KEYUP ||
23  Msg == WM_SYSKEYUP )
24  {
25  //Vk = wParam & 0xff;
26  pKbdLayout = pWnd->head.pti->KeyboardLayout;
27  if (pKbdLayout == NULL) return 0;
28  //
29  if (!(gpsi->dwSRVIFlags & SRVINFO_IMM32)) return 0;
30  // need ime.h!
31  }
32  // Call User32:
33  // Anything but BOOL!
34  //ImmRet = co_IntImmProcessKey(UserHMGetHandle(pWnd), pKbdLayout->hkl, Vk, lParam, HotKey);
35  FIXME(" is UNIMPLEMENTED.\n");
36  return 0;
37 }
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:13
struct @1567 Msg[]
PSERVERINFO gpsi
Definition: main.c:27
DWORD dwSRVIFlags
Definition: ntuser.h:1004
#define FIXME(fmt,...)
Definition: debug.h:110
HEAD head
Definition: input.h:28
smooth NULL
Definition: ftsmooth.c:416
Definition: input.h:26
#define WM_KEYDOWN
Definition: winuser.h:1691
#define WM_KEYUP
Definition: winuser.h:1692
#define WM_SYSKEYUP
Definition: winuser.h:1696
#define SRVINFO_IMM32
Definition: ntuser.h:910
#define WM_SYSKEYDOWN
Definition: winuser.h:1695

Referenced by co_IntProcessKeyboardMessage().

◆ IsRemoveAttachThread()

BOOL FASTCALL IsRemoveAttachThread ( PTHREADINFO  )

Definition at line 441 of file input.c.

442 {
444  PATTACHINFO pai;
445  BOOL Ret = TRUE;
446  PTHREADINFO ptiFrom = NULL, ptiTo = NULL;
447 
448  do
449  {
450  if (!gpai) return TRUE;
451 
452  pai = gpai; // Bottom of the list.
453 
454  do
455  {
456  if (pai->pti2 == pti)
457  {
458  ptiFrom = pai->pti1;
459  ptiTo = pti;
460  break;
461  }
462  if (pai->pti1 == pti)
463  {
464  ptiFrom = pti;
465  ptiTo = pai->pti2;
466  break;
467  }
468  pai = pai->paiNext;
469 
470  } while (pai);
471 
472  if (!pai && !ptiFrom && !ptiTo) break;
473 
474  Status = UserAttachThreadInput(ptiFrom, ptiTo, FALSE);
475  if (!NT_SUCCESS(Status)) Ret = FALSE;
476 
477  } while (Ret);
478 
479  return Ret;
480 }
PTHREADINFO pti1
Definition: input.h:44
#define TRUE
Definition: types.h:120
NTSTATUS FASTCALL UserAttachThreadInput(PTHREADINFO ptiFrom, PTHREADINFO ptiTo, BOOL fAttach)
Definition: input.c:483
PATTACHINFO gpai
Definition: input.c:17
LONG NTSTATUS
Definition: precomp.h:26
struct _ATTACHINFO * paiNext
Definition: input.h:43
unsigned int BOOL
Definition: ntddk_ex.h:94
PTHREADINFO pti2
Definition: input.h:45
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24

Referenced by ExitThreadCallback().

◆ RawInputThreadMain()

VOID NTAPI RawInputThreadMain ( VOID  )

Definition at line 128 of file input.c.

129 {
130  NTSTATUS MouStatus = STATUS_UNSUCCESSFUL, KbdStatus = STATUS_UNSUCCESSFUL, Status;
131  IO_STATUS_BLOCK MouIosb, KbdIosb;
132  PFILE_OBJECT pKbdDevice = NULL, pMouDevice = NULL;
134  //LARGE_INTEGER WaitTimeout;
135  PVOID WaitObjects[4], pSignaledObject = NULL;
137  ULONG cWaitObjects = 0, cMaxWaitObjects = 2;
138  MOUSE_INPUT_DATA MouseInput;
139  KEYBOARD_INPUT_DATA KeyInput;
141  HWINSTA hWinSta;
142 
143  ByteOffset.QuadPart = (LONGLONG)0;
144  //WaitTimeout.QuadPart = (LONGLONG)(-10000000);
145 
149 
150  TRACE("Raw Input Thread %p\n", ptiRawInput);
151 
154 
156  0,
157  NULL,
160  UserMode,
161  (PHANDLE)&hWinSta);
162  if (NT_SUCCESS(Status))
163  {
165  }
166  else
167  {
168  ASSERT(FALSE);
169  /* Failed to open the interactive winsta! What now? */
170  }
171 
173  StartTheTimers();
174  UserLeave();
175 
178 
180  for (;;)
181  {
182  if (!ghMouseDevice)
183  {
184  /* Check if mouse device already exists */
185  Status = OpenInputDevice(&ghMouseDevice, &pMouDevice, L"\\Device\\PointerClass0" );
186  if (NT_SUCCESS(Status))
187  {
188  ++cMaxWaitObjects;
189  TRACE("Mouse connected!\n");
190  }
191  }
192  if (!ghKeyboardDevice)
193  {
194  /* Check if keyboard device already exists */
195  Status = OpenInputDevice(&ghKeyboardDevice, &pKbdDevice, L"\\Device\\KeyboardClass0");
196  if (NT_SUCCESS(Status))
197  {
198  ++cMaxWaitObjects;
199  TRACE("Keyboard connected!\n");
200  // Get and load keyboard attributes.
203  // Register the Window hotkey.
205  // Register the Window Snap hotkey.
210  // Register the debug hotkeys.
212  UserLeave();
213  }
214  }
215 
216  /* Reset WaitHandles array */
217  cWaitObjects = 0;
218  WaitObjects[cWaitObjects++] = ShutdownEvent;
219  WaitObjects[cWaitObjects++] = MasterTimer;
220 
221  if (ghMouseDevice)
222  {
223  /* Try to read from mouse if previous reading is not pending */
224  if (MouStatus != STATUS_PENDING)
225  {
226  MouStatus = ZwReadFile(ghMouseDevice,
227  NULL,
228  NULL,
229  NULL,
230  &MouIosb,
231  &MouseInput,
232  sizeof(MOUSE_INPUT_DATA),
233  &ByteOffset,
234  NULL);
235  }
236 
237  if (MouStatus == STATUS_PENDING)
238  WaitObjects[cWaitObjects++] = &pMouDevice->Event;
239  }
240 
241  if (ghKeyboardDevice)
242  {
243  /* Try to read from keyboard if previous reading is not pending */
244  if (KbdStatus != STATUS_PENDING)
245  {
246  KbdStatus = ZwReadFile(ghKeyboardDevice,
247  NULL,
248  NULL,
249  NULL,
250  &KbdIosb,
251  &KeyInput,
252  sizeof(KEYBOARD_INPUT_DATA),
253  &ByteOffset,
254  NULL);
255 
256  }
257  if (KbdStatus == STATUS_PENDING)
258  WaitObjects[cWaitObjects++] = &pKbdDevice->Event;
259  }
260 
261  /* If all objects are pending, wait for them */
262  if (cWaitObjects == cMaxWaitObjects)
263  {
264  Status = KeWaitForMultipleObjects(cWaitObjects,
265  WaitObjects,
266  WaitAny,
267  UserRequest,
268  KernelMode,
269  TRUE,
270  NULL,//&WaitTimeout,
272 
273  if ((Status >= STATUS_WAIT_0) &&
274  (Status < (STATUS_WAIT_0 + (LONG)cWaitObjects)))
275  {
276  /* Some device has finished reading */
277  pSignaledObject = WaitObjects[Status - STATUS_WAIT_0];
278 
279  /* Check if it is mouse or keyboard and update status */
280  if ((MouStatus == STATUS_PENDING) &&
281  (pSignaledObject == &pMouDevice->Event))
282  {
283  MouStatus = MouIosb.Status;
284  }
285  else if ((KbdStatus == STATUS_PENDING) &&
286  (pSignaledObject == &pKbdDevice->Event))
287  {
288  KbdStatus = KbdIosb.Status;
289  }
290  else if (pSignaledObject == MasterTimer)
291  {
292  ProcessTimers();
293  }
294  else if (pSignaledObject == ShutdownEvent)
295  {
296  break;
297  }
298  else ASSERT(FALSE);
299  }
300  }
301 
302  /* Have we successed reading from mouse? */
303  if (NT_SUCCESS(MouStatus) && MouStatus != STATUS_PENDING)
304  {
305  TRACE("MouseEvent\n");
306 
307  /* Set LastInputTick */
309 
310  /* Process data */
312  UserProcessMouseInput(&MouseInput);
313  UserLeave();
314  }
315  else if (MouStatus != STATUS_PENDING)
316  ERR("Failed to read from mouse: %x.\n", MouStatus);
317 
318  /* Have we successed reading from keyboard? */
319  if (NT_SUCCESS(KbdStatus) && KbdStatus != STATUS_PENDING)
320  {
321  TRACE("KeyboardEvent: %s %04x\n",
322  (KeyInput.Flags & KEY_BREAK) ? "up" : "down",
323  KeyInput.MakeCode);
324 
325  /* Set LastInputTick */
327 
328  /* Process data */
330  UserProcessKeyboardInput(&KeyInput);
331  UserLeave();
332  }
333  else if (KbdStatus != STATUS_PENDING)
334  ERR("Failed to read from keyboard: %x.\n", KbdStatus);
335  }
336 
337  if (ghMouseDevice)
338  {
339  (void)ZwCancelIoFile(ghMouseDevice, &MouIosb);
341  ObDereferenceObject(pMouDevice);
343  }
344 
345  if (ghKeyboardDevice)
346  {
349  ObDereferenceObject(pKbdDevice);
351  }
352 
353  ERR("Raw Input Thread Exit!\n");
354 }
#define IDHK_SNAP_DOWN
Definition: hotkey.h:23
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
NTSYSAPI NTSTATUS NTAPI ZwCancelIoFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)
#define TRUE
Definition: types.h:120
static NTSTATUS NTAPI OpenInputDevice(PHANDLE pHandle, PFILE_OBJECT *ppObject, CONST WCHAR *pszDeviceName)
Definition: input.c:92
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
PKTIMER MasterTimer
Definition: input.c:16
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
static HANDLE ghMouseDevice
Definition: input.c:22
VOID FASTCALL StartTheTimers(VOID)
Definition: timer.c:368
FLONG TIF_flags
Definition: win32.h:94
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
#define PWND_BOTTOM
Definition: ntuser.h:731
LONG NTSTATUS
Definition: precomp.h:26
#define VK_LEFT
Definition: winuser.h:2178
#define LOW_REALTIME_PRIORITY
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define VK_DOWN
Definition: winuser.h:2181
VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice)
Definition: keyboard.c:161
#define KEY_BREAK
Definition: ntddkbd.h:71
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2739
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:242
HANDLE ghKeyboardDevice
Definition: input.c:19
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:783
VOID FASTCALL StartDebugHotKeys(VOID)
Definition: hotkey.c:44
NTSTATUS NTAPI PoRequestShutdownEvent(OUT PVOID *Event)
Definition: poshtdwn.c:396
#define STATUS_WAIT_0
Definition: ntstatus.h:223
#define VK_UP
Definition: winuser.h:2179
#define IDHK_SNAP_RIGHT
Definition: hotkey.h:21
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static HANDLE ShutdownEvent
Definition: dcomlaunch.c:28
PTHREADINFO ptiRawInput
Definition: input.c:15
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
int64_t LONGLONG
Definition: typedefs.h:66
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IDHK_SNAP_UP
Definition: hotkey.h:22
VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA pMouseInputData)
Definition: mouse.c:40
* PFILE_OBJECT
Definition: iotypes.h:1954
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1346
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
BOOL FASTCALL UserRegisterHotKey(PWND pWnd, int id, UINT fsModifiers, UINT vk)
Definition: hotkey.c:431
Status
Definition: gdiplustypes.h:24
#define VK_RIGHT
Definition: winuser.h:2180
#define ERR(fmt,...)
Definition: debug.h:109
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
VOID FASTCALL ProcessTimers(VOID)
Definition: timer.c:449
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1327
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define IDHK_SNAP_LEFT
Definition: hotkey.h:20
VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKeyInput)
Definition: keyboard.c:1053
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ WAIT_TYPE _In_opt_ PLARGE_INTEGER _In_opt_ PKWAIT_BLOCK WaitBlockArray
Definition: fsrtlfuncs.h:1151
#define MOD_WIN
Definition: winuser.h:2598
#define IDHK_WINKEY
Definition: hotkey.h:16
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716
static DWORD FASTCALL IntLastInputTick(BOOL bUpdate)
Definition: input.c:32
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by UserSystemThreadProc().

◆ UserAttachThreadInput()

NTSTATUS FASTCALL UserAttachThreadInput ( PTHREADINFO  ,
PTHREADINFO  ,
BOOL   
)

Definition at line 483 of file input.c.

484 {
485  MSG msg;
486  PATTACHINFO pai;
487  PCURICON_OBJECT CurIcon;
488 
489  /* Can not be the same thread. */
490  if (ptiFrom == ptiTo) return STATUS_INVALID_PARAMETER;
491 
492  /* Do not attach to system threads or between different desktops. */
493  if (ptiFrom->TIF_flags & TIF_DONTATTACHQUEUE ||
494  ptiTo->TIF_flags & TIF_DONTATTACHQUEUE ||
495  ptiFrom->rpdesk != ptiTo->rpdesk)
496  return STATUS_ACCESS_DENIED;
497 
498  /* MSDN Note:
499  Keyboard and mouse events received by both threads are processed by the thread specified by the idAttachTo.
500  */
501 
502  /* If Attach set, allocate and link. */
503  if (fAttach)
504  {
506  if (!pai) return STATUS_NO_MEMORY;
507 
508  pai->paiNext = gpai;
509  pai->pti1 = ptiFrom;
510  pai->pti2 = ptiTo;
511  gpai = pai;
512  paiCount++;
513  ERR("Attach Allocated! ptiFrom 0x%p ptiTo 0x%p paiCount %d\n",ptiFrom,ptiTo,paiCount);
514 
515  if (ptiTo->MessageQueue != ptiFrom->MessageQueue)
516  {
517 
518  ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel;
519 
520  if (ptiFrom->MessageQueue == gpqForeground)
521  {
522  ERR("ptiFrom is Foreground\n");
523  ptiTo->MessageQueue->spwndActive = ptiFrom->MessageQueue->spwndActive;
524  ptiTo->MessageQueue->spwndFocus = ptiFrom->MessageQueue->spwndFocus;
525  ptiTo->MessageQueue->spwndCapture = ptiFrom->MessageQueue->spwndCapture;
526  ptiTo->MessageQueue->QF_flags ^= ((ptiTo->MessageQueue->QF_flags ^ ptiFrom->MessageQueue->QF_flags) & QF_CAPTURELOCKED);
527  RtlCopyMemory(&ptiTo->MessageQueue->CaretInfo,
528  &ptiFrom->MessageQueue->CaretInfo,
529  sizeof(ptiTo->MessageQueue->CaretInfo));
531  IntSetFocusMessageQueue(ptiTo->MessageQueue);
532  gptiForeground = ptiTo;
533  }
534  else
535  {
536  ERR("ptiFrom NOT Foreground\n");
537  if ( ptiTo->MessageQueue->spwndActive == 0 )
538  ptiTo->MessageQueue->spwndActive = ptiFrom->MessageQueue->spwndActive;
539  if ( ptiTo->MessageQueue->spwndFocus == 0 )
540  ptiTo->MessageQueue->spwndFocus = ptiFrom->MessageQueue->spwndFocus;
541  }
542 
543  CurIcon = ptiFrom->MessageQueue->CursorObject;
544 
545  MsqDestroyMessageQueue(ptiFrom);
546 
547  if (CurIcon)
548  {
549  // Could be global. Keep it above the water line!
550  UserReferenceObject(CurIcon);
551  }
552 
553  if (CurIcon && UserObjectInDestroy(UserHMGetHandle(CurIcon)))
554  {
555  UserDereferenceObject(CurIcon);
556  CurIcon = NULL;
557  }
558 
559  ptiFrom->MessageQueue = ptiTo->MessageQueue;
560 
561  // Pass cursor From if To is null. Pass test_SetCursor parent_id == current pti ID.
562  if (CurIcon && ptiTo->MessageQueue->CursorObject == NULL)
563  {
564  ERR("ptiTo receiving ptiFrom Cursor\n");
565  ptiTo->MessageQueue->CursorObject = CurIcon;
566  }
567 
568  ptiFrom->MessageQueue->cThreads++;
569  ERR("ptiTo S Share count %u\n", ptiFrom->MessageQueue->cThreads);
570 
571  IntReferenceMessageQueue(ptiTo->MessageQueue);
572  }
573  else
574  {
575  ERR("Attach Threads are already associated!\n");
576  }
577  }
578  else /* If clear, unlink and free it. */
579  {
580  BOOL Hit = FALSE;
581  PATTACHINFO *ppai;
582 
583  if (!gpai) return STATUS_INVALID_PARAMETER;
584 
585  /* Search list and free if found or return false. */
586  ppai = &gpai;
587  while (*ppai != NULL)
588  {
589  if ( (*ppai)->pti2 == ptiTo && (*ppai)->pti1 == ptiFrom )
590  {
591  pai = *ppai;
592  /* Remove it from the list */
593  *ppai = (*ppai)->paiNext;
595  paiCount--;
596  Hit = TRUE;
597  break;
598  }
599  ppai = &((*ppai)->paiNext);
600  }
601 
602  if (!Hit) return STATUS_INVALID_PARAMETER;
603 
604  ERR("Attach Free! ptiFrom 0x%p ptiTo 0x%p paiCount %d\n",ptiFrom,ptiTo,paiCount);
605 
606  if (ptiTo->MessageQueue == ptiFrom->MessageQueue)
607  {
608  PWND spwndActive = ptiTo->MessageQueue->spwndActive;
609  PWND spwndFocus = ptiTo->MessageQueue->spwndFocus;
610 
611  if (gptiForeground == ptiFrom)
612  {
613  ERR("ptiTo is now pti FG.\n");
614  // MessageQueue foreground is set so switch threads.
615  gptiForeground = ptiTo;
616  }
617  ptiTo->MessageQueue->cThreads--;
618  ERR("ptiTo E Share count %u\n", ptiTo->MessageQueue->cThreads);
619  ASSERT(ptiTo->MessageQueue->cThreads >= 1);
620 
621  IntDereferenceMessageQueue(ptiTo->MessageQueue);
622 
623  ptiFrom->MessageQueue = MsqCreateMessageQueue(ptiFrom);
624 
625  if (spwndActive)
626  {
627  if (spwndActive->head.pti == ptiFrom)
628  {
629  ptiFrom->MessageQueue->spwndActive = spwndActive;
630  ptiTo->MessageQueue->spwndActive = 0;
631  }
632  }
633  if (spwndFocus)
634  {
635  if (spwndFocus->head.pti == ptiFrom)
636  {
637  ptiFrom->MessageQueue->spwndFocus = spwndFocus;
638  ptiTo->MessageQueue->spwndFocus = 0;
639  }
640  }
641  ptiTo->MessageQueue->iCursorLevel -= ptiFrom->iCursorLevel;
642  }
643  else
644  {
645  ERR("Detaching Threads are not associated!\n");
646  }
647  }
648  /* Note that key state, which can be ascertained by calls to the GetKeyState
649  or GetKeyboardState function, is reset after a call to AttachThreadInput.
650  ATM which one?
651  */
652  RtlCopyMemory(ptiTo->MessageQueue->afKeyState, gafAsyncKeyState, sizeof(gafAsyncKeyState));
653 
654  ptiTo->MessageQueue->msgDblClk.message = 0;
655 
656  /* Generate mouse move message */
657  msg.message = WM_MOUSEMOVE;
658  msg.wParam = UserGetMouseButtonsState();
659  msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
660  msg.pt = gpsi->ptCursor;
662 
663  return STATUS_SUCCESS;
664 }
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:12
PTHREADINFO pti1
Definition: input.h:44
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:582
PATTACHINFO gpai
Definition: input.c:17
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:246
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
PSERVERINFO gpsi
Definition: main.c:27
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
#define IntReferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:217
struct _ATTACHINFO * paiNext
Definition: input.h:43
PTHREADINFO gptiForeground
Definition: focus.c:14
unsigned int BOOL
Definition: ntddk_ex.h:94
#define QF_CAPTURELOCKED
Definition: msgqueue.h:111
PTHREADINFO pti2
Definition: input.h:45
THRDESKHEAD head
Definition: ntuser.h:659
#define USERTAG_ATTACHINFO
Definition: tags.h:196
INT paiCount
Definition: input.c:18
smooth NULL
Definition: ftsmooth.c:416
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:669
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define IntDereferenceMessageQueue(MsgQueue)
Definition: msgqueue.h:220
VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti)
Definition: msgqueue.c:2457
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2430
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:109
Definition: ntuser.h:657
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
VOID FASTCALL IntSetFocusMessageQueue(PUSER_MESSAGE_QUEUE NewQueue)
Definition: desktop.c:1283
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define msg(x)
Definition: auth_time.c:54
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2725
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697

Referenced by co_IntSetParent(), co_UserCreateWindowEx(), co_UserDestroyWindow(), IntCreateWindow(), IntProcessOwnerSwap(), IsRemoveAttachThread(), and NtUserAttachThreadInput().

◆ UserGetMouseButtonsState()

WORD FASTCALL UserGetMouseButtonsState ( VOID  )

Definition at line 22 of file mouse.c.

23 {
24  WORD wRet = 0;
25 
27 
30 
31  return wRet;
32 }
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define MK_SHIFT
Definition: winuser.h:2323
#define VK_SHIFT
Definition: winuser.h:2156
unsigned short WORD
Definition: ntddk_ex.h:93
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
#define MK_CONTROL
Definition: winuser.h:2324
#define VK_CONTROL
Definition: winuser.h:2157
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98

Referenced by co_UserDestroyWindow(), co_WinPosSetWindowPos(), IntDeactivateWindow(), UserAttachThreadInput(), UserSendMouseInput(), and UserSetCursorPos().

◆ UserHklToKbl()

PKL NTAPI UserHklToKbl ( HKL  hKl)

Definition at line 370 of file kbdlayout.c.

371 {
372  PKL pKl = gspklBaseLayout;
373 
374  if (!gspklBaseLayout)
375  return NULL;
376 
377  do
378  {
379  if (pKl->hkl == hKl)
380  return pKl;
381 
382  pKl = pKl->pklNext;
383  } while (pKl != gspklBaseLayout);
384 
385  return NULL;
386 }
PKL gspklBaseLayout
Definition: kbdlayout.c:20
smooth NULL
Definition: ftsmooth.c:416
Definition: input.h:26
HKL hkl
Definition: input.h:32
struct tagKL * pklNext
Definition: input.h:29

Referenced by NtUserActivateKeyboardLayout(), NtUserLoadKeyboardLayoutEx(), NtUserMapVirtualKeyEx(), NtUserToUnicodeEx(), NtUserUnloadKeyboardLayout(), NtUserVkKeyScanEx(), and UserSetDefaultInputLang().

◆ UserInitKeyboard()

VOID NTAPI UserInitKeyboard ( HANDLE  hKeyboardDevice)

Definition at line 161 of file keyboard.c.

162 {
164  IO_STATUS_BLOCK Block;
165 
167 
168  Status = ZwDeviceIoControlFile(hKeyboardDevice,
169  NULL,
170  NULL,
171  NULL,
172  &Block,
174  NULL, 0,
175  &gIndicators,
176  sizeof(gIndicators));
177 
178  if (!NT_SUCCESS(Status))
179  {
180  WARN("NtDeviceIoControlFile() failed, ignored\n");
181  gIndicators.LedFlags = 0;
182  gIndicators.UnitId = 0;
183  }
184 
191 
192  // FIXME: Need device driver to work! HID support more than one!!!!
193  Status = ZwDeviceIoControlFile(hKeyboardDevice,
194  NULL,
195  NULL,
196  NULL,
197  &Block,
199  NULL, 0,
200  &gKeyboardInfo, sizeof(gKeyboardInfo));
201 
202  if (!NT_SUCCESS(Status))
203  {
204  ERR("NtDeviceIoControlFile() failed, ignored\n");
205  }
206  TRACE("Keyboard type %u, subtype %u and number of func keys %u\n",
210 }
NTSYSAPI NTSTATUS NTAPI ZwDeviceIoControlFile(IN HANDLE DeviceHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, IN PVOID UserApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, OUT PVOID OutputBuffer, IN ULONG OutputBufferSize)
UCHAR Type
Definition: ntddkbd.h:101
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
static KEYBOARD_INDICATOR_PARAMETERS gIndicators
Definition: keyboard.c:16
#define KEYBOARD_CAPS_LOCK_ON
Definition: ntddkbd.h:81
smooth NULL
Definition: ftsmooth.c:416
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans
Definition: keyboard.c:15
#define IOCTL_KEYBOARD_QUERY_INDICATORS
Definition: ntddkbd.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
UCHAR Subtype
Definition: ntddkbd.h:102
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
#define KEYBOARD_SCROLL_LOCK_ON
Definition: ntddkbd.h:83
#define VK_CAPITAL
Definition: winuser.h:2160
#define IOCTL_KEYBOARD_QUERY_ATTRIBUTES
Definition: ntddkbd.h:32
#define KEYBOARD_NUM_LOCK_ON
Definition: ntddkbd.h:82
NTSTATUS APIENTRY IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice, PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans)
Definition: keyboard.c:50
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17
#define SET_KEY_LOCKED(ks, vk, down)
Definition: input.h:103

Referenced by RawInputThreadMain().

◆ UserProcessKeyboardInput()

VOID NTAPI UserProcessKeyboardInput ( PKEYBOARD_INPUT_DATA  pKeyInput)

Definition at line 1053 of file keyboard.c.

1055 {
1056  WORD wScanCode, wVk;
1057  PKL pKl = NULL;
1058  PKBDTABLES pKbdTbl;
1059  PUSER_MESSAGE_QUEUE pFocusQueue;
1060 
1061  /* Calculate scan code with prefix */
1062  wScanCode = pKbdInputData->MakeCode & 0x7F;
1063  if (pKbdInputData->Flags & KEY_E0)
1064  wScanCode |= 0xE000;
1065  if (pKbdInputData->Flags & KEY_E1)
1066  wScanCode |= 0xE100;
1067 
1068  /* Find the target thread whose locale is in effect */
1069  pFocusQueue = IntGetFocusMessageQueue();
1070 
1071  if (pFocusQueue && pFocusQueue->ptiKeyboard)
1072  {
1073  pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
1074  }
1075 
1076  if (!pKl)
1077  pKl = W32kGetDefaultKeyLayout();
1078  if (!pKl)
1079  return;
1080 
1081  pKbdTbl = pKl->spkf->pKbdTbl;
1082 
1083  /* Convert scan code to virtual key.
1084  Note: We could call UserSendKeyboardInput using scan code,
1085  but it wouldn't interpret E1 key(s) properly */
1086  wVk = IntVscToVk(wScanCode, pKbdTbl);
1087  TRACE("UserProcessKeyboardInput: %x (break: %u) -> %x\n",
1088  wScanCode, (pKbdInputData->Flags & KEY_BREAK) ? 1u : 0, wVk);
1089 
1090  if (wVk)
1091  {
1092  KEYBDINPUT KbdInput;
1093 
1094  /* Support numlock */
1096  {
1097  wVk = IntTranslateNumpadKey(wVk & 0xFF);
1098  }
1099 
1100  /* Send keyboard input */
1101  KbdInput.wVk = wVk & 0xFF;
1102  KbdInput.wScan = wScanCode & 0x7F;
1103  KbdInput.dwFlags = 0;
1104  if (pKbdInputData->Flags & KEY_BREAK)
1105  KbdInput.dwFlags |= KEYEVENTF_KEYUP;
1106 
1107  if (wVk & KBDEXT)
1108  KbdInput.dwFlags |= KEYEVENTF_EXTENDEDKEY;
1109  //
1110  // Based on wine input:test_Input_blackbox this is okay. It seems the
1111  // bit did not get set and more research is needed. Now the right
1112  // shift works.
1113  //
1114  if (wVk == VK_RSHIFT)
1115  KbdInput.dwFlags |= KEYEVENTF_EXTENDEDKEY;
1116 
1117  KbdInput.time = 0;
1118  KbdInput.dwExtraInfo = pKbdInputData->ExtraInformation;
1119  UserSendKeyboardInput(&KbdInput, FALSE);
1120 
1121  /* E1 keys don't have break code */
1122  if (pKbdInputData->Flags & KEY_E1)
1123  {
1124  /* Send key up event */
1125  KbdInput.dwFlags |= KEYEVENTF_KEYUP;
1126  UserSendKeyboardInput(&KbdInput, FALSE);
1127  }
1128  }
1129 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
PTHREADINFO ptiKeyboard
Definition: msgqueue.h:56
static WORD FASTCALL IntVscToVk(WORD wScanCode, PKBDTABLES pKbdTbl)
Definition: keyboard.c:562
DWORD time
Definition: winable.h:50
#define KEY_BREAK
Definition: ntddkbd.h:71
BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
Definition: keyboard.c:973
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1271
#define KBDNUMPAD
Definition: kbd.h:11
smooth NULL
Definition: ftsmooth.c:416
Definition: input.h:26
#define IS_KEY_LOCKED(ks, vk)
Definition: input.h:99
DWORD dwFlags
Definition: winable.h:49
#define TRACE(s)
Definition: solgame.cpp:4
Definition: kbd.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
static WORD IntTranslateNumpadKey(WORD wVk)
Definition: keyboard.c:272
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
#define VK_RSHIFT
Definition: winuser.h:2237
struct tagKL * KeyboardLayout
Definition: win32.h:89
#define KEY_E1
Definition: ntddkbd.h:73
#define KBDEXT
Definition: kbd.h:8
WORD wScan
Definition: winable.h:48
#define VK_NUMLOCK
Definition: winuser.h:2233
#define KEY_E0
Definition: ntddkbd.h:72
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:343
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
PKBDFILE spkf
Definition: input.h:33
ULONG_PTR dwExtraInfo
Definition: winable.h:51
WORD wVk
Definition: winable.h:47

Referenced by RawInputThreadMain().

◆ UserProcessMouseInput()

VOID NTAPI UserProcessMouseInput ( PMOUSE_INPUT_DATA  pMouseInputData)

Definition at line 40 of file mouse.c.

41 {
42  MOUSEINPUT mi;
43 
44  /* Convert MOUSE_INPUT_DATA to MOUSEINPUT. First init all fields. */
45  mi.dx = mid->LastX;
46  mi.dy = mid->LastY;
47  mi.mouseData = 0;
48  mi.dwFlags = 0;
49  mi.time = 0;
50  mi.dwExtraInfo = mid->ExtraInformation;
51 
52  /* Mouse position */
53  if (mi.dx != 0 || mi.dy != 0)
55 
56  /* Flags for absolute move */
57  if (mid->Flags & MOUSE_MOVE_ABSOLUTE)
59  if (mid->Flags & MOUSE_VIRTUAL_DESKTOP)
61 
62  /* Left button */
63  if (mid->ButtonFlags & MOUSE_LEFT_BUTTON_DOWN)
65  if (mid->ButtonFlags & MOUSE_LEFT_BUTTON_UP)
67 
68  /* Middle button */
69  if (mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_DOWN)
71  if (mid->ButtonFlags & MOUSE_MIDDLE_BUTTON_UP)
73 
74  /* Right button */
75  if (mid->ButtonFlags & MOUSE_RIGHT_BUTTON_DOWN)
77  if (mid->ButtonFlags & MOUSE_RIGHT_BUTTON_UP)
79 
80  /* Note: Next buttons use mouseData field so they cannot be sent in one call */
81 
82  /* Button 4 */
83  if (mid->ButtonFlags & MOUSE_BUTTON_4_DOWN)
84  {
86  mi.mouseData |= XBUTTON1;
87  }
88  if (mid->ButtonFlags & MOUSE_BUTTON_4_UP)
89  {
91  mi.mouseData |= XBUTTON1;
92  }
93 
94  /* If mouseData is used by button 4, send input and clear mi */
96  {
98  RtlZeroMemory(&mi, sizeof(mi));
99  }
100 
101  /* Button 5 */
102  if (mid->ButtonFlags & MOUSE_BUTTON_5_DOWN)
103  {
104  mi.mouseData |= XBUTTON2;
106  }
107  if (mid->ButtonFlags & MOUSE_BUTTON_5_UP)
108  {
109  mi.mouseData |= XBUTTON2;
111  }
112 
113  /* If mouseData is used by button 5, send input and clear mi */
115  {
117  RtlZeroMemory(&mi, sizeof(mi));
118  }
119 
120  /* Mouse wheel */
121  if (mid->ButtonFlags & MOUSE_WHEEL)
122  {
123  mi.mouseData = mid->ButtonData;
125  }
126 
127  /* If something has changed, send input to user */
128  if (mi.dwFlags)
130 }
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1180
#define MOUSE_MIDDLE_BUTTON_DOWN
Definition: ntddmou.h:50
#define MOUSE_LEFT_BUTTON_DOWN
Definition: ntddmou.h:46
#define MOUSEEVENTF_WHEEL
Definition: winuser.h:1178
#define MOUSEEVENTF_XDOWN
Definition: winuser.h:1176
#define MOUSE_WHEEL
Definition: ntddmou.h:56
static MONITORINFO mi
Definition: win.c:7331
#define MOUSEEVENTF_MIDDLEDOWN
Definition: winuser.h:1174
#define MOUSEEVENTF_MIDDLEUP
Definition: winuser.h:1175
BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pmi, BOOL bInjected)
Definition: mouse.c:168
#define MOUSEEVENTF_VIRTUALDESK
Definition: winuser.h:1179
#define MOUSE_BUTTON_4_DOWN
Definition: ntddmou.h:52
#define MOUSE_BUTTON_4_UP
Definition: ntddmou.h:53
#define MOUSE_BUTTON_5_UP
Definition: ntddmou.h:55
#define MOUSE_LEFT_BUTTON_UP
Definition: ntddmou.h:47
#define MOUSE_MIDDLE_BUTTON_UP
Definition: ntddmou.h:51
#define MOUSE_RIGHT_BUTTON_DOWN
Definition: ntddmou.h:48
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1171
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1173
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1169
#define MOUSEEVENTF_XUP
Definition: winuser.h:1177
DWORD dwFlags
Definition: winuser.h:3729
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MOUSE_RIGHT_BUTTON_UP
Definition: ntddmou.h:49
#define MOUSE_BUTTON_5_DOWN
Definition: ntddmou.h:54
#define MOUSE_MOVE_ABSOLUTE
Definition: ntddmou.h:68
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1172
#define MOUSE_VIRTUAL_DESKTOP
Definition: ntddmou.h:69

Referenced by RawInputThreadMain().

◆ UserSendKeyboardInput()

BOOL NTAPI UserSendKeyboardInput ( KEYBDINPUT pKbdInput,
BOOL  bInjected 
)

Definition at line 973 of file keyboard.c.

974 {
975  WORD wScanCode, wVk;
976  PKL pKl = NULL;
977  PKBDTABLES pKbdTbl;
978  PUSER_MESSAGE_QUEUE pFocusQueue;
979  LARGE_INTEGER LargeTickCount;
980  DWORD dwTime;
981  BOOL bExt = (pKbdInput->dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
982 
984 
985  /* Find the target thread whose locale is in effect */
986  pFocusQueue = IntGetFocusMessageQueue();
987 
988  if (pFocusQueue && pFocusQueue->ptiKeyboard)
989  {
990  pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
991  }
992 
993  if (!pKl)
994  pKl = W32kGetDefaultKeyLayout();
995  if (!pKl)
996  {
997  ERR("No keyboard layout!\n");
998  return FALSE;
999  }
1000 
1001  pKbdTbl = pKl->spkf->pKbdTbl;
1002 
1003  /* Note: wScan field is always used */
1004  wScanCode = pKbdInput->wScan;
1005 
1006  if (pKbdInput->dwFlags & KEYEVENTF_UNICODE)
1007  {
1008  /* Generate WM_KEYDOWN msg with wParam == VK_PACKET and
1009  high order word of lParam == pKbdInput->wScan */
1010  wVk = VK_PACKET;
1011  }
1012  else
1013  {
1014  wScanCode &= 0x7F;
1015  if (pKbdInput->dwFlags & KEYEVENTF_SCANCODE)
1016  {
1017  /* Don't ignore invalid scan codes */
1018  wVk = IntVscToVk(wScanCode | (bExt ? 0xE000 : 0), pKbdTbl);
1019  if (!wVk) /* use 0xFF if vsc is invalid */
1020  wVk = 0xFF;
1021  }
1022  else
1023  {
1024  wVk = pKbdInput->wVk & 0xFF;
1025  }
1026  }
1027 
1028  /* If time is given, use it */
1029  if (pKbdInput->time)
1030  dwTime = pKbdInput->time;
1031  else
1032  {
1033  KeQueryTickCount(&LargeTickCount);
1034  dwTime = MsqCalculateMessageTime(&LargeTickCount);
1035  }
1036 
1037  if (wVk == VK_RMENU && (pKbdTbl->fLocaleFlags & KLLF_ALTGR))
1038  {
1039  /* For AltGr keyboards RALT generates CTRL events */
1040  ProcessKeyEvent(VK_LCONTROL, 0, pKbdInput->dwFlags & KEYEVENTF_KEYUP, bInjected, dwTime, 0);
1041  }
1042 
1043  /* Finally process this key */
1044  return ProcessKeyEvent(wVk, wScanCode, pKbdInput->dwFlags, bInjected, dwTime, pKbdInput->dwExtraInfo);
1045 }
#define TRUE
Definition: types.h:120
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define VK_RMENU
Definition: winuser.h:2241
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
PTHREADINFO ptiKeyboard
Definition: msgqueue.h:56
static WORD FASTCALL IntVscToVk(WORD wScanCode, PKBDTABLES pKbdTbl)
Definition: keyboard.c:562
DWORD time
Definition: winable.h:50
DWORD fLocaleFlags
Definition: kbd.h:106
static __inline LONG MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount)
Definition: msgqueue.h:253
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1271
#define KLLF_ALTGR
Definition: kbd.h:91
unsigned int BOOL
Definition: ntddk_ex.h:94
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
smooth NULL
Definition: ftsmooth.c:416
Definition: input.h:26
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
DWORD dwTime
Definition: solitaire.cpp:25
DWORD dwFlags
Definition: winable.h:49
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
Definition: kbd.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
struct tagKL * KeyboardLayout
Definition: win32.h:89
#define ERR(fmt,...)
Definition: debug.h:109
WORD wScan
Definition: winable.h:48
BOOL NTAPI ProcessKeyEvent(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
Definition: keyboard.c:800
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:343
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
PKBDFILE spkf
Definition: input.h:33
ULONG_PTR dwExtraInfo
Definition: winable.h:51
#define VK_LCONTROL
Definition: winuser.h:2238
WORD wVk
Definition: winable.h:47

Referenced by NtUserSendInput(), and UserProcessKeyboardInput().

◆ UserSendMouseInput()

BOOL NTAPI UserSendMouseInput ( MOUSEINPUT pMouseInput,
BOOL  bInjected 
)

Definition at line 168 of file mouse.c.

169 {
170  POINT ptCursor;
171  PSYSTEM_CURSORINFO pCurInfo;
172  MSG Msg;
173  DWORD dwFlags;
174 
175  ASSERT(pmi);
176 
177  pCurInfo = IntGetSysCursorInfo();
178  ptCursor = gpsi->ptCursor;
179  dwFlags = IntFixMouseInputButtons(pmi->dwFlags);
180 
182 
183  if (pmi->dwFlags & MOUSEEVENTF_MOVE)
184  {
185  /* Mouse has changes position */
186  if (!(pmi->dwFlags & MOUSEEVENTF_ABSOLUTE))
187  {
188  /* Relative move */
189  ptCursor.x += pmi->dx;
190  ptCursor.y += pmi->dy;
191  }
192  else if (pmi->dwFlags & MOUSEEVENTF_VIRTUALDESK)
193  {
194  /* Absolute move in virtual screen units */
195  ptCursor.x = pmi->dx * UserGetSystemMetrics(SM_CXVIRTUALSCREEN) >> 16;
196  ptCursor.y = pmi->dy * UserGetSystemMetrics(SM_CYVIRTUALSCREEN) >> 16;
197  }
198  else
199  {
200  /* Absolute move in primary monitor units */
201  ptCursor.x = pmi->dx * UserGetSystemMetrics(SM_CXSCREEN) >> 16;
202  ptCursor.y = pmi->dy * UserGetSystemMetrics(SM_CYSCREEN) >> 16;
203  }
204  }
205 
206  /* Init message fields */
207  Msg.wParam = UserGetMouseButtonsState();
208  Msg.lParam = MAKELPARAM(ptCursor.x, ptCursor.y);
209  Msg.pt = ptCursor;
210  Msg.time = pmi->time;
211  if (!Msg.time)
212  {
213  LARGE_INTEGER LargeTickCount;
214  KeQueryTickCount(&LargeTickCount);
215  Msg.time = MsqCalculateMessageTime(&LargeTickCount);
216  }
217 
218  /* Do GetMouseMovePointsEx FIFO. */
222  gMouseHistoryOfMoves[gcMouseHistoryOfMoves].dwExtraInfo = pmi->dwExtraInfo;
224  gcMouseHistoryOfMoves = 0; // 0 - 63 is 64, FIFO forwards.
225 
226  /* Update cursor position */
228  {
229  UserSetCursorPos(ptCursor.x, ptCursor.y, bInjected, pmi->dwExtraInfo, TRUE);
230  }
231 
232  /* Left button */
234  {
236  Msg.message = WM_LBUTTONDOWN;
237  pCurInfo->ButtonsDown |= MK_LBUTTON;
238  Msg.wParam |= MK_LBUTTON;
239  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
240  }
241  else if (dwFlags & MOUSEEVENTF_LEFTUP)
242  {
244  Msg.message = WM_LBUTTONUP;
245  pCurInfo->ButtonsDown &= ~MK_LBUTTON;
246  Msg.wParam &= ~MK_LBUTTON;
247  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
248  }
249 
250  /* Middle button */
252  {
254  Msg.message = WM_MBUTTONDOWN;
255  pCurInfo->ButtonsDown |= MK_MBUTTON;
256  Msg.wParam |= MK_MBUTTON;
257  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
258  }
259  else if (dwFlags & MOUSEEVENTF_MIDDLEUP)
260  {
262  Msg.message = WM_MBUTTONUP;
263  pCurInfo->ButtonsDown &= ~MK_MBUTTON;
264  Msg.wParam &= ~MK_MBUTTON;
265  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
266  }
267 
268  /* Right button */
270  {
272  Msg.message = WM_RBUTTONDOWN;
273  pCurInfo->ButtonsDown |= MK_RBUTTON;
274  Msg.wParam |= MK_RBUTTON;
275  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
276  }
277  else if (dwFlags & MOUSEEVENTF_RIGHTUP)
278  {
280  Msg.message = WM_RBUTTONUP;
281  pCurInfo->ButtonsDown &= ~MK_RBUTTON;
282  Msg.wParam &= ~MK_RBUTTON;
283  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
284  }
285 
288  {
289  /* Fail because both types of events use the mouseData field */
290  WARN("Invalid flags!\n");
291  return FALSE;
292  }
293 
294  /* X-Button (4 or 5) */
296  {
297  Msg.message = WM_XBUTTONDOWN;
298  if (pmi->mouseData & XBUTTON1)
299  {
300  SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, TRUE);
301  pCurInfo->ButtonsDown |= MK_XBUTTON1;
302  Msg.wParam |= MAKEWPARAM(MK_XBUTTON1, XBUTTON1);
303  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
304  }
305  if (pmi->mouseData & XBUTTON2)
306  {
307  SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, TRUE);
308  pCurInfo->ButtonsDown |= MK_XBUTTON2;
309  Msg.wParam |= MAKEWPARAM(MK_XBUTTON2, XBUTTON2);
310  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
311  }
312  }
313  else if (dwFlags & MOUSEEVENTF_XUP)
314  {
315  Msg.message = WM_XBUTTONUP;
316  if(pmi->mouseData & XBUTTON1)
317  {
318  SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, FALSE);
319  pCurInfo->ButtonsDown &= ~MK_XBUTTON1;
320  Msg.wParam &= ~MK_XBUTTON1;
321  Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
322  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
323  }
324  if (pmi->mouseData & XBUTTON2)
325  {
326  SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, FALSE);
327  pCurInfo->ButtonsDown &= ~MK_XBUTTON2;
328  Msg.wParam &= ~MK_XBUTTON2;
329  Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
330  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
331  }
332  }
333 
334  /* Mouse wheel */
336  {
337  Msg.message = WM_MOUSEWHEEL;
338  Msg.wParam = MAKEWPARAM(pCurInfo->ButtonsDown, pmi->mouseData);
339  co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
340  }
341 
342  return TRUE;
343 }
#define WM_MBUTTONUP
Definition: winuser.h:1759
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
#define TRUE
Definition: types.h:120
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:582
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1180
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
#define MK_LBUTTON
Definition: winuser.h:2321
long x
Definition: polytest.cpp:48
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
#define VK_LBUTTON
Definition: winuser.h:2144
#define MOUSEEVENTF_WHEEL
Definition: winuser.h:1178
#define MOUSEEVENTF_XDOWN
Definition: winuser.h:1176
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define MK_MBUTTON
Definition: winuser.h:2325
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WARN(fmt,...)
Definition: debug.h:111
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
struct @1567 Msg[]
#define MOUSEEVENTF_MIDDLEDOWN
Definition: winuser.h:1174
#define MOUSEEVENTF_MIDDLEUP
Definition: winuser.h:1175
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
static __inline LONG MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount)
Definition: msgqueue.h:253
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
PSERVERINFO gpsi
Definition: main.c:27
#define MOUSEEVENTF_VIRTUALDESK
Definition: winuser.h:1179
#define SM_CXSCREEN
Definition: winuser.h:949
#define VK_RBUTTON
Definition: winuser.h:2145
#define SET_KEY_DOWN(ks, vk, down)
Definition: input.h:100
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
#define MK_RBUTTON
Definition: winuser.h:2322
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
#define SM_CYSCREEN
Definition: winuser.h:950
INT gcMouseHistoryOfMoves
Definition: mouse.c:14
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WM_RBUTTONUP
Definition: winuser.h:1756
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1171
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1173
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1169
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
#define MOUSEEVENTF_XUP
Definition: winuser.h:1177
DWORD IntFixMouseInputButtons(DWORD dwFlags)
Definition: mouse.c:138
MOUSEMOVEPOINT gMouseHistoryOfMoves[64]
Definition: mouse.c:13
#define VK_MBUTTON
Definition: winuser.h:2147
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1172

Referenced by co_UserSetCapture(), NtUserSendInput(), and UserProcessMouseInput().

◆ UserSetDefaultInputLang()

BOOL NTAPI UserSetDefaultInputLang ( HKL  hKl)

Definition at line 395 of file kbdlayout.c.

396 {
397  PKL pKl;
398 
399  pKl = UserHklToKbl(hKl);
400  if (!pKl)
401  return FALSE;
402 
403  gspklBaseLayout = pKl;
404  return TRUE;
405 }
#define TRUE
Definition: types.h:120
PKL gspklBaseLayout
Definition: kbdlayout.c:20
Definition: input.h:26
PKL NTAPI UserHklToKbl(HKL hKl)
Definition: kbdlayout.c:370

Referenced by SpiGetSet().

◆ W32kGetDefaultKeyLayout()

PKL W32kGetDefaultKeyLayout ( VOID  )

Definition at line 343 of file kbdlayout.c.

344 {
345  PKL pKl = gspklBaseLayout;
346 
347  if (!pKl)
348  return NULL;
349 
350  /* Return not unloaded layout */
351  do
352  {
353  if (!(pKl->dwKL_Flags & KLF_UNLOAD))
354  return pKl;
355 
356  pKl = pKl->pklPrev; /* Confirmed on Win2k */
357  } while(pKl != gspklBaseLayout);
358 
359  /* We have not found proper KL */
360  return NULL;
361 }
struct tagKL * pklPrev
Definition: input.h:30
#define KLF_UNLOAD
Definition: input.h:51
PKL gspklBaseLayout
Definition: kbdlayout.c:20
smooth NULL
Definition: ftsmooth.c:416
Definition: input.h:26
DWORD dwKL_Flags
Definition: input.h:31

Referenced by InitThreadCallback(), IntTranslateKbdMessage(), UserProcessKeyboardInput(), and UserSendKeyboardInput().

Variable Documentation

◆ gafAsyncKeyState

◆ gdwLanguageToggleKey

DWORD gdwLanguageToggleKey

◆ ghKeyboardDevice

HANDLE ghKeyboardDevice

Definition at line 19 of file input.c.

Referenced by ProcessKeyEvent(), and RawInputThreadMain().

◆ gKeyboardInfo

KEYBOARD_ATTRIBUTES gKeyboardInfo

◆ gLanguageToggleKeyState

int gLanguageToggleKeyState

Definition at line 18 of file keyboard.c.

Referenced by co_IntProcessKeyboardMessage().

◆ gpai

Definition at line 17 of file input.c.

Referenced by IsRemoveAttachThread(), and UserAttachThreadInput().

◆ gspklBaseLayout

◆ gSystemCPCharSet

UINT gSystemCPCharSet

Definition at line 23 of file kbdlayout.c.

Referenced by UserLoadKbdLayout().

◆ gSystemFS

DWORD gSystemFS

Definition at line 22 of file kbdlayout.c.

Referenced by co_IntProcessKeyboardMessage(), and UserLoadKbdLayout().

◆ ptiRawInput

PTHREADINFO ptiRawInput

Definition at line 15 of file input.c.

Referenced by IntSetTimer(), and RawInputThreadMain().