ReactOS 0.4.16-dev-297-gc569aee
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 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

 CODE_SEG ("INIT") 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)
 
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)
 
VOID FASTCALL IntFreeImeHotKeys (VOID)
 

Variables

PATTACHINFO gpai
 
INT gLanguageToggleKeyState
 
DWORD gdwLanguageToggleKey
 
INT gLayoutToggleKeyState
 
DWORD gdwLayoutToggleKey
 
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.

◆ KS_DOWN_BIT

#define KS_DOWN_BIT   0x80

Definition at line 51 of file input.h.

◆ KS_LOCK_BIT

#define KS_LOCK_BIT   0x01

Definition at line 52 of file input.h.

◆ LP_DO_NOT_CARE_BIT

#define LP_DO_NOT_CARE_BIT   (1<<25)

Definition at line 56 of file input.h.

◆ SC_KEY_UP

#define SC_KEY_UP   0x8000

Definition at line 54 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
WORD vk
Definition: input.c:77
#define GET_KS_DOWN_BIT(vk)
Definition: input.h:96
#define GET_KS_BYTE(vk)
Definition: input.h:95

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 GET_KS_LOCK_BIT(vk)
Definition: input.h:97

Definition at line 103 of file input.h.

◆ ThreadHasInputAccess

#define ThreadHasInputAccess (   W32Thread)    (TRUE)

Definition at line 65 of file input.h.

Typedef Documentation

◆ ATTACHINFO

◆ KBDFILE

◆ KBDNLSLAYER

◆ KL

typedef struct tagKL KL

◆ PATTACHINFO

◆ PKBDFILE

◆ PKBDNLSLAYER

◆ PKL

typedef struct tagKL * PKL

Function Documentation

◆ CODE_SEG()

CODE_SEG ( "INIT"  )

Definition at line 1810 of file Interface.c.

1817{
1818 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\FileSystem\\Filters\\"DRIVER_NAME);
1819 PDEVICE_OBJECT RawDeviceObject;
1821 PFILE_OBJECT RawFileObject;
1823 UNICODE_STRING SymLink;
1824
1826
1829
1830 /* Save the registry key for this driver */
1834 RegistryPath->MaximumLength,
1838
1839 /* Do some initialization */
1841
1842 /* Create the main filter manager device object */
1844 0,
1845 &DeviceName,
1848 FALSE,
1849 &DeviceObject);
1850 if (!NT_SUCCESS(Status))
1851 {
1852 DPRINT1("fltmgr IoCreateDevice failed. Status = %X\n", Status);
1853 goto Cleanup;
1854 }
1855
1856 /* Store a global reference so we can access from callbacks */
1858
1859 /* Generate the symbolic link name */
1860 RtlInitUnicodeString(&SymLink, L"\\??\\"DRIVER_NAME);
1862 if (!NT_SUCCESS(Status)) goto Cleanup;
1863
1864 /* Create the callbacks for the dispatch table, FastIo and FS callbacks */
1866 if (!NT_SUCCESS(Status)) goto Cleanup;
1867
1868 /* Initialize the comms objects */
1870 if (!NT_SUCCESS(Status)) goto Cleanup;
1871
1872 /* Register for notifications when a new file system is loaded. This also enumerates any existing file systems */
1874 FLT_ASSERT(Status != STATUS_DEVICE_ALREADY_ATTACHED); // Windows checks for this, I'm not sure how it can happen. Needs investigation??
1875 if (!NT_SUCCESS(Status)) goto Cleanup;
1876
1879
1880 /* IoRegisterFsRegistrationChange isn't notified about the raw file systems, so we attach to them manually */
1881 RtlInitUnicodeString(&ObjectName, L"\\Device\\RawDisk");
1884 &RawFileObject,
1885 &RawDeviceObject);
1886 if (NT_SUCCESS(Status))
1887 {
1888 FltpFsNotification(RawDeviceObject, TRUE);
1889 ObDereferenceObject(RawFileObject);
1890 }
1891
1892 RtlInitUnicodeString(&ObjectName, L"\\Device\\RawCdRom");
1895 &RawFileObject,
1896 &RawDeviceObject);
1897 if (NT_SUCCESS(Status))
1898 {
1899 FltpFsNotification(RawDeviceObject, TRUE);
1900 ObDereferenceObject(RawFileObject);
1901 }
1902
1903 /* We're done, clear the initializing flag */
1906
1907Cleanup:
1908
1909 if (!NT_SUCCESS(Status))
1910 {
1912 {
1913 DriverObject->FastIoDispatch = NULL;
1915 }
1916
1917 IoDeleteSymbolicLink(&SymLink);
1918
1919 if (DeviceObject)
1921
1924 }
1925
1926 return Status;
1927}
LIST_ENTRY FilterList
Definition: Filter.c:24
DRIVER_FS_NOTIFICATION FltpFsNotification
Definition: Interface.c:1699
ERESOURCE FilterListLock
Definition: Filter.c:25
static NTSTATUS SetupDispatchAndCallbacksTables(_In_ PDRIVER_OBJECT DriverObject)
Definition: Interface.c:1739
DRIVER_DATA DriverData
Definition: Interface.c:35
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Cleanup[]
Definition: register.c:80
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ClearFlag(_F, _SF)
Definition: ext2fs.h:191
#define DRIVER_NAME
Definition: ext2fs.h:136
#define FLT_ASSERT(_e)
Definition: fltkernel.h:49
#define FM_TAG_REGISTRY_DATA
Definition: fltmgr.h:18
#define FM_TAG_DISPATCH_TABLE
Definition: fltmgr.h:17
NTSTATUS FltpSetupCommunicationObjects(_In_ PDRIVER_OBJECT DriverObject)
Definition: Messaging.c:377
Status
Definition: gdiplustypes.h:25
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
NTSTATUS NTAPI IoRegisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject, IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine)
Definition: volume.c:1089
#define STATUS_DEVICE_ALREADY_ATTACHED
Definition: ntstatus.h:292
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:53
#define STATUS_SUCCESS
Definition: shellext.h:65
PDRIVER_OBJECT DriverObject
Definition: fltmgr.h:31
UNICODE_STRING ServiceKey
Definition: fltmgr.h:33
PFAST_IO_DISPATCH FastIoDispatch
Definition: fltmgr.h:37
FAST_MUTEX FilterAttachLock
Definition: fltmgr.h:39
PDEVICE_OBJECT DeviceObject
Definition: fltmgr.h:32
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ DoTheScreenSaver()

VOID FASTCALL DoTheScreenSaver ( VOID  )

Definition at line 48 of file input.c.

49{
50 DWORD Test, TO;
51
52 if (gspv.iScrSaverTimeout > 0) // Zero means Off.
53 {
56 TO = 1000 * gspv.iScrSaverTimeout;
57 if (Test > TO)
58 {
59 TRACE("Screensaver Message Start! Tick %lu Timeout %d \n", Test, gspv.iScrSaverTimeout);
60
61 if (ppiScrnSaver) // We are or we are not the screensaver, prevent reentry...
62 {
63 if (!(ppiScrnSaver->W32PF_flags & W32PF_IDLESCREENSAVER))
64 {
65 ppiScrnSaver->W32PF_flags |= W32PF_IDLESCREENSAVER;
66 ERR("Screensaver is Idle\n");
67 }
68 }
69 else
70 {
72 if (ForegroundQueue && ForegroundQueue->spwndActive)
74 else
76 }
77 }
78 }
79}
#define ERR(fmt,...)
Definition: precomp.h:57
#define EngGetTickCount32()
Definition: eng.h:43
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND hwndSAS
Definition: winsta.c:24
#define TRACE(s)
Definition: solgame.cpp:4
INT iScrSaverTimeout
Definition: sysparams.h:110
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
#define LN_START_SCREENSAVE
Definition: undocuser.h:121
#define W32PF_IDLESCREENSAVER
Definition: win32.h:27
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1324
static DWORD LastInputTick
Definition: input.c:21
PPROCESSINFO ppiScrnSaver
Definition: main.c:29
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1395
SPIVALUES gspv
Definition: sysparams.c:17

Referenced by HungAppSysTimerProc().

◆ IntBlockInput()

BOOL FASTCALL IntBlockInput ( PTHREADINFO  W32Thread,
BOOL  BlockIt 
)

Definition at line 375 of file input.c.

376{
377 PTHREADINFO OldBlock;
378 ASSERT(pti);
379
380 if(!pti->rpdesk || ((pti->TIF_flags & TIF_INCLEANUP) && BlockIt))
381 {
382 /*
383 * Fail blocking if exiting the thread
384 */
385
386 return FALSE;
387 }
388
389 /*
390 * FIXME: Check access rights of the window station
391 * e.g. services running in the service window station cannot block input
392 */
393 if(!ThreadHasInputAccess(pti) ||
394 !IntIsActiveDesktop(pti->rpdesk))
395 {
397 return FALSE;
398 }
399
400 ASSERT(pti->rpdesk);
401 OldBlock = pti->rpdesk->BlockInputThread;
402 if(OldBlock)
403 {
404 if(OldBlock != pti)
405 {
407 return FALSE;
408 }
409 pti->rpdesk->BlockInputThread = (BlockIt ? pti : NULL);
410 return OldBlock == NULL;
411 }
412
413 pti->rpdesk->BlockInputThread = (BlockIt ? pti : NULL);
414 return OldBlock == NULL;
415}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define TIF_INCLEANUP
Definition: ntuser.h:263
#define ASSERT(a)
Definition: mode.c:44
struct _DESKTOP * rpdesk
Definition: win32.h:92
#define IntIsActiveDesktop(Desktop)
Definition: desktop.h:172
#define ThreadHasInputAccess(W32Thread)
Definition: input.h:65
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22

Referenced by ExitThreadCallback(), and NtUserBlockInput().

◆ IntFreeImeHotKeys()

VOID FASTCALL IntFreeImeHotKeys ( VOID  )

Definition at line 326 of file ime.c.

327{
328 PIMEHOTKEY pNode, pNext;
329 for (pNode = gpImeHotKeyList; pNode; pNode = pNext)
330 {
331 pNext = pNode->pNext;
333 }
335}
struct tagIMEHOTKEY * pNext
Definition: ime.c:33
PIMEHOTKEY gpImeHotKeyList
Definition: ime.c:40
#define USERTAG_IMEHOTKEY
Definition: tags.h:239

Referenced by IntSetImeHotKey(), and UserProcessDestroy().

◆ IntImmProcessKey()

UINT FASTCALL IntImmProcessKey ( PUSER_MESSAGE_QUEUE  MessageQueue,
PWND  pWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 569 of file ime.c.

571{
572 UINT uVirtualKey, ret;
573 DWORD dwHotKeyId;
574 PKL pKL;
575 PIMC pIMC;
576 PIMEHOTKEY pImeHotKey;
577 HKL hKL;
578 HWND hWnd;
579
580 ASSERT_REFS_CO(pWnd);
581
582 switch (uMsg)
583 {
584 case WM_KEYDOWN:
585 case WM_KEYUP:
586 case WM_SYSKEYDOWN:
587 case WM_SYSKEYUP:
588 break;
589
590 default:
591 return 0;
592 }
593
594 pIMC = NULL;
595 hWnd = UserHMGetHandle(pWnd);
596 pKL = pWnd->head.pti->KeyboardLayout;
597 if (!pKL)
598 return 0;
599
600 uVirtualKey = LOBYTE(wParam);
601 pImeHotKey = IntCheckImeHotKey(MessageQueue, uVirtualKey, lParam);
602 if (pImeHotKey)
603 {
604 dwHotKeyId = pImeHotKey->dwHotKeyId;
605 hKL = pImeHotKey->hKL;
606 }
607 else
608 {
609 dwHotKeyId = INVALID_HOTKEY;
610 hKL = NULL;
611 }
612
613 if (IME_HOTKEY_DSWITCH_FIRST <= dwHotKeyId && dwHotKeyId <= IME_HOTKEY_DSWITCH_LAST)
614 {
615 if (pKL->hkl != hKL)
616 {
617 UserPostMessage(hWnd, WM_INPUTLANGCHANGEREQUEST,
618 ((pKL->dwFontSigs & gSystemFS) ? INPUTLANGCHANGE_SYSCHARSET : 0),
619 (LPARAM)hKL);
620 }
621
622 if (IntGetImeCompatFlags(pWnd->head.pti) & 0x800000)
623 return 0;
624
625 return IPHK_HOTKEY;
626 }
627
628 if (!IS_IMM_MODE())
629 return 0;
630
631 if (dwHotKeyId == INVALID_HOTKEY)
632 {
633 if (!pKL->piiex)
634 return 0;
635
636 if (pWnd->hImc)
638 if (!pIMC)
639 return 0;
640
641 if ((lParam & (KF_UP << 16)) &&
643 {
644 return 0;
645 }
646
647 switch (uVirtualKey)
648 {
649 case VK_DBE_CODEINPUT:
652 case VK_DBE_HIRAGANA:
653 case VK_DBE_KATAKANA:
655 case VK_DBE_NOROMAN:
656 case VK_DBE_ROMAN:
657 break;
658
659 default:
660 {
661 if (uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP)
662 {
663 if (uVirtualKey != VK_MENU && uVirtualKey != VK_F10)
664 return 0;
665 }
666
668 {
669 if (uVirtualKey == VK_MENU || (lParam & 0x20000000))
670 return 0;
671 }
672 break;
673 }
674 }
675 }
676
677 if (LOBYTE(uVirtualKey) == VK_PACKET)
678 uVirtualKey = MAKELONG(wParam, GetW32ThreadInfo()->wchInjected);
679
680 ret = co_IntImmProcessKey(hWnd, pKL->hkl, uVirtualKey, lParam, dwHotKeyId);
681
682 if (IntGetImeCompatFlags(pWnd->head.pti) & 0x800000)
683 ret &= ~IPHK_HOTKEY;
684
685 return ret;
686}
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define IME_HOTKEY_DSWITCH_LAST
Definition: imm.h:213
#define IME_HOTKEY_DSWITCH_FIRST
Definition: imm.h:212
#define IME_PROP_NEED_ALTKEY
Definition: immdev.h:387
#define IME_PROP_IGNORE_UPKEYS
Definition: immdev.h:386
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:807
#define IS_IMM_MODE()
Definition: ntuser.h:1209
@ TYPE_INPUTCONTEXT
Definition: ntuser.h:57
#define LOBYTE(W)
Definition: jmemdos.c:487
#define VK_DBE_ROMAN
Definition: jpnvkeys.h:19
#define VK_DBE_HIRAGANA
Definition: jpnvkeys.h:16
#define VK_DBE_CODEINPUT
Definition: jpnvkeys.h:24
#define VK_DBE_NOROMAN
Definition: jpnvkeys.h:20
#define VK_DBE_KATAKANA
Definition: jpnvkeys.h:15
#define VK_DBE_ENTERCONFIGMODE
Definition: jpnvkeys.h:22
#define VK_DBE_ENTERWORDREGISTERMODE
Definition: jpnvkeys.h:21
#define VK_DBE_NOCODEINPUT
Definition: jpnvkeys.h:25
UINT_PTR HKL
Definition: msctf.idl:143
unsigned int UINT
Definition: ndis.h:50
THRDESKHEAD head
Definition: ntuser.h:695
HIMC hImc
Definition: ntuser.h:740
DWORD fdwProperty
Definition: immdev.h:22
Definition: ntuser.h:199
HKL hKL
Definition: ime.c:37
DWORD dwHotKeyId
Definition: ime.c:34
IMEINFO ImeInfo
Definition: imm32_undoc.h:34
Definition: input.h:27
PIMEINFOEX piiex
Definition: input.h:38
DWORD dwFontSigs
Definition: input.h:34
HKL hkl
Definition: input.h:32
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define IPHK_HOTKEY
Definition: undocuser.h:139
#define ASSERT_REFS_CO(_obj_)
Definition: userfuncs.h:14
int ret
DWORD APIENTRY co_IntImmProcessKey(HWND hWnd, HKL hKL, UINT vKey, LPARAM lParam, DWORD dwHotKeyID)
Definition: callback.c:1253
#define INVALID_HOTKEY
Definition: ime.c:16
PIMEHOTKEY IntCheckImeHotKey(PUSER_MESSAGE_QUEUE MessageQueue, UINT uVirtualKey, LPARAM lParam)
Definition: ime.c:275
DWORD FASTCALL IntGetImeCompatFlags(PTHREADINFO pti)
Definition: ime.c:44
DWORD gSystemFS
Definition: kbdlayout.c:24
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_KEYUP
Definition: winuser.h:1719
#define VK_F10
Definition: winuser.h:2267
#define KF_UP
Definition: winuser.h:2454
#define WM_SYSKEYUP
Definition: winuser.h:1723
#define WM_KEYDOWN
Definition: winuser.h:1718
#define WM_SYSKEYDOWN
Definition: winuser.h:1722
#define VK_MENU
Definition: winuser.h:2207

Referenced by co_IntProcessKeyboardMessage().

◆ IsRemoveAttachThread()

BOOL FASTCALL IsRemoveAttachThread ( PTHREADINFO  pti)

Definition at line 437 of file input.c.

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

Referenced by ExitThreadCallback().

◆ RawInputThreadMain()

VOID NTAPI RawInputThreadMain ( VOID  )

Definition at line 124 of file input.c.

125{
126 NTSTATUS MouStatus = STATUS_UNSUCCESSFUL, KbdStatus = STATUS_UNSUCCESSFUL, Status;
127 IO_STATUS_BLOCK MouIosb, KbdIosb;
128 PFILE_OBJECT pKbdDevice = NULL, pMouDevice = NULL;
130 //LARGE_INTEGER WaitTimeout;
131 PVOID WaitObjects[4], pSignaledObject = NULL;
133 ULONG cWaitObjects = 0, cMaxWaitObjects = 2;
134 MOUSE_INPUT_DATA MouseInput;
135 KEYBOARD_INPUT_DATA KeyInput;
137 HWINSTA hWinSta;
138
139 ByteOffset.QuadPart = (LONGLONG)0;
140 //WaitTimeout.QuadPart = (LONGLONG)(-10000000);
141
145
146 TRACE("Raw Input Thread %p\n", ptiRawInput);
147
150
152 0,
153 NULL,
156 UserMode,
157 (PHANDLE)&hWinSta);
158 if (NT_SUCCESS(Status))
159 {
161 }
162 else
163 {
164 ASSERT(FALSE);
165 /* Failed to open the interactive winsta! What now? */
166 }
167
170 UserLeave();
171
174
176 for (;;)
177 {
178 if (!ghMouseDevice)
179 {
180 /* Check if mouse device already exists */
181 Status = OpenInputDevice(&ghMouseDevice, &pMouDevice, L"\\Device\\PointerClass0" );
182 if (NT_SUCCESS(Status))
183 {
184 ++cMaxWaitObjects;
185 TRACE("Mouse connected!\n");
186 }
187 }
188 if (!ghKeyboardDevice)
189 {
190 /* Check if keyboard device already exists */
191 Status = OpenInputDevice(&ghKeyboardDevice, &pKbdDevice, L"\\Device\\KeyboardClass0");
192 if (NT_SUCCESS(Status))
193 {
194 ++cMaxWaitObjects;
195 TRACE("Keyboard connected!\n");
196 // Get and load keyboard attributes.
199 // Register the Window hotkey.
201 // Register the Window Snap hotkey.
206 // Register the debug hotkeys.
208 UserLeave();
209 }
210 }
211
212 /* Reset WaitHandles array */
213 cWaitObjects = 0;
214 WaitObjects[cWaitObjects++] = ShutdownEvent;
215 WaitObjects[cWaitObjects++] = MasterTimer;
216
217 if (ghMouseDevice)
218 {
219 /* Try to read from mouse if previous reading is not pending */
220 if (MouStatus != STATUS_PENDING)
221 {
222 MouStatus = ZwReadFile(ghMouseDevice,
223 NULL,
224 NULL,
225 NULL,
226 &MouIosb,
227 &MouseInput,
228 sizeof(MOUSE_INPUT_DATA),
229 &ByteOffset,
230 NULL);
231 }
232
233 if (MouStatus == STATUS_PENDING)
234 WaitObjects[cWaitObjects++] = &pMouDevice->Event;
235 }
236
238 {
239 /* Try to read from keyboard if previous reading is not pending */
240 if (KbdStatus != STATUS_PENDING)
241 {
242 KbdStatus = ZwReadFile(ghKeyboardDevice,
243 NULL,
244 NULL,
245 NULL,
246 &KbdIosb,
247 &KeyInput,
248 sizeof(KEYBOARD_INPUT_DATA),
249 &ByteOffset,
250 NULL);
251
252 }
253 if (KbdStatus == STATUS_PENDING)
254 WaitObjects[cWaitObjects++] = &pKbdDevice->Event;
255 }
256
257 /* If all objects are pending, wait for them */
258 if (cWaitObjects == cMaxWaitObjects)
259 {
260 Status = KeWaitForMultipleObjects(cWaitObjects,
261 WaitObjects,
262 WaitAny,
265 TRUE,
266 NULL,//&WaitTimeout,
268
269 if ((Status >= STATUS_WAIT_0) &&
270 (Status < (STATUS_WAIT_0 + (LONG)cWaitObjects)))
271 {
272 /* Some device has finished reading */
273 pSignaledObject = WaitObjects[Status - STATUS_WAIT_0];
274
275 /* Check if it is mouse or keyboard and update status */
276 if ((MouStatus == STATUS_PENDING) &&
277 (pSignaledObject == &pMouDevice->Event))
278 {
279 MouStatus = MouIosb.Status;
280 }
281 else if ((KbdStatus == STATUS_PENDING) &&
282 (pSignaledObject == &pKbdDevice->Event))
283 {
284 KbdStatus = KbdIosb.Status;
285 }
286 else if (pSignaledObject == MasterTimer)
287 {
289 }
290 else if (pSignaledObject == ShutdownEvent)
291 {
292 break;
293 }
294 else ASSERT(FALSE);
295 }
296 }
297
298 /* Have we successed reading from mouse? */
299 if (NT_SUCCESS(MouStatus) && MouStatus != STATUS_PENDING)
300 {
301 TRACE("MouseEvent\n");
302
303 /* Set LastInputTick */
305
306 /* Process data */
308 UserProcessMouseInput(&MouseInput);
309 UserLeave();
310 }
311 else if (MouStatus != STATUS_PENDING)
312 ERR("Failed to read from mouse: %x.\n", MouStatus);
313
314 /* Have we successed reading from keyboard? */
315 if (NT_SUCCESS(KbdStatus) && KbdStatus != STATUS_PENDING)
316 {
317 TRACE("KeyboardEvent: %s %04x\n",
318 (KeyInput.Flags & KEY_BREAK) ? "up" : "down",
319 KeyInput.MakeCode);
320
321 /* Set LastInputTick */
323
324 /* Process data */
326 UserProcessKeyboardInput(&KeyInput);
327 UserLeave();
328 }
329 else if (KbdStatus != STATUS_PENDING)
330 ERR("Failed to read from keyboard: %x.\n", KbdStatus);
331 }
332
333 if (ghMouseDevice)
334 {
337 ObDereferenceObject(pMouDevice);
339 }
340
342 {
345 ObDereferenceObject(pKbdDevice);
347 }
348
349 ERR("Raw Input Thread Exit!\n");
350}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define STATUS_PENDING
Definition: d3dkmdt.h:43
static HANDLE ShutdownEvent
Definition: dcomlaunch.c:28
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:732
_Must_inspect_result_ _In_ WAIT_TYPE _In_opt_ PLARGE_INTEGER _In_opt_ PKWAIT_BLOCK WaitBlockArray
Definition: fsrtlfuncs.h:1153
#define IDHK_SNAP_LEFT
Definition: hotkey.h:20
#define IDHK_WINKEY
Definition: hotkey.h:16
#define IDHK_SNAP_UP
Definition: hotkey.h:22
#define IDHK_SNAP_DOWN
Definition: hotkey.h:23
#define IDHK_SNAP_RIGHT
Definition: hotkey.h:21
#define PWND_BOTTOM
Definition: ntuser.h:769
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:265
#define LOW_REALTIME_PRIORITY
#define KernelMode
Definition: asm.h:34
#define UserMode
Definition: asm.h:35
NTSYSAPI NTSTATUS NTAPI ZwCancelIoFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)
#define MAXIMUM_ALLOWED
Definition: nt_native.h:83
#define KEY_BREAK
Definition: ntddkbd.h:71
@ WaitAny
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
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_WAIT_0
Definition: ntstatus.h:237
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1382
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
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:2742
long LONG
Definition: pedump.c:60
NTSTATUS NTAPI PoRequestShutdownEvent(OUT PVOID *Event)
Definition: poshtdwn.c:384
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
FLONG TIF_flags
Definition: win32.h:95
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1319
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:21
BOOL FASTCALL UserRegisterHotKey(PWND pWnd, int id, UINT fsModifiers, UINT vk)
Definition: hotkey.c:431
VOID FASTCALL StartDebugHotKeys(VOID)
Definition: hotkey.c:44
static NTSTATUS NTAPI OpenInputDevice(PHANDLE pHandle, PFILE_OBJECT *ppObject, CONST WCHAR *pszDeviceName)
Definition: input.c:88
static HANDLE ghMouseDevice
Definition: input.c:22
HANDLE ghKeyboardDevice
Definition: input.c:19
PTHREADINFO ptiRawInput
Definition: input.c:15
static DWORD FASTCALL IntLastInputTick(BOOL bUpdate)
Definition: input.c:32
PKTIMER MasterTimer
Definition: input.c:16
VOID NTAPI UserProcessKeyboardInput(PKEYBOARD_INPUT_DATA pKeyInput)
Definition: keyboard.c:1191
VOID NTAPI UserProcessMouseInput(PMOUSE_INPUT_DATA pMouseInputData)
Definition: mouse.c:40
VOID NTAPI UserInitKeyboard(HANDLE hKeyboardDevice)
Definition: keyboard.c:163
VOID FASTCALL ProcessTimers(VOID)
Definition: timer.c:452
VOID FASTCALL StartTheTimers(VOID)
Definition: timer.c:374
#define MOD_WIN
Definition: winuser.h:2647
#define VK_UP
Definition: winuser.h:2228
#define VK_LEFT
Definition: winuser.h:2227
#define VK_RIGHT
Definition: winuser.h:2229
#define VK_DOWN
Definition: winuser.h:2230
@ UserRequest
Definition: ketypes.h:421
#define NT_ASSERT
Definition: rtlfuncs.h:3327

Referenced by UserSystemThreadProc().

◆ UserAttachThreadInput()

NTSTATUS FASTCALL UserAttachThreadInput ( PTHREADINFO  ptiFrom,
PTHREADINFO  ptiTo,
BOOL  fAttach 
)

Definition at line 480 of file input.c.

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

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}
unsigned short WORD
Definition: ntddk_ex.h:93
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
#define MK_SHIFT
Definition: winuser.h:2372
#define VK_CONTROL
Definition: winuser.h:2206
#define MK_CONTROL
Definition: winuser.h:2373
#define VK_SHIFT
Definition: winuser.h:2205

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

◆ UserHklToKbl()

PKL NTAPI UserHklToKbl ( HKL  hKl)

Definition at line 539 of file kbdlayout.c.

540{
541 PKL pKl = gspklBaseLayout;
542
543 if (!gspklBaseLayout)
544 return NULL;
545
546 do
547 {
548 if (pKl->hkl == hKl)
549 return pKl;
550
551 pKl = pKl->pklNext;
552 } while (pKl != gspklBaseLayout);
553
554 return NULL;
555}
struct tagKL * pklNext
Definition: input.h:29
PKL gspklBaseLayout
Definition: kbdlayout.c:22

Referenced by co_IntLoadKeyboardLayoutEx(), NtUserMapVirtualKeyEx(), NtUserSetThreadLayoutHandles(), NtUserToUnicodeEx(), NtUserVkKeyScanEx(), and UserSetDefaultInputLang().

◆ UserInitKeyboard()

VOID NTAPI UserInitKeyboard ( HANDLE  hKeyboardDevice)

Definition at line 163 of file keyboard.c.

164{
166 IO_STATUS_BLOCK Block;
167
169
170 Status = ZwDeviceIoControlFile(hKeyboardDevice,
171 NULL,
172 NULL,
173 NULL,
174 &Block,
176 NULL, 0,
178 sizeof(gIndicators));
179
180 if (!NT_SUCCESS(Status))
181 {
182 WARN("NtDeviceIoControlFile() failed, ignored\n");
185 }
186
193
194 // FIXME: Need device driver to work! HID support more than one!!!!
195 Status = ZwDeviceIoControlFile(hKeyboardDevice,
196 NULL,
197 NULL,
198 NULL,
199 &Block,
201 NULL, 0,
202 &gKeyboardInfo, sizeof(gKeyboardInfo));
203
204 if (!NT_SUCCESS(Status))
205 {
206 ERR("NtDeviceIoControlFile() failed, ignored\n");
207 }
208 TRACE("Keyboard type %u, subtype %u and number of func keys %u\n",
212}
#define WARN(fmt,...)
Definition: precomp.h:61
#define KEYBOARD_CAPS_LOCK_ON
Definition: ntddkbd.h:81
#define IOCTL_KEYBOARD_QUERY_INDICATORS
Definition: ntddkbd.h:35
#define IOCTL_KEYBOARD_QUERY_ATTRIBUTES
Definition: ntddkbd.h:32
#define KEYBOARD_SCROLL_LOCK_ON
Definition: ntddkbd.h:83
#define KEYBOARD_NUM_LOCK_ON
Definition: ntddkbd.h:82
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)
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
UCHAR Subtype
Definition: ntddkbd.h:102
UCHAR Type
Definition: ntddkbd.h:101
#define SET_KEY_LOCKED(ks, vk, down)
Definition: input.h:103
static KEYBOARD_INDICATOR_PARAMETERS gIndicators
Definition: keyboard.c:16
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans
Definition: keyboard.c:15
NTSTATUS APIENTRY IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice, PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans)
Definition: keyboard.c:52
#define VK_CAPITAL
Definition: winuser.h:2209
#define VK_SCROLL
Definition: winuser.h:2283
#define VK_NUMLOCK
Definition: winuser.h:2282

Referenced by RawInputThreadMain().

◆ UserProcessKeyboardInput()

VOID NTAPI UserProcessKeyboardInput ( PKEYBOARD_INPUT_DATA  pKeyInput)

Definition at line 1191 of file keyboard.c.

1193{
1194 WORD wScanCode, wVk;
1195 PKL pKl = NULL;
1196 PKBDTABLES pKbdTbl;
1197 PUSER_MESSAGE_QUEUE pFocusQueue;
1198
1199 /* Calculate scan code with prefix */
1200 wScanCode = pKbdInputData->MakeCode & 0x7F;
1201 if (pKbdInputData->Flags & KEY_E0)
1202 wScanCode |= 0xE000;
1203 if (pKbdInputData->Flags & KEY_E1)
1204 wScanCode |= 0xE100;
1205
1206 /* Find the target thread whose locale is in effect */
1207 pFocusQueue = IntGetFocusMessageQueue();
1208
1209 if (pFocusQueue && pFocusQueue->ptiKeyboard)
1210 {
1211 pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
1212 }
1213
1214 if (!pKl)
1216 if (!pKl)
1217 return;
1218
1219 pKbdTbl = pKl->spkf->pKbdTbl;
1220
1221 /* Convert scan code to virtual key.
1222 Note: We could call UserSendKeyboardInput using scan code,
1223 but it wouldn't interpret E1 key(s) properly */
1224 wVk = IntVscToVk(wScanCode, pKbdTbl);
1225 TRACE("UserProcessKeyboardInput: %x (break: %u) -> %x\n",
1226 wScanCode, (pKbdInputData->Flags & KEY_BREAK) ? 1u : 0, wVk);
1227
1228 if (wVk)
1229 {
1230 KEYBDINPUT KbdInput;
1231
1232 /* Support numlock */
1234 {
1235 wVk = IntTranslateNumpadKey(wVk & 0xFF);
1236 }
1237
1238 /* Send keyboard input */
1239 KbdInput.wVk = wVk & 0xFF;
1240 KbdInput.wScan = wScanCode & 0x7F;
1241 KbdInput.dwFlags = 0;
1242 if (pKbdInputData->Flags & KEY_BREAK)
1243 KbdInput.dwFlags |= KEYEVENTF_KEYUP;
1244
1245 if (wVk & KBDEXT)
1246 KbdInput.dwFlags |= KEYEVENTF_EXTENDEDKEY;
1247 //
1248 // Based on wine input:test_Input_blackbox this is okay. It seems the
1249 // bit did not get set and more research is needed. Now the right
1250 // shift works.
1251 //
1252 if (wVk == VK_RSHIFT)
1253 KbdInput.dwFlags |= KEYEVENTF_EXTENDEDKEY;
1254
1255 KbdInput.time = 0;
1256 KbdInput.dwExtraInfo = pKbdInputData->ExtraInformation;
1257 UserSendKeyboardInput(&KbdInput, FALSE);
1258
1259 /* E1 keys don't have break code */
1260 if (pKbdInputData->Flags & KEY_E1)
1261 {
1262 /* Send key up event */
1263 KbdInput.dwFlags |= KEYEVENTF_KEYUP;
1264 UserSendKeyboardInput(&KbdInput, FALSE);
1265 }
1266 }
1267}
#define KBDNUMPAD
Definition: kbd.h:11
#define KBDEXT
Definition: kbd.h:8
#define KEY_E1
Definition: ntddkbd.h:73
#define KEY_E0
Definition: ntddkbd.h:72
Definition: kbd.h:95
struct tagKL * KeyboardLayout
Definition: win32.h:90
PTHREADINFO ptiKeyboard
Definition: msgqueue.h:56
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
DWORD dwFlags
Definition: winable.h:49
WORD wVk
Definition: winable.h:47
WORD wScan
Definition: winable.h:48
ULONG_PTR dwExtraInfo
Definition: winable.h:51
DWORD time
Definition: winable.h:50
PKBDFILE spkf
Definition: input.h:33
#define IS_KEY_LOCKED(ks, vk)
Definition: input.h:99
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:512
BOOL NTAPI UserSendKeyboardInput(KEYBDINPUT *pKbdInput, BOOL bInjected)
Definition: keyboard.c:1110
static WORD FASTCALL IntVscToVk(WORD wScanCode, PKBDTABLES pKbdTbl)
Definition: keyboard.c:564
static WORD IntTranslateNumpadKey(WORD wVk)
Definition: keyboard.c:274
#define VK_RSHIFT
Definition: winuser.h:2286
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1104
#define KEYEVENTF_KEYUP
Definition: winuser.h:1105

Referenced by RawInputThreadMain().

◆ UserProcessMouseInput()

VOID NTAPI UserProcessMouseInput ( PMOUSE_INPUT_DATA  pMouseInputData)

Definition at line 40 of file mouse.c.

41{
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 MOUSE_LEFT_BUTTON_DOWN
Definition: ntddmou.h:46
#define MOUSE_LEFT_BUTTON_UP
Definition: ntddmou.h:47
#define MOUSE_MIDDLE_BUTTON_DOWN
Definition: ntddmou.h:50
#define MOUSE_BUTTON_4_DOWN
Definition: ntddmou.h:52
#define MOUSE_BUTTON_5_UP
Definition: ntddmou.h:55
#define MOUSE_WHEEL
Definition: ntddmou.h:56
#define MOUSE_MOVE_ABSOLUTE
Definition: ntddmou.h:68
#define MOUSE_VIRTUAL_DESKTOP
Definition: ntddmou.h:69
#define MOUSE_BUTTON_5_DOWN
Definition: ntddmou.h:54
#define MOUSE_BUTTON_4_UP
Definition: ntddmou.h:53
#define MOUSE_RIGHT_BUTTON_UP
Definition: ntddmou.h:49
#define MOUSE_MIDDLE_BUTTON_UP
Definition: ntddmou.h:51
#define MOUSE_RIGHT_BUTTON_DOWN
Definition: ntddmou.h:48
DWORD dwFlags
Definition: winuser.h:3790
BOOL NTAPI UserSendMouseInput(MOUSEINPUT *pmi, BOOL bInjected)
Definition: mouse.c:168
static MONITORINFO mi
Definition: win.c:7338
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1197
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1188
#define MOUSEEVENTF_WHEEL
Definition: winuser.h:1195
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1190
#define MOUSEEVENTF_MIDDLEUP
Definition: winuser.h:1192
#define MOUSEEVENTF_XUP
Definition: winuser.h:1194
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1186
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1187
#define MOUSEEVENTF_XDOWN
Definition: winuser.h:1193
#define MOUSEEVENTF_VIRTUALDESK
Definition: winuser.h:1196
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1189
#define MOUSEEVENTF_MIDDLEDOWN
Definition: winuser.h:1191

Referenced by RawInputThreadMain().

◆ UserSendKeyboardInput()

BOOL NTAPI UserSendKeyboardInput ( KEYBDINPUT pKbdInput,
BOOL  bInjected 
)

Definition at line 1110 of file keyboard.c.

1111{
1112 WORD wScanCode, wVk;
1113 PKL pKl = NULL;
1114 PKBDTABLES pKbdTbl;
1115 PUSER_MESSAGE_QUEUE pFocusQueue;
1116 DWORD dwTime;
1117 BOOL bExt = (pKbdInput->dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
1118
1120
1121 /* Find the target thread whose locale is in effect */
1122 pFocusQueue = IntGetFocusMessageQueue();
1123
1124 if (pFocusQueue && pFocusQueue->ptiKeyboard)
1125 {
1126 pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
1127 }
1128
1129 if (!pKl)
1131 if (!pKl)
1132 {
1133 ERR("No keyboard layout!\n");
1134 return FALSE;
1135 }
1136
1137 pKbdTbl = pKl->spkf->pKbdTbl;
1138
1139 /* Note: wScan field is always used */
1140 wScanCode = pKbdInput->wScan;
1141
1142 if (pKbdInput->dwFlags & KEYEVENTF_UNICODE)
1143 {
1144 /* Generate WM_KEYDOWN msg with wParam == VK_PACKET and
1145 high order word of lParam == pKbdInput->wScan */
1146 wVk = VK_PACKET;
1147 }
1148 else
1149 {
1150 wScanCode &= 0x7F;
1151 if (pKbdInput->dwFlags & KEYEVENTF_SCANCODE)
1152 {
1153 /* Don't ignore invalid scan codes */
1154 wVk = IntVscToVk(wScanCode | (bExt ? 0xE000 : 0), pKbdTbl);
1155 if (!wVk) /* use 0xFF if vsc is invalid */
1156 wVk = 0xFF;
1157 }
1158 else
1159 {
1160 wVk = pKbdInput->wVk;
1161 }
1162
1163 /* Remove all virtual key flags (KBDEXT, KBDMULTIVK, KBDSPECIAL, KBDNUMPAD) */
1164 wVk &= 0xFF;
1165 }
1166
1167 /* If time is given, use it */
1168 if (pKbdInput->time)
1169 dwTime = pKbdInput->time;
1170 else
1171 {
1173 }
1174
1175 if (wVk == VK_RMENU && (pKbdTbl->fLocaleFlags & KLLF_ALTGR))
1176 {
1177 /* For AltGr keyboards RALT generates CTRL events */
1178 ProcessKeyEvent(VK_LCONTROL, 0, pKbdInput->dwFlags & KEYEVENTF_KEYUP, bInjected, dwTime, 0);
1179 }
1180
1181 /* Finally process this key */
1182 return ProcessKeyEvent(wVk, wScanCode, pKbdInput->dwFlags, bInjected, dwTime, pKbdInput->dwExtraInfo);
1183}
#define KLLF_ALTGR
Definition: kbd.h:91
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
DWORD dwTime
Definition: solitaire.cpp:27
DWORD fLocaleFlags
Definition: kbd.h:106
BOOL NTAPI ProcessKeyEvent(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
Definition: keyboard.c:888
#define VK_LCONTROL
Definition: winuser.h:2287
#define VK_RMENU
Definition: winuser.h:2290

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;
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 Msg.time = EngGetTickCount32();
214 }
215
216 /* Do GetMouseMovePointsEx FIFO. */
220 gMouseHistoryOfMoves[gcMouseHistoryOfMoves].dwExtraInfo = pmi->dwExtraInfo;
222 gcMouseHistoryOfMoves = 0; // 0 - 63 is 64, FIFO forwards.
223
224 /* Update cursor position */
226 {
227 UserSetCursorPos(ptCursor.x, ptCursor.y, bInjected, pmi->dwExtraInfo, TRUE);
228 }
229
231 pCurInfo->ButtonsDown |= MK_SHIFT;
232 else
233 pCurInfo->ButtonsDown &= ~MK_SHIFT;
234
236 pCurInfo->ButtonsDown |= MK_CONTROL;
237 else
238 pCurInfo->ButtonsDown &= ~MK_CONTROL;
239
240 /* Left button */
242 {
244 Msg.message = WM_LBUTTONDOWN;
245 pCurInfo->ButtonsDown |= MK_LBUTTON;
246 Msg.wParam |= MK_LBUTTON;
247 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
248 }
249 else if (dwFlags & MOUSEEVENTF_LEFTUP)
250 {
252 Msg.message = WM_LBUTTONUP;
253 pCurInfo->ButtonsDown &= ~MK_LBUTTON;
254 Msg.wParam &= ~MK_LBUTTON;
255 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
256 }
257
258 /* Middle button */
260 {
262 Msg.message = WM_MBUTTONDOWN;
263 pCurInfo->ButtonsDown |= MK_MBUTTON;
264 Msg.wParam |= MK_MBUTTON;
265 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
266 }
267 else if (dwFlags & MOUSEEVENTF_MIDDLEUP)
268 {
270 Msg.message = WM_MBUTTONUP;
271 pCurInfo->ButtonsDown &= ~MK_MBUTTON;
272 Msg.wParam &= ~MK_MBUTTON;
273 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
274 }
275
276 /* Right button */
278 {
280 Msg.message = WM_RBUTTONDOWN;
281 pCurInfo->ButtonsDown |= MK_RBUTTON;
282 Msg.wParam |= MK_RBUTTON;
283 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
284 }
285 else if (dwFlags & MOUSEEVENTF_RIGHTUP)
286 {
288 Msg.message = WM_RBUTTONUP;
289 pCurInfo->ButtonsDown &= ~MK_RBUTTON;
290 Msg.wParam &= ~MK_RBUTTON;
291 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
292 }
293
296 {
297 /* Fail because both types of events use the mouseData field */
298 WARN("Invalid flags!\n");
299 return FALSE;
300 }
301
302 /* X-Button (4 or 5) */
304 {
305 Msg.message = WM_XBUTTONDOWN;
306 if (pmi->mouseData & XBUTTON1)
307 {
308 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, TRUE);
309 pCurInfo->ButtonsDown |= MK_XBUTTON1;
310 Msg.wParam |= MAKEWPARAM(MK_XBUTTON1, XBUTTON1);
311 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
312 }
313 if (pmi->mouseData & XBUTTON2)
314 {
315 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, TRUE);
316 pCurInfo->ButtonsDown |= MK_XBUTTON2;
317 Msg.wParam |= MAKEWPARAM(MK_XBUTTON2, XBUTTON2);
318 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
319 }
320 }
321 else if (dwFlags & MOUSEEVENTF_XUP)
322 {
323 Msg.message = WM_XBUTTONUP;
324 if(pmi->mouseData & XBUTTON1)
325 {
326 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON1, FALSE);
327 pCurInfo->ButtonsDown &= ~MK_XBUTTON1;
328 Msg.wParam &= ~MK_XBUTTON1;
329 Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
330 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
331 }
332 if (pmi->mouseData & XBUTTON2)
333 {
334 SET_KEY_DOWN(gafAsyncKeyState, VK_XBUTTON2, FALSE);
335 pCurInfo->ButtonsDown &= ~MK_XBUTTON2;
336 Msg.wParam &= ~MK_XBUTTON2;
337 Msg.wParam |= MAKEWPARAM(0, XBUTTON2);
338 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
339 }
340 }
341
342 /* Mouse wheel */
344 {
345 Msg.message = WM_MOUSEWHEEL;
346 Msg.wParam = MAKEWPARAM(pCurInfo->ButtonsDown, pmi->mouseData);
347 co_MsqInsertMouseMessage(&Msg, bInjected, pmi->dwExtraInfo, TRUE);
348 }
349
350 return TRUE;
351}
struct @1640 Msg[]
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define WM_MOUSEWHEEL
Definition: treelist.c:96
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
#define SET_KEY_DOWN(ks, vk, down)
Definition: input.h:100
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:214
MOUSEMOVEPOINT gMouseHistoryOfMoves[64]
Definition: mouse.c:13
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
DWORD IntFixMouseInputButtons(DWORD dwFlags)
Definition: mouse.c:138
INT gcMouseHistoryOfMoves
Definition: mouse.c:14
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define MK_RBUTTON
Definition: winuser.h:2371
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1042
#define SM_CYSCREEN
Definition: winuser.h:963
#define VK_RBUTTON
Definition: winuser.h:2194
#define WM_RBUTTONUP
Definition: winuser.h:1783
#define VK_MBUTTON
Definition: winuser.h:2196
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
#define WM_RBUTTONDOWN
Definition: winuser.h:1782
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1041
#define MK_MBUTTON
Definition: winuser.h:2374
#define WM_LBUTTONUP
Definition: winuser.h:1780
#define MK_LBUTTON
Definition: winuser.h:2370
#define SM_CXSCREEN
Definition: winuser.h:962
#define WM_MBUTTONUP
Definition: winuser.h:1786
#define WM_MBUTTONDOWN
Definition: winuser.h:1785
#define VK_LBUTTON
Definition: winuser.h:2193

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

◆ UserSetDefaultInputLang()

BOOL NTAPI UserSetDefaultInputLang ( HKL  hKl)

Definition at line 583 of file kbdlayout.c.

584{
585 PKL pKl;
586
587 pKl = UserHklToKbl(hKl);
588 if (!pKl)
589 return FALSE;
590
592 return TRUE;
593}
PWINSTATION_OBJECT FASTCALL IntGetProcessWindowStation(HWINSTA *phWinSta OPTIONAL)
Definition: winsta.c:400
VOID FASTCALL IntReorderKeyboardLayouts(_Inout_ PWINSTATION_OBJECT pWinSta, _Inout_ PKL pNewKL)
Definition: kbdlayout.c:558
PKL NTAPI UserHklToKbl(HKL hKl)
Definition: kbdlayout.c:539

Referenced by SpiGetSet().

◆ W32kGetDefaultKeyLayout()

PKL W32kGetDefaultKeyLayout ( VOID  )

Definition at line 512 of file kbdlayout.c.

513{
514 PKL pKl = gspklBaseLayout;
515
516 if (!pKl)
517 return NULL;
518
519 /* Return not unloaded layout */
520 do
521 {
522 if (!(pKl->dwKL_Flags & KL_UNLOAD))
523 return pKl;
524
525 pKl = pKl->pklPrev; /* Confirmed on Win2k */
526 } while(pKl != gspklBaseLayout);
527
528 /* We have not found proper KL */
529 return NULL;
530}
DWORD dwKL_Flags
Definition: input.h:31
struct tagKL * pklPrev
Definition: input.h:30
#define KL_UNLOAD
Definition: undocuser.h:179

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

Variable Documentation

◆ gafAsyncKeyState

◆ gdwLanguageToggleKey

DWORD gdwLanguageToggleKey
extern

Definition at line 19 of file keyboard.c.

Referenced by ProcessKeyEvent(), SpiGetSet(), and SpiUpdatePerUserSystemParameters().

◆ gdwLayoutToggleKey

DWORD gdwLayoutToggleKey
extern

Definition at line 21 of file keyboard.c.

Referenced by ProcessKeyEvent(), SpiGetSet(), and SpiUpdatePerUserSystemParameters().

◆ ghKeyboardDevice

HANDLE ghKeyboardDevice
extern

Definition at line 19 of file input.c.

Referenced by ProcessKeyEvent(), and RawInputThreadMain().

◆ gKeyboardInfo

KEYBOARD_ATTRIBUTES gKeyboardInfo
extern

◆ gLanguageToggleKeyState

INT gLanguageToggleKeyState
extern

Definition at line 18 of file keyboard.c.

Referenced by ProcessKeyEvent().

◆ gLayoutToggleKeyState

INT gLayoutToggleKeyState
extern

Definition at line 20 of file keyboard.c.

Referenced by IntCheckLanguageToggle(), and ProcessKeyEvent().

◆ gpai

PATTACHINFO gpai
extern

Definition at line 17 of file input.c.

Referenced by IsRemoveAttachThread(), and UserAttachThreadInput().

◆ gspklBaseLayout

◆ gSystemCPCharSet

UINT gSystemCPCharSet
extern

Definition at line 25 of file kbdlayout.c.

Referenced by co_UserLoadKbdLayout().

◆ gSystemFS

DWORD gSystemFS
extern

Definition at line 24 of file kbdlayout.c.

Referenced by co_UserLoadKbdLayout(), IntImmProcessKey(), and IntLanguageToggle().

◆ ptiRawInput

PTHREADINFO ptiRawInput
extern

Definition at line 15 of file input.c.

Referenced by IntSetTimer(), and RawInputThreadMain().