ReactOS  0.4.15-dev-3308-g9455def
keyboard.c File Reference
#include <win32k.h>
Include dependency graph for keyboard.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserKbd)
 
NTSTATUS NTAPI InitKeyboardImpl (VOID)
 
NTSTATUS APIENTRY IntKeyboardGetIndicatorTrans (HANDLE hKeyboardDevice, PKEYBOARD_INDICATOR_TRANSLATION *ppIndicatorTrans)
 
static NTSTATUS APIENTRY IntKeyboardUpdateLeds (HANDLE hKeyboardDevice, WORD wVk, WORD wScanCode)
 
VOID NTAPI UserInitKeyboard (HANDLE hKeyboardDevice)
 
static WORD IntSimplifyVk (WORD wVk)
 
static WORD IntFixVk (WORD wVk, BOOL bExt)
 
static WORD IntTranslateNumpadKey (WORD wVk)
 
static DWORD IntGetModBits (PKBDTABLES pKbdTbl, PBYTE pKeyState)
 
static BOOL IntTranslateChar (WORD wVirtKey, PBYTE pKeyState, PBOOL pbDead, PBOOL pbLigature, PWCHAR pwcTranslatedChar, PKBDTABLES pKbdTbl)
 
static int APIENTRY IntToUnicodeEx (UINT wVirtKey, UINT wScanCode, PBYTE pKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, PKBDTABLES pKbdTbl)
 
static WORD FASTCALL IntVkToVsc (WORD wVk, PKBDTABLES pKbdTbl)
 
static WORD FASTCALL IntVscToVk (WORD wScanCode, PKBDTABLES pKbdTbl)
 
static WCHAR FASTCALL IntVkToChar (WORD wVk, PKBDTABLES pKbdTbl)
 
SHORT APIENTRY NtUserGetAsyncKeyState (INT Key)
 
static VOID NTAPI UpdateAsyncKeyState (WORD wVk, BOOL bIsDown)
 
static LRESULT co_CallLowLevelKeyboardHook (WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
 
static VOID SnapWindow (HWND hWnd)
 
BOOL NTAPI ProcessKeyEvent (WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
 
BOOL NTAPI UserSendKeyboardInput (KEYBDINPUT *pKbdInput, BOOL bInjected)
 
VOID NTAPI UserProcessKeyboardInput (PKEYBOARD_INPUT_DATA pKbdInputData)
 
BOOL FASTCALL IntTranslateKbdMessage (LPMSG lpMsg, UINT flags)
 
static UINT IntMapVirtualKeyEx (UINT uCode, UINT Type, PKBDTABLES pKbdTbl)
 
UINT APIENTRY NtUserMapVirtualKeyEx (UINT uCode, UINT uType, DWORD keyboardId, HKL dwhkl)
 
int APIENTRY NtUserToUnicodeEx (UINT wVirtKey, UINT wScanCode, PBYTE pKeyStateUnsafe, LPWSTR pwszBuffUnsafe, INT cchBuff, UINT wFlags, HKL dwhkl)
 
DWORD APIENTRY NtUserGetKeyNameText (LONG lParam, LPWSTR lpString, int cchSize)
 
DWORD FASTCALL UserGetKeyboardType (DWORD dwTypeFlag)
 
DWORD APIENTRY NtUserVkKeyScanEx (WCHAR wch, HKL dwhkl, BOOL bUsehKL)
 

Variables

BYTE gafAsyncKeyState [256 *2/8]
 
static BYTE gafAsyncKeyStateRecentDown [256/8]
 
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans = NULL
 
static KEYBOARD_INDICATOR_PARAMETERS gIndicators = {0, 0}
 
KEYBOARD_ATTRIBUTES gKeyboardInfo
 
int gLanguageToggleKeyState = 0
 
DWORD gdwLanguageToggleKey = 0
 

Function Documentation

◆ co_CallLowLevelKeyboardHook()

static LRESULT co_CallLowLevelKeyboardHook ( WORD  wVk,
WORD  wScanCode,
DWORD  dwFlags,
BOOL  bInjected,
DWORD  dwTime,
DWORD  dwExtraInfo 
)
static

Definition at line 687 of file keyboard.c.

688 {
689  KBDLLHOOKSTRUCT KbdHookData;
690  UINT uMsg;
691 
692  KbdHookData.vkCode = wVk;
693  KbdHookData.scanCode = wScanCode;
694  KbdHookData.flags = 0;
696  KbdHookData.flags |= LLKHF_EXTENDED;
698  KbdHookData.flags |= LLKHF_ALTDOWN;
699  if (dwFlags & KEYEVENTF_KEYUP)
700  KbdHookData.flags |= LLKHF_UP;
701  if (bInjected)
702  KbdHookData.flags |= LLKHF_INJECTED;
703  KbdHookData.time = dwTime;
704  KbdHookData.dwExtraInfo = dwExtraInfo;
705 
706  /* Note: it doesnt support WM_SYSKEYUP */
707  if (dwFlags & KEYEVENTF_KEYUP)
708  uMsg = WM_KEYUP;
710  uMsg = WM_SYSKEYDOWN;
711  else
712  uMsg = WM_KEYDOWN;
713 
714  return co_HOOK_CallHooks(WH_KEYBOARD_LL, HC_ACTION, uMsg, (LPARAM)&KbdHookData);
715 }
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define VK_MENU
Definition: winuser.h:2180
#define LLKHF_UP
Definition: winuser.h:2624
#define WM_KEYDOWN
Definition: winuser.h:1698
LONG_PTR LPARAM
Definition: windef.h:208
DWORD dwTime
Definition: solitaire.cpp:26
#define WH_KEYBOARD_LL
Definition: winuser.h:43
#define WM_KEYUP
Definition: winuser.h:1699
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
#define LLKHF_INJECTED
Definition: winuser.h:2622
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define LLKHF_EXTENDED
Definition: winuser.h:2621
#define LLKHF_ALTDOWN
Definition: winuser.h:2623
#define HC_ACTION
Definition: winuser.h:48
unsigned int UINT
Definition: ndis.h:50
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
#define VK_CONTROL
Definition: winuser.h:2179
#define WM_SYSKEYDOWN
Definition: winuser.h:1702
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
ULONG_PTR dwExtraInfo
Definition: winuser.h:3788

Referenced by ProcessKeyEvent().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserKbd  )

◆ InitKeyboardImpl()

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:262
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DriverEntry().

◆ IntFixVk()

static WORD IntFixVk ( WORD  wVk,
BOOL  bExt 
)
static

Definition at line 247 of file keyboard.c.

248 {
249  switch (wVk)
250  {
251  case VK_SHIFT:
252  return bExt ? VK_RSHIFT : VK_LSHIFT;
253 
254  case VK_CONTROL:
255  return bExt ? VK_RCONTROL : VK_LCONTROL;
256 
257  case VK_MENU:
258  return bExt ? VK_RMENU : VK_LMENU;
259 
260  default:
261  return wVk;
262  }
263 }
#define VK_RMENU
Definition: winuser.h:2263
#define VK_LSHIFT
Definition: winuser.h:2258
#define VK_MENU
Definition: winuser.h:2180
#define VK_SHIFT
Definition: winuser.h:2178
#define VK_RCONTROL
Definition: winuser.h:2261
#define VK_LMENU
Definition: winuser.h:2262
#define VK_RSHIFT
Definition: winuser.h:2259
#define VK_CONTROL
Definition: winuser.h:2179
#define VK_LCONTROL
Definition: winuser.h:2260

Referenced by IntMapVirtualKeyEx(), and ProcessKeyEvent().

◆ IntGetModBits()

static DWORD IntGetModBits ( PKBDTABLES  pKbdTbl,
PBYTE  pKeyState 
)
static

Definition at line 298 of file keyboard.c.

299 {
300  DWORD i, dwModBits = 0;
301 
302  /* DumpKeyState( KeyState ); */
303 
304  for (i = 0; pKbdTbl->pCharModifiers->pVkToBit[i].Vk; i++)
305  if (IS_KEY_DOWN(pKeyState, pKbdTbl->pCharModifiers->pVkToBit[i].Vk))
306  dwModBits |= pKbdTbl->pCharModifiers->pVkToBit[i].ModBits;
307 
308  TRACE("Current Mod Bits: %lx\n", dwModBits);
309 
310  return dwModBits;
311 }
BYTE ModBits
Definition: kbd.h:23
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
PVK_TO_BIT pVkToBit
Definition: kbd.h:27
BYTE Vk
Definition: kbd.h:22
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PMODIFIERS pCharModifiers
Definition: kbd.h:96
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98

Referenced by IntTranslateChar().

◆ IntKeyboardGetIndicatorTrans()

NTSTATUS APIENTRY IntKeyboardGetIndicatorTrans ( HANDLE  hKeyboardDevice,
PKEYBOARD_INDICATOR_TRANSLATION ppIndicatorTrans 
)

Definition at line 50 of file keyboard.c.

52 {
54  DWORD dwSize = 0;
55  IO_STATUS_BLOCK Block;
57 
59 
61  dwSize,
63 
64  while (pRet)
65  {
66  Status = ZwDeviceIoControlFile(hKeyboardDevice,
67  NULL,
68  NULL,
69  NULL,
70  &Block,
72  NULL, 0,
73  pRet, dwSize);
74 
76  break;
77 
79 
81 
83  dwSize,
85  }
86 
87  if (!pRet)
89 
90  if (!NT_SUCCESS(Status))
91  {
93  return Status;
94  }
95 
96  *ppIndicatorTrans = pRet;
97  return Status;
98 }
#define USERTAG_KBDTABLE
Definition: tags.h:246
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)
#define IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION
Definition: ntddkbd.h:38
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _KEYBOARD_INDICATOR_TRANSLATION KEYBOARD_INDICATOR_TRANSLATION
#define NULL
Definition: types.h:112
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by UserInitKeyboard().

◆ IntKeyboardUpdateLeds()

static NTSTATUS APIENTRY IntKeyboardUpdateLeds ( HANDLE  hKeyboardDevice,
WORD  wVk,
WORD  wScanCode 
)
static

Definition at line 107 of file keyboard.c.

110 {
112  UINT i;
113  USHORT LedFlag = 0;
114  IO_STATUS_BLOCK Block;
115 
117  return STATUS_NOT_SUPPORTED;
118 
119  switch (wVk)
120  {
121  case VK_CAPITAL: LedFlag = KEYBOARD_CAPS_LOCK_ON; break;
122  case VK_NUMLOCK: LedFlag = KEYBOARD_NUM_LOCK_ON; break;
123  case VK_SCROLL: LedFlag = KEYBOARD_SCROLL_LOCK_ON; break;
124  default:
126  {
128  {
130  break;
131  }
132  }
133  }
134 
135  if (LedFlag)
136  {
137  gIndicators.LedFlags ^= LedFlag;
138 
139  /* Update the lights on the hardware */
140  Status = ZwDeviceIoControlFile(hKeyboardDevice,
141  NULL,
142  NULL,
143  NULL,
144  &Block,
146  &gIndicators, sizeof(gIndicators),
147  NULL, 0);
148 
149  return Status;
150  }
151 
152  return STATUS_SUCCESS;
153 }
USHORT MakeCode
Definition: ntddkbd.h:114
return STATUS_NOT_SUPPORTED
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)
USHORT IndicatorFlags
Definition: ntddkbd.h:115
LONG NTSTATUS
Definition: precomp.h:26
INDICATOR_LIST IndicatorList[1]
Definition: ntddkbd.h:120
static KEYBOARD_INDICATOR_PARAMETERS gIndicators
Definition: keyboard.c:16
#define KEYBOARD_CAPS_LOCK_ON
Definition: ntddkbd.h:81
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans
Definition: keyboard.c:15
Status
Definition: gdiplustypes.h:24
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define VK_SCROLL
Definition: winuser.h:2256
#define VK_NUMLOCK
Definition: winuser.h:2255
unsigned short USHORT
Definition: pedump.c:61
#define KEYBOARD_SCROLL_LOCK_ON
Definition: ntddkbd.h:83
#define VK_CAPITAL
Definition: winuser.h:2182
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define KEYBOARD_NUM_LOCK_ON
Definition: ntddkbd.h:82
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IOCTL_KEYBOARD_SET_INDICATORS
Definition: ntddkbd.h:47

Referenced by ProcessKeyEvent().

◆ IntMapVirtualKeyEx()

static UINT IntMapVirtualKeyEx ( UINT  uCode,
UINT  Type,
PKBDTABLES  pKbdTbl 
)
static

Definition at line 1247 of file keyboard.c.

1248 {
1249  UINT uRet = 0;
1250 
1251  switch (Type)
1252  {
1253  case MAPVK_VK_TO_VSC:
1254  uCode = IntFixVk(uCode, FALSE);
1255  uRet = IntVkToVsc(uCode, pKbdTbl);
1256  if (uRet > 0xFF) // Fail for scancodes with prefix (e0, e1)
1257  uRet = 0;
1258  break;
1259 
1260  case MAPVK_VSC_TO_VK:
1261  uRet = IntVscToVk(uCode, pKbdTbl) & 0xFF;
1262  uRet = IntSimplifyVk(uRet);
1263  break;
1264 
1265  case MAPVK_VK_TO_CHAR:
1266  uRet = (UINT)IntVkToChar(uCode, pKbdTbl);
1267  break;
1268 
1269  case MAPVK_VSC_TO_VK_EX:
1270  uRet = IntVscToVk(uCode, pKbdTbl) & 0xFF;
1271  break;
1272 
1273  case MAPVK_VK_TO_VSC_EX:
1274  uRet = IntVkToVsc(uCode, pKbdTbl);
1275  break;
1276 
1277  default:
1279  ERR("Wrong type value: %u\n", Type);
1280  }
1281 
1282  return uRet;
1283 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static WORD FASTCALL IntVscToVk(WORD wScanCode, PKBDTABLES pKbdTbl)
Definition: keyboard.c:562
#define MAPVK_VSC_TO_VK_EX
Definition: winuser.h:2334
#define FALSE
Definition: types.h:117
static WORD FASTCALL IntVkToVsc(WORD wVk, PKBDTABLES pKbdTbl)
Definition: keyboard.c:525
#define MAPVK_VSC_TO_VK
Definition: winuser.h:2332
#define MAPVK_VK_TO_VSC
Definition: winuser.h:2331
#define MAPVK_VK_TO_VSC_EX
Definition: winuser.h:2335
Type
Definition: Type.h:6
#define MAPVK_VK_TO_CHAR
Definition: winuser.h:2333
static WORD IntSimplifyVk(WORD wVk)
Definition: keyboard.c:219
#define ERR(fmt,...)
Definition: debug.h:110
static WORD IntFixVk(WORD wVk, BOOL bExt)
Definition: keyboard.c:247
unsigned int UINT
Definition: ndis.h:50
static WCHAR FASTCALL IntVkToChar(WORD wVk, PKBDTABLES pKbdTbl)
Definition: keyboard.c:605
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by NtUserMapVirtualKeyEx().

◆ IntSimplifyVk()

static WORD IntSimplifyVk ( WORD  wVk)
static

Definition at line 219 of file keyboard.c.

220 {
221  switch (wVk)
222  {
223  case VK_LSHIFT:
224  case VK_RSHIFT:
225  return VK_SHIFT;
226 
227  case VK_LCONTROL:
228  case VK_RCONTROL:
229  return VK_CONTROL;
230 
231  case VK_LMENU:
232  case VK_RMENU:
233  return VK_MENU;
234 
235  default:
236  return wVk;
237  }
238 }
#define VK_RMENU
Definition: winuser.h:2263
#define VK_LSHIFT
Definition: winuser.h:2258
#define VK_MENU
Definition: winuser.h:2180
#define VK_SHIFT
Definition: winuser.h:2178
#define VK_RCONTROL
Definition: winuser.h:2261
#define VK_LMENU
Definition: winuser.h:2262
#define VK_RSHIFT
Definition: winuser.h:2259
#define VK_CONTROL
Definition: winuser.h:2179
#define VK_LCONTROL
Definition: winuser.h:2260

Referenced by IntMapVirtualKeyEx(), and ProcessKeyEvent().

◆ IntToUnicodeEx()

static int APIENTRY IntToUnicodeEx ( UINT  wVirtKey,
UINT  wScanCode,
PBYTE  pKeyState,
LPWSTR  pwszBuff,
int  cchBuff,
UINT  wFlags,
PKBDTABLES  pKbdTbl 
)
static

Definition at line 432 of file keyboard.c.

439 {
440  WCHAR wchTranslatedChar;
441  BOOL bDead, bLigature;
442  static WCHAR wchDead = 0;
443  int iRet = 0;
444 
445  ASSERT(pKbdTbl);
446 
447  if (!IntTranslateChar(wVirtKey,
448  pKeyState,
449  &bDead,
450  &bLigature,
451  &wchTranslatedChar,
452  pKbdTbl))
453  {
454  return 0;
455  }
456 
457  if (bLigature)
458  {
459  WARN("Not handling ligature (yet)\n" );
460  return 0;
461  }
462 
463  /* If we got dead char in previous call check dead keys in keyboard layout */
464  if (wchDead)
465  {
466  UINT i;
467  WCHAR wchFirst, wchSecond;
468  TRACE("Previous dead char: %lc (%x)\n", wchDead, wchDead);
469 
470  if (pKbdTbl->pDeadKey)
471  {
472  for (i = 0; pKbdTbl->pDeadKey[i].dwBoth; i++)
473  {
474  wchFirst = pKbdTbl->pDeadKey[i].dwBoth >> 16;
475  wchSecond = pKbdTbl->pDeadKey[i].dwBoth & 0xFFFF;
476  if (wchFirst == wchDead && wchSecond == wchTranslatedChar)
477  {
478  wchTranslatedChar = pKbdTbl->pDeadKey[i].wchComposed;
479  wchDead = 0;
480  bDead = FALSE;
481  break;
482  }
483  }
484  }
485  else
486  {
487 #if defined(__GNUC__)
488  if (wchDead == 0x8000)
489  {
490  ERR("GCC is inventing bits, ignoring fake dead key\n");
491  wchDead = 0;
492  }
493 #endif
494  }
495 
496  TRACE("Final char: %lc (%x)\n", wchTranslatedChar, wchTranslatedChar);
497  }
498 
499  /* Dead char has not been not found */
500  if (wchDead)
501  {
502  /* Treat both characters normally */
503  if (cchBuff > iRet)
504  pwszBuff[iRet++] = wchDead;
505  bDead = FALSE;
506  }
507 
508  /* Add character to the buffer */
509  if (cchBuff > iRet)
510  pwszBuff[iRet++] = wchTranslatedChar;
511 
512  /* Save dead character */
513  wchDead = bDead ? wchTranslatedChar : 0;
514 
515  return bDead ? -iRet : iRet;
516 }
WCHAR wchComposed
Definition: kbd.h:58
#define WARN(fmt,...)
Definition: debug.h:112
static BOOL IntTranslateChar(WORD wVirtKey, PBYTE pKeyState, PBOOL pbDead, PBOOL pbLigature, PWCHAR pwcTranslatedChar, PKBDTABLES pKbdTbl)
Definition: keyboard.c:320
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PDEADKEY pDeadKey
Definition: kbd.h:98
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ERR(fmt,...)
Definition: debug.h:110
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD dwBoth
Definition: kbd.h:57
unsigned int UINT
Definition: ndis.h:50

Referenced by IntTranslateKbdMessage(), and NtUserToUnicodeEx().

◆ IntTranslateChar()

static BOOL IntTranslateChar ( WORD  wVirtKey,
PBYTE  pKeyState,
PBOOL  pbDead,
PBOOL  pbLigature,
PWCHAR  pwcTranslatedChar,
PKBDTABLES  pKbdTbl 
)
static

Definition at line 320 of file keyboard.c.

326 {
327  PVK_TO_WCHAR_TABLE pVkToVchTbl;
328  PVK_TO_WCHARS10 pVkToVch;
329  DWORD i, dwModBits, dwVkModBits, dwModNumber = 0;
330  WCHAR wch;
331  BOOL bAltGr;
332  WORD wCaplokAttr;
333 
334  dwModBits = pKeyState ? IntGetModBits(pKbdTbl, pKeyState) : 0;
335  bAltGr = pKeyState && (pKbdTbl->fLocaleFlags & KLLF_ALTGR) && IS_KEY_DOWN(pKeyState, VK_RMENU);
336  wCaplokAttr = bAltGr ? CAPLOKALTGR : CAPLOK;
337 
338  TRACE("TryToTranslate: %04x %x\n", wVirtKey, dwModBits);
339 
340  /* If ALT without CTRL has ben used, remove ALT flag */
341  if ((dwModBits & (KBDALT|KBDCTRL)) == KBDALT)
342  dwModBits &= ~KBDALT;
343 
344  if (dwModBits > pKbdTbl->pCharModifiers->wMaxModBits)
345  {
346  TRACE("dwModBits %x > wMaxModBits %x\n", dwModBits, pKbdTbl->pCharModifiers->wMaxModBits);
347  return FALSE;
348  }
349 
350  for (i = 0; pKbdTbl->pVkToWcharTable[i].pVkToWchars; i++)
351  {
352  pVkToVchTbl = &pKbdTbl->pVkToWcharTable[i];
353  pVkToVch = (PVK_TO_WCHARS10)(pVkToVchTbl->pVkToWchars);
354  while (pVkToVch->VirtualKey)
355  {
356  if (wVirtKey == (pVkToVch->VirtualKey & 0xFF))
357  {
358  dwVkModBits = dwModBits;
359 
360  /* If CapsLock is enabled for this key and locked, add SHIFT bit */
361  if ((pVkToVch->Attributes & wCaplokAttr) &&
362  pKeyState &&
363  IS_KEY_LOCKED(pKeyState, VK_CAPITAL))
364  {
365  /* Note: we use special value here instead of getting VK_SHIFT mod bit - it's verified */
366  dwVkModBits ^= KBDSHIFT;
367  }
368 
369  if (dwVkModBits > pKbdTbl->pCharModifiers->wMaxModBits)
370  break;
371 
372  /* Get modification number */
373  dwModNumber = pKbdTbl->pCharModifiers->ModNumber[dwVkModBits];
374  if (dwModNumber >= pVkToVchTbl->nModifications)
375  {
376  TRACE("dwModNumber %u >= nModifications %u\n", dwModNumber, pVkToVchTbl->nModifications);
377  break;
378  }
379 
380  /* Read character */
381  wch = pVkToVch->wch[dwModNumber];
382  if (wch == WCH_NONE)
383  break;
384 
385  *pbDead = (wch == WCH_DEAD);
386  *pbLigature = (wch == WCH_LGTR);
387  *pwcTranslatedChar = wch;
388 
389  TRACE("%lu %04x: dwModNumber %08x Char %04x\n",
390  i, wVirtKey, dwModNumber, wch);
391 
392  if (*pbDead)
393  {
394  /* After WCH_DEAD, real character is located */
395  pVkToVch = (PVK_TO_WCHARS10)(((BYTE *)pVkToVch) + pVkToVchTbl->cbSize);
396  if (pVkToVch->VirtualKey != 0xFF)
397  {
398  WARN("Found dead key with no trailer in the table.\n");
399  WARN("VK: %04x, ADDR: %p\n", wVirtKey, pVkToVch);
400  break;
401  }
402  *pwcTranslatedChar = pVkToVch->wch[dwModNumber];
403  }
404  return TRUE;
405  }
406  pVkToVch = (PVK_TO_WCHARS10)(((BYTE *)pVkToVch) + pVkToVchTbl->cbSize);
407  }
408  }
409 
410  /* If nothing has been found in layout, check if this is ASCII control character.
411  Note: we could add it to layout table, but windows does not have it there */
412  if (wVirtKey >= 'A' && wVirtKey <= 'Z' &&
413  pKeyState && IS_KEY_DOWN(pKeyState, VK_CONTROL) &&
414  !IS_KEY_DOWN(pKeyState, VK_MENU))
415  {
416  *pwcTranslatedChar = (wVirtKey - 'A') + 1; /* ASCII control character */
417  *pbDead = FALSE;
418  *pbLigature = FALSE;
419  return TRUE;
420  }
421 
422  return FALSE;
423 }
PVK_TO_WCHARS1 pVkToWchars
Definition: kbd.h:51
#define KBDCTRL
Definition: kbd.h:15
#define TRUE
Definition: types.h:120
#define VK_RMENU
Definition: winuser.h:2263
#define WARN(fmt,...)
Definition: debug.h:112
#define KBDSHIFT
Definition: kbd.h:14
#define VK_MENU
Definition: winuser.h:2180
DWORD fLocaleFlags
Definition: kbd.h:106
#define CAPLOK
Definition: kbd.h:118
#define WCH_NONE
Definition: kbd.h:113
#define KLLF_ALTGR
Definition: kbd.h:91
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CAPLOKALTGR
Definition: kbd.h:120
#define IS_KEY_LOCKED(ks, vk)
Definition: input.h:99
BYTE nModifications
Definition: kbd.h:52
PVK_TO_WCHAR_TABLE pVkToWcharTable
Definition: kbd.h:97
static DWORD IntGetModBits(PKBDTABLES pKbdTbl, PBYTE pKeyState)
Definition: keyboard.c:298
#define TRACE(s)
Definition: solgame.cpp:4
BYTE ModNumber[]
Definition: kbd.h:29
__wchar_t WCHAR
Definition: xmlstorage.h:180
WORD wMaxModBits
Definition: kbd.h:28
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE cbSize
Definition: kbd.h:53
unsigned char BYTE
Definition: xxhash.c:193
#define WCH_LGTR
Definition: kbd.h:115
#define KBDALT
Definition: kbd.h:16
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define VK_CAPITAL
Definition: winuser.h:2182
PMODIFIERS pCharModifiers
Definition: kbd.h:96
#define WCH_DEAD
Definition: kbd.h:114
#define VK_CONTROL
Definition: winuser.h:2179
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98

Referenced by IntToUnicodeEx(), and IntVkToChar().

◆ IntTranslateKbdMessage()

BOOL FASTCALL IntTranslateKbdMessage ( LPMSG  lpMsg,
UINT  flags 
)

Definition at line 1139 of file keyboard.c.

1141 {
1142  PTHREADINFO pti;
1143  INT cch = 0, i;
1144  WCHAR wch[3] = { 0 };
1145  MSG NewMsg = { 0 };
1146  PKBDTABLES pKbdTbl;
1147  BOOL bResult = FALSE;
1148 
1149  switch(lpMsg->message)
1150  {
1151  case WM_KEYDOWN:
1152  case WM_KEYUP:
1153  case WM_SYSKEYDOWN:
1154  case WM_SYSKEYUP:
1155  break;
1156  default:
1157  return FALSE;
1158  }
1159 
1161 
1162  if (!pti->KeyboardLayout)
1163  {
1165  pti->pClientInfo->hKL = pti->KeyboardLayout ? pti->KeyboardLayout->hkl : NULL;
1166  pKbdTbl = pti->KeyboardLayout ? pti->KeyboardLayout->spkf->pKbdTbl : NULL;
1167  }
1168  else
1169  pKbdTbl = pti->KeyboardLayout->spkf->pKbdTbl;
1170  if (!pKbdTbl)
1171  return FALSE;
1172 
1173  if (lpMsg->message != WM_KEYDOWN && lpMsg->message != WM_SYSKEYDOWN)
1174  return FALSE;
1175 
1176  /* Init pt, hwnd and time msg fields */
1177  NewMsg.pt = gpsi->ptCursor;
1178  NewMsg.hwnd = lpMsg->hwnd;
1179  NewMsg.time = EngGetTickCount32();
1180 
1181  TRACE("Enter IntTranslateKbdMessage msg %s, vk %x\n",
1182  lpMsg->message == WM_SYSKEYDOWN ? "WM_SYSKEYDOWN" : "WM_KEYDOWN", lpMsg->wParam);
1183 
1184  if (lpMsg->wParam == VK_PACKET)
1185  {
1186  NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
1187  NewMsg.wParam = HIWORD(lpMsg->lParam);
1188  NewMsg.lParam = LOWORD(lpMsg->lParam);
1189  MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0, 0);
1190  return TRUE;
1191  }
1192 
1193  cch = IntToUnicodeEx(lpMsg->wParam,
1194  HIWORD(lpMsg->lParam) & 0xFF,
1195  pti->MessageQueue->afKeyState,
1196  wch,
1197  sizeof(wch) / sizeof(wch[0]),
1198  0,
1199  pKbdTbl);
1200 
1201  if (cch)
1202  {
1203  if (cch > 0) /* Normal characters */
1204  NewMsg.message = (lpMsg->message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
1205  else /* Dead character */
1206  {
1207  cch = -cch;
1208  NewMsg.message =
1209  (lpMsg->message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
1210  }
1211  NewMsg.lParam = lpMsg->lParam;
1212 
1213  /* Send all characters */
1214  for (i = 0; i < cch; ++i)
1215  {
1216  TRACE("Msg: %x '%lc' (%04x) %08x\n", NewMsg.message, wch[i], wch[i], NewMsg.lParam);
1217  NewMsg.wParam = wch[i];
1218  MsqPostMessage(pti, &NewMsg, FALSE, QS_KEY, 0, 0);
1219  }
1220  bResult = TRUE;
1221  }
1222 
1223  TRACE("Leave IntTranslateKbdMessage ret %d, cch %d, msg %x, wch %x\n",
1224  bResult, cch, NewMsg.message, NewMsg.wParam);
1225  return bResult;
1226 }
#define WM_CHAR
Definition: winuser.h:1700
#define TRUE
Definition: types.h:120
#define EngGetTickCount32()
Definition: eng.h:43
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
WPARAM wParam
Definition: winuser.h:3092
PSERVERINFO gpsi
Definition: main.c:27
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_SYSCHAR
Definition: winuser.h:1704
#define WM_KEYDOWN
Definition: winuser.h:1698
LPARAM lParam
Definition: winuser.h:3093
#define WM_DEADCHAR
Definition: winuser.h:1701
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: kbd.h:95
#define WM_KEYUP
Definition: winuser.h:1699
static int APIENTRY IntToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE pKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, PKBDTABLES pKbdTbl)
Definition: keyboard.c:432
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1338
struct _CLIENTINFO * pClientInfo
Definition: win32.h:95
struct tagKL * KeyboardLayout
Definition: win32.h:91
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:90
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WM_SYSDEADCHAR
Definition: winuser.h:1705
#define WM_SYSKEYUP
Definition: winuser.h:1703
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:396
#define NULL
Definition: types.h:112
HWND hwnd
Definition: winuser.h:3090
#define WM_SYSKEYDOWN
Definition: winuser.h:1702
#define HIWORD(l)
Definition: typedefs.h:247
IN PCTCH IN DWORD cch
Definition: pager.h:36
#define QS_KEY
Definition: winuser.h:883
UINT message
Definition: winuser.h:3091
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DefWndDoSizeMove(), DefWndStartSizeMove(), MENU_TrackMenu(), and NtUserTranslateMessage().

◆ IntTranslateNumpadKey()

static WORD IntTranslateNumpadKey ( WORD  wVk)
static

Definition at line 272 of file keyboard.c.

273 {
274  switch (wVk)
275  {
276  case VK_INSERT: return VK_NUMPAD0;
277  case VK_END: return VK_NUMPAD1;
278  case VK_DOWN: return VK_NUMPAD2;
279  case VK_NEXT: return VK_NUMPAD3;
280  case VK_LEFT: return VK_NUMPAD4;
281  case VK_CLEAR: return VK_NUMPAD5;
282  case VK_RIGHT: return VK_NUMPAD6;
283  case VK_HOME: return VK_NUMPAD7;
284  case VK_UP: return VK_NUMPAD8;
285  case VK_PRIOR: return VK_NUMPAD9;
286  case VK_DELETE: return VK_DECIMAL;
287  default: return wVk;
288  }
289 }
#define VK_NUMPAD8
Definition: winuser.h:2223
#define VK_NUMPAD0
Definition: winuser.h:2215
#define VK_NUMPAD6
Definition: winuser.h:2221
#define VK_NUMPAD5
Definition: winuser.h:2220
#define VK_LEFT
Definition: winuser.h:2200
#define VK_DOWN
Definition: winuser.h:2203
#define VK_INSERT
Definition: winuser.h:2208
#define VK_DECIMAL
Definition: winuser.h:2229
#define VK_PRIOR
Definition: winuser.h:2196
#define VK_NUMPAD9
Definition: winuser.h:2224
#define VK_NEXT
Definition: winuser.h:2197
#define VK_HOME
Definition: winuser.h:2199
#define VK_UP
Definition: winuser.h:2201
#define VK_NUMPAD3
Definition: winuser.h:2218
#define VK_DELETE
Definition: winuser.h:2209
#define VK_NUMPAD4
Definition: winuser.h:2219
#define VK_RIGHT
Definition: winuser.h:2202
#define VK_NUMPAD7
Definition: winuser.h:2222
#define VK_NUMPAD2
Definition: winuser.h:2217
#define VK_CLEAR
Definition: winuser.h:2176
#define VK_NUMPAD1
Definition: winuser.h:2216
#define VK_END
Definition: winuser.h:2198

Referenced by UserProcessKeyboardInput().

◆ IntVkToChar()

static WCHAR FASTCALL IntVkToChar ( WORD  wVk,
PKBDTABLES  pKbdTbl 
)
static

Definition at line 605 of file keyboard.c.

606 {
607  WCHAR wch;
608  BOOL bDead, bLigature;
609 
610  ASSERT(pKbdTbl);
611 
612  if (IntTranslateChar(wVk,
613  NULL,
614  &bDead,
615  &bLigature,
616  &wch,
617  pKbdTbl))
618  {
619  return wch;
620  }
621 
622  return 0;
623 }
static BOOL IntTranslateChar(WORD wVirtKey, PBYTE pKeyState, PBOOL pbDead, PBOOL pbLigature, PWCHAR pwcTranslatedChar, PKBDTABLES pKbdTbl)
Definition: keyboard.c:320
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NULL
Definition: types.h:112

Referenced by IntMapVirtualKeyEx(), and NtUserGetKeyNameText().

◆ IntVkToVsc()

static WORD FASTCALL IntVkToVsc ( WORD  wVk,
PKBDTABLES  pKbdTbl 
)
static

Definition at line 525 of file keyboard.c.

526 {
527  unsigned i;
528 
529  ASSERT(pKbdTbl);
530 
531  /* Check standard keys first */
532  for (i = 0; i < pKbdTbl->bMaxVSCtoVK; i++)
533  {
534  if ((pKbdTbl->pusVSCtoVK[i] & 0xFF) == wVk)
535  return i;
536  }
537 
538  /* Check extended keys now */
539  for (i = 0; pKbdTbl->pVSCtoVK_E0[i].Vsc; i++)
540  {
541  if ((pKbdTbl->pVSCtoVK_E0[i].Vk & 0xFF) == wVk)
542  return 0xE000 | pKbdTbl->pVSCtoVK_E0[i].Vsc;
543  }
544 
545  for (i = 0; pKbdTbl->pVSCtoVK_E1[i].Vsc; i++)
546  {
547  if ((pKbdTbl->pVSCtoVK_E1[i].Vk & 0xFF) == wVk)
548  return 0xE100 | pKbdTbl->pVSCtoVK_E1[i].Vsc;
549  }
550 
551  /* Virtual key has not been found */
552  return 0;
553 }
BYTE Vsc
Definition: kbd.h:72
PVSC_VK pVSCtoVK_E0
Definition: kbd.h:104
USHORT Vk
Definition: kbd.h:73
#define ASSERT(a)
Definition: mode.c:44
USHORT * pusVSCtoVK
Definition: kbd.h:102
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BYTE bMaxVSCtoVK
Definition: kbd.h:103
PVSC_VK pVSCtoVK_E1
Definition: kbd.h:105

Referenced by IntMapVirtualKeyEx().

◆ IntVscToVk()

static WORD FASTCALL IntVscToVk ( WORD  wScanCode,
PKBDTABLES  pKbdTbl 
)
static

Definition at line 562 of file keyboard.c.

563 {
564  unsigned i;
565  WORD wVk = 0;
566 
567  ASSERT(pKbdTbl);
568 
569  if ((wScanCode & 0xFF00) == 0xE000)
570  {
571  for (i = 0; pKbdTbl->pVSCtoVK_E0[i].Vsc; i++)
572  {
573  if (pKbdTbl->pVSCtoVK_E0[i].Vsc == (wScanCode & 0xFF))
574  {
575  wVk = pKbdTbl->pVSCtoVK_E0[i].Vk;
576  }
577  }
578  }
579  else if ((wScanCode & 0xFF00) == 0xE100)
580  {
581  for (i = 0; pKbdTbl->pVSCtoVK_E1[i].Vsc; i++)
582  {
583  if (pKbdTbl->pVSCtoVK_E1[i].Vsc == (wScanCode & 0xFF))
584  {
585  wVk = pKbdTbl->pVSCtoVK_E1[i].Vk;
586  }
587  }
588  }
589  else if (wScanCode < pKbdTbl->bMaxVSCtoVK)
590  {
591  wVk = pKbdTbl->pusVSCtoVK[wScanCode];
592  }
593 
594  /* 0xFF nad 0x00 are invalid VKs */
595  return wVk != 0xFF ? wVk : 0;
596 }
BYTE Vsc
Definition: kbd.h:72
PVSC_VK pVSCtoVK_E0
Definition: kbd.h:104
USHORT Vk
Definition: kbd.h:73
#define ASSERT(a)
Definition: mode.c:44
unsigned short WORD
Definition: ntddk_ex.h:93
USHORT * pusVSCtoVK
Definition: kbd.h:102
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PVSC_VK pVSCtoVK_E1
Definition: kbd.h:105

Referenced by IntMapVirtualKeyEx(), NtUserGetKeyNameText(), UserProcessKeyboardInput(), and UserSendKeyboardInput().

◆ NtUserGetAsyncKeyState()

SHORT APIENTRY NtUserGetAsyncKeyState ( INT  Key)

Definition at line 632 of file keyboard.c.

633 {
634  WORD wRet = 0;
635 
636  TRACE("Enter NtUserGetAsyncKeyState\n");
637 
638  if (Key >= 0x100)
639  {
641  ERR("Invalid parameter Key\n");
642  return 0;
643  }
644 
646 
648  wRet |= 0x8000; // If down, windows returns 0x8000.
649  if (gafAsyncKeyStateRecentDown[Key / 8] & (1 << (Key % 8)))
650  wRet |= 0x1;
651  gafAsyncKeyStateRecentDown[Key / 8] &= ~(1 << (Key % 8));
652 
653  UserLeave();
654 
655  TRACE("Leave NtUserGetAsyncKeyState, ret=%u\n", wRet);
656  return wRet;
657 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short WORD
Definition: ntddk_ex.h:93
static BYTE gafAsyncKeyStateRecentDown[256/8]
Definition: keyboard.c:14
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by GetAsyncKeyState().

◆ NtUserGetKeyNameText()

DWORD APIENTRY NtUserGetKeyNameText ( LONG  lParam,
LPWSTR  lpString,
int  cchSize 
)

Definition at line 1438 of file keyboard.c.

1439 {
1440  PTHREADINFO pti;
1441  DWORD i, dwRet = 0;
1442  SIZE_T cchKeyName;
1443  WORD wScanCode = (lParam >> 16) & 0xFF;
1444  BOOL bExtKey = (HIWORD(lParam) & KF_EXTENDED) ? TRUE : FALSE;
1445  PKBDTABLES pKbdTbl;
1446  VSC_LPWSTR *pKeyNames = NULL;
1447  CONST WCHAR *pKeyName = NULL;
1448  WCHAR KeyNameBuf[2];
1449 
1450  TRACE("Enter NtUserGetKeyNameText\n");
1451 
1452  UserEnterShared();
1453 
1454  /* Get current keyboard layout */
1456  pKbdTbl = pti ? pti->KeyboardLayout->spkf->pKbdTbl : 0;
1457 
1458  if (!pKbdTbl || cchSize < 1)
1459  {
1460  ERR("Invalid parameter\n");
1461  goto cleanup;
1462  }
1463 
1464  /* "Do not care" flag */
1466  {
1467  /* Note: We could do vsc -> vk -> vsc conversion, instead of using
1468  hardcoded scan codes, but it's not what Windows does */
1469  if (wScanCode == SCANCODE_RSHIFT && !bExtKey)
1470  wScanCode = SCANCODE_LSHIFT;
1471  else if (wScanCode == SCANCODE_CTRL || wScanCode == SCANCODE_ALT)
1472  bExtKey = FALSE;
1473  }
1474 
1475  if (bExtKey)
1476  pKeyNames = pKbdTbl->pKeyNamesExt;
1477  else
1478  pKeyNames = pKbdTbl->pKeyNames;
1479 
1480  for (i = 0; pKeyNames[i].pwsz; i++)
1481  {
1482  if (pKeyNames[i].vsc == wScanCode)
1483  {
1484  pKeyName = pKeyNames[i].pwsz;
1485  break;
1486  }
1487  }
1488 
1489  if (!pKeyName)
1490  {
1491  WORD wVk = IntVscToVk(wScanCode, pKbdTbl);
1492 
1493  if (wVk)
1494  {
1495  KeyNameBuf[0] = IntVkToChar(wVk, pKbdTbl);
1496  KeyNameBuf[1] = 0;
1497  if (KeyNameBuf[0])
1498  pKeyName = KeyNameBuf;
1499  }
1500  }
1501 
1502  if (pKeyName)
1503  {
1504  cchKeyName = wcslen(pKeyName);
1505  if (cchKeyName > (cchSize - 1UL))
1506  cchKeyName = cchSize - 1UL; // Don't count '\0'
1507 
1508  _SEH2_TRY
1509  {
1510  ProbeForWrite(lpString, (cchKeyName + 1) * sizeof(WCHAR), 1);
1511  RtlCopyMemory(lpString, pKeyName, cchKeyName * sizeof(WCHAR));
1512  lpString[cchKeyName] = UNICODE_NULL;
1513  dwRet = cchKeyName;
1514  }
1516  {
1518  }
1519  _SEH2_END;
1520  }
1521  else
1522  {
1524  }
1525 
1526 cleanup:
1527  UserLeave();
1528  TRACE("Leave NtUserGetKeyNameText, ret=%lu\n", dwRet);
1529  return dwRet;
1530 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
VSC_LPWSTR * pKeyNamesExt
Definition: kbd.h:100
#define TRUE
Definition: types.h:120
#define SCANCODE_RSHIFT
Definition: kbd.h:129
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
static WORD FASTCALL IntVscToVk(WORD wScanCode, PKBDTABLES pKbdTbl)
Definition: keyboard.c:562
#define SCANCODE_ALT
Definition: kbd.h:131
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define SCANCODE_LSHIFT
Definition: kbd.h:128
_SEH2_TRY
Definition: create.c:4226
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR pwsz
Definition: kbd.h:68
#define KF_EXTENDED
Definition: winuser.h:2422
VSC_LPWSTR * pKeyNames
Definition: kbd.h:99
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
Definition: kbd.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
struct tagKL * KeyboardLayout
Definition: win32.h:91
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_SEH2_END
Definition: create.c:4400
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
static WCHAR FASTCALL IntVkToChar(WORD wVk, PKBDTABLES pKbdTbl)
Definition: keyboard.c:605
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HIWORD(l)
Definition: typedefs.h:247
char * cleanup(char *str)
Definition: wpickclick.c:99
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define LP_DO_NOT_CARE_BIT
Definition: input.h:59
#define UL
Definition: tui.h:82
LPARAM lParam
Definition: combotst.c:139
#define CONST
Definition: pedump.c:81
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define SCANCODE_CTRL
Definition: kbd.h:130

Referenced by GetKeyNameTextA(), and GetKeyNameTextW().

◆ NtUserMapVirtualKeyEx()

UINT APIENTRY NtUserMapVirtualKeyEx ( UINT  uCode,
UINT  uType,
DWORD  keyboardId,
HKL  dwhkl 
)

Definition at line 1293 of file keyboard.c.

1294 {
1295  PKBDTABLES pKbdTbl = NULL;
1296  UINT ret = 0;
1297 
1298  TRACE("Enter NtUserMapVirtualKeyEx\n");
1299  UserEnterShared();
1300 
1301  if (!dwhkl)
1302  {
1303  PTHREADINFO pti;
1304 
1306  if (pti && pti->KeyboardLayout)
1307  pKbdTbl = pti->KeyboardLayout->spkf->pKbdTbl;
1308  }
1309  else
1310  {
1311  PKL pKl;
1312 
1313  pKl = UserHklToKbl(dwhkl);
1314  if (pKl)
1315  pKbdTbl = pKl->spkf->pKbdTbl;
1316  }
1317 
1318  if (pKbdTbl)
1319  ret = IntMapVirtualKeyEx(uCode, uType, pKbdTbl);
1320 
1321  UserLeave();
1322  TRACE("Leave NtUserMapVirtualKeyEx, ret=%u\n", ret);
1323  return ret;
1324 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
Definition: input.h:26
#define TRACE(s)
Definition: solgame.cpp:4
Definition: kbd.h:95
int ret
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
struct tagKL * KeyboardLayout
Definition: win32.h:91
static UINT IntMapVirtualKeyEx(UINT uCode, UINT Type, PKBDTABLES pKbdTbl)
Definition: keyboard.c:1247
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
PKBDFILE spkf
Definition: input.h:33
PKL NTAPI UserHklToKbl(HKL hKl)
Definition: kbdlayout.c:423

Referenced by MapVirtualKeyExW().

◆ NtUserToUnicodeEx()

int APIENTRY NtUserToUnicodeEx ( UINT  wVirtKey,
UINT  wScanCode,
PBYTE  pKeyStateUnsafe,
LPWSTR  pwszBuffUnsafe,
INT  cchBuff,
UINT  wFlags,
HKL  dwhkl 
)

Definition at line 1333 of file keyboard.c.

1341 {
1342  PTHREADINFO pti;
1343  BYTE afKeyState[256 * 2 / 8] = {0};
1344  PWCHAR pwszBuff = NULL;
1345  INT i, iRet = 0;
1346  PKL pKl = NULL;
1348 
1349  TRACE("Enter NtUserSetKeyboardState\n");
1350 
1351  /* Return 0 if SC_KEY_UP bit is set */
1352  if (wScanCode & SC_KEY_UP || wVirtKey >= 0x100)
1353  {
1354  ERR("Invalid parameter\n");
1355  return 0;
1356  }
1357 
1358  _SEH2_TRY
1359  {
1360  /* Probe and copy key state to smaller bitmap */
1361  ProbeForRead(pKeyStateUnsafe, 256 * sizeof(BYTE), 1);
1362  for (i = 0; i < 256; ++i)
1363  {
1364  if (pKeyStateUnsafe[i] & KS_DOWN_BIT)
1365  SET_KEY_DOWN(afKeyState, i, TRUE);
1366  if (pKeyStateUnsafe[i] & KS_LOCK_BIT)
1367  SET_KEY_LOCKED(afKeyState, i, TRUE);
1368  }
1369  }
1371  {
1372  ERR("Cannot copy key state\n");
1374  _SEH2_YIELD(return 0);
1375  }
1376  _SEH2_END;
1377 
1378  pwszBuff = ExAllocatePoolWithTag(NonPagedPool, sizeof(WCHAR) * cchBuff, TAG_STRING);
1379  if (!pwszBuff)
1380  {
1381  ERR("ExAllocatePoolWithTag(%u) failed\n", sizeof(WCHAR) * cchBuff);
1382  return 0;
1383  }
1384  RtlZeroMemory(pwszBuff, sizeof(WCHAR) * cchBuff);
1385 
1386  UserEnterExclusive(); // Note: We modify wchDead static variable
1387 
1388  if (dwhkl)
1389  pKl = UserHklToKbl(dwhkl);
1390 
1391  if (!pKl)
1392  {
1394  pKl = pti->KeyboardLayout;
1395  }
1396 
1397  if (pKl)
1398  {
1399  iRet = IntToUnicodeEx(wVirtKey,
1400  wScanCode,
1401  afKeyState,
1402  pwszBuff,
1403  cchBuff,
1404  wFlags,
1405  pKl->spkf->pKbdTbl);
1406 
1407  if (iRet)
1408  {
1409  Status = MmCopyToCaller(pwszBuffUnsafe, pwszBuff, cchBuff * sizeof(WCHAR));
1410  }
1411  }
1412  else
1413  {
1414  ERR("No keyboard layout ?!\n");
1416  }
1417 
1418  ExFreePoolWithTag(pwszBuff, TAG_STRING);
1419 
1420  if (!NT_SUCCESS(Status))
1421  {
1422  iRet = 0;
1424  }
1425 
1426  UserLeave();
1427  TRACE("Leave NtUserSetKeyboardState, ret=%i\n", iRet);
1428  return iRet;
1429 }
#define TRUE
Definition: types.h:120
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
LONG NTSTATUS
Definition: precomp.h:26
#define KS_LOCK_BIT
Definition: input.h:55
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
uint16_t * PWCHAR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
_SEH2_TRY
Definition: create.c:4226
#define TAG_STRING
Definition: oslist.h:22
#define SET_KEY_DOWN(ks, vk, down)
Definition: input.h:100
Definition: input.h:26
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static int APIENTRY IntToUnicodeEx(UINT wVirtKey, UINT wScanCode, PBYTE pKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags, PKBDTABLES pKbdTbl)
Definition: keyboard.c:432
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
struct tagKL * KeyboardLayout
Definition: win32.h:91
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
unsigned char BYTE
Definition: xxhash.c:193
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define ERR(fmt,...)
Definition: debug.h:110
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
#define SC_KEY_UP
Definition: input.h:57
_SEH2_END
Definition: create.c:4400
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
PKBDFILE spkf
Definition: input.h:33
#define KS_DOWN_BIT
Definition: input.h:54
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define SET_KEY_LOCKED(ks, vk, down)
Definition: input.h:103
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PKL NTAPI UserHklToKbl(HKL hKl)
Definition: kbdlayout.c:423

◆ NtUserVkKeyScanEx()

DWORD APIENTRY NtUserVkKeyScanEx ( WCHAR  wch,
HKL  dwhkl,
BOOL  bUsehKL 
)

Definition at line 1563 of file keyboard.c.

1567 {
1568  PKBDTABLES pKbdTbl;
1569  PVK_TO_WCHAR_TABLE pVkToWchTbl;
1570  PVK_TO_WCHARS10 pVkToWch;
1571  PKL pKl = NULL;
1572  DWORD i, dwModBits = 0, dwModNumber = 0, Ret = (DWORD)-1;
1573 
1574  TRACE("NtUserVkKeyScanEx() wch %u, KbdLayout 0x%p\n", wch, dwhkl);
1575  UserEnterShared();
1576 
1577  if (bUsehKL)
1578  {
1579  // Use given keyboard layout
1580  if (dwhkl)
1581  pKl = UserHklToKbl(dwhkl);
1582  }
1583  else
1584  {
1585  // Use thread keyboard layout
1587  }
1588 
1589  if (!pKl)
1590  goto Exit;
1591 
1592  pKbdTbl = pKl->spkf->pKbdTbl;
1593 
1594  // Interate through all VkToWchar tables while pVkToWchars is not NULL
1595  for (i = 0; pKbdTbl->pVkToWcharTable[i].pVkToWchars; i++)
1596  {
1597  pVkToWchTbl = &pKbdTbl->pVkToWcharTable[i];
1598  pVkToWch = (PVK_TO_WCHARS10)(pVkToWchTbl->pVkToWchars);
1599 
1600  // Interate through all virtual keys
1601  while (pVkToWch->VirtualKey)
1602  {
1603  for (dwModNumber = 0; dwModNumber < pVkToWchTbl->nModifications; dwModNumber++)
1604  {
1605  if (pVkToWch->wch[dwModNumber] == wch)
1606  {
1607  dwModBits = pKbdTbl->pCharModifiers->ModNumber[dwModNumber];
1608  TRACE("i %lu wC %04x: dwModBits %08x dwModNumber %08x MaxModBits %08x\n",
1609  i, wch, dwModBits, dwModNumber, pKbdTbl->pCharModifiers->wMaxModBits);
1610  Ret = (dwModBits << 8) | (pVkToWch->VirtualKey & 0xFF);
1611  goto Exit;
1612  }
1613  }
1614  pVkToWch = (PVK_TO_WCHARS10)(((BYTE *)pVkToWch) + pVkToWchTbl->cbSize);
1615  }
1616  }
1617 Exit:
1618  UserLeave();
1619  return Ret;
1620 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:239
PVK_TO_WCHARS1 pVkToWchars
Definition: kbd.h:51
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
Definition: input.h:26
BYTE nModifications
Definition: kbd.h:52
PVK_TO_WCHAR_TABLE pVkToWcharTable
Definition: kbd.h:97
#define TRACE(s)
Definition: solgame.cpp:4
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
BYTE ModNumber[]
Definition: kbd.h:29
static void Exit(void)
Definition: sock.c:1331
WORD wMaxModBits
Definition: kbd.h:28
Definition: kbd.h:95
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE cbSize
Definition: kbd.h:53
struct _KBDTABLES * pKbdTbl
Definition: input.h:21
unsigned char BYTE
Definition: xxhash.c:193
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:253
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DWORD
Definition: keyboard.c:34
#define NULL
Definition: types.h:112
PMODIFIERS pCharModifiers
Definition: kbd.h:96
PKBDFILE spkf
Definition: input.h:33
KeyboardLayout
Definition: utils.h:36
PKL NTAPI UserHklToKbl(HKL hKl)
Definition: kbdlayout.c:423

Referenced by VkKeyScanExW(), and VkKeyScanW().

◆ ProcessKeyEvent()

BOOL NTAPI ProcessKeyEvent ( WORD  wVk,
WORD  wScanCode,
DWORD  dwFlags,
BOOL  bInjected,
DWORD  dwTime,
DWORD  dwExtraInfo 
)

Definition at line 800 of file keyboard.c.

801 {
802  WORD wSimpleVk = 0, wFixedVk, wVk2;
803  PUSER_MESSAGE_QUEUE pFocusQueue;
804  PTHREADINFO pti;
806  BOOL bIsDown = (dwFlags & KEYEVENTF_KEYUP) ? FALSE : TRUE;
807  BOOL bPacket = (dwFlags & KEYEVENTF_UNICODE) ? TRUE : FALSE;
808  BOOL bWasSimpleDown = FALSE, bPostMsg = TRUE, bIsSimpleDown;
809  MSG Msg;
810  static BOOL bMenuDownRecently = FALSE;
811 
812  /* Get virtual key without shifts (VK_(L|R)* -> VK_*) */
813  wSimpleVk = IntSimplifyVk(wVk);
814  bWasSimpleDown = IS_KEY_DOWN(gafAsyncKeyState, wSimpleVk);
815 
816  /* Update key without shifts */
817  wVk2 = IntFixVk(wSimpleVk, !bExt);
818  bIsSimpleDown = bIsDown || IS_KEY_DOWN(gafAsyncKeyState, wVk2);
819  UpdateAsyncKeyState(wSimpleVk, bIsSimpleDown);
820 
821  if (bIsDown)
822  {
823  /* Update keyboard LEDs */
825  wSimpleVk,
826  wScanCode);
827  }
828 
829  /* Call WH_KEYBOARD_LL hook */
830  if (co_CallLowLevelKeyboardHook(wVk, wScanCode, dwFlags, bInjected, dwTime, dwExtraInfo))
831  {
832  ERR("Kbd msg dropped by WH_KEYBOARD_LL hook\n");
833  bPostMsg = FALSE;
834  }
835 
836  /* Check if this is a hotkey */
837  if (co_UserProcessHotKeys(wSimpleVk, bIsDown))
838  {
839  TRACE("HotKey Processed\n");
840  bPostMsg = FALSE;
841  }
842 
843  wFixedVk = IntFixVk(wSimpleVk, bExt); /* LSHIFT + EXT = RSHIFT */
844  if (wSimpleVk == VK_SHIFT) /* shift can't be extended */
845  bExt = FALSE;
846 
847  /* If we have a focus queue, post a keyboard message */
848  pFocusQueue = IntGetFocusMessageQueue();
849  TRACE("ProcessKeyEvent Q 0x%p Active pWnd 0x%p Focus pWnd 0x%p\n",
850  pFocusQueue,
851  (pFocusQueue ? pFocusQueue->spwndActive : 0),
852  (pFocusQueue ? pFocusQueue->spwndFocus : 0));
853 
854  /* If it is F10 or ALT is down and CTRL is up, it's a system key */
855  if ( wVk == VK_F10 ||
856  (wSimpleVk == VK_MENU && bMenuDownRecently) ||
859  // See MSDN WM_SYSKEYDOWN/UP fixes last wine Win test_keyboard_input.
860  (pFocusQueue && !pFocusQueue->spwndFocus) )
861  {
862  bMenuDownRecently = FALSE; // reset
863  if (bIsDown)
864  {
865  Msg.message = WM_SYSKEYDOWN;
866  if (wSimpleVk == VK_MENU)
867  {
868  // Note: If only LALT is pressed WM_SYSKEYUP is generated instead of WM_KEYUP
869  bMenuDownRecently = TRUE;
870  }
871  }
872  else
873  Msg.message = WM_SYSKEYUP;
874  }
875  else
876  {
877  if (bIsDown)
878  Msg.message = WM_KEYDOWN;
879  else
880  Msg.message = WM_KEYUP;
881  }
882 
883  /* Update async state of not simplified vk here.
884  See user32_apitest:GetKeyState */
885  UpdateAsyncKeyState(wFixedVk, bIsDown);
886 
887  /* Alt-Tab/Esc Check. Use FocusQueue or RIT Queue */
888  if (bIsSimpleDown && !bWasSimpleDown &&
891  (wVk == VK_ESCAPE || wVk == VK_TAB))
892  {
893  TRACE("Alt-Tab/Esc Pressed wParam %x\n",wVk);
894  }
895 
896  if (bIsDown && wVk == VK_SNAPSHOT)
897  {
898  if (pFocusQueue &&
901  {
902  // Snap from Active Window, Focus can be null.
903  SnapWindow(pFocusQueue->spwndActive ? UserHMGetHandle(pFocusQueue->spwndActive) : 0);
904  }
905  else
906  SnapWindow(NULL); // Snap Desktop.
907  }
908  else if (pFocusQueue && bPostMsg)
909  {
910  PWND Wnd = pFocusQueue->spwndFocus; // SysInit.....
911 
912  pti = pFocusQueue->ptiKeyboard;
913 
914  if (!Wnd && pFocusQueue->spwndActive) // SysInit.....
915  {
916  // Going with Active. WM_SYSKEYXXX last wine Win test_keyboard_input.
917  Wnd = pFocusQueue->spwndActive;
918  }
919  if (Wnd) pti = Wnd->head.pti;
920 
921  /* Init message */
922  Msg.hwnd = Wnd ? UserHMGetHandle(Wnd) : NULL;
923  Msg.wParam = wFixedVk & 0xFF; /* Note: It's simplified by msg queue */
924  Msg.lParam = MAKELPARAM(1, wScanCode);
925  Msg.time = dwTime;
926  Msg.pt = gpsi->ptCursor;
927 
928  if ( Msg.message == WM_KEYDOWN || Msg.message == WM_SYSKEYDOWN )
929  {
930  if ( (Msg.wParam == VK_SHIFT ||
931  Msg.wParam == VK_CONTROL ||
932  Msg.wParam == VK_MENU ) &&
933  !IS_KEY_DOWN(gafAsyncKeyState, Msg.wParam))
934  {
935  ERR("Set last input\n");
936  //ptiLastInput = pti;
937  }
938  }
939 
940  /* If it is VK_PACKET, high word of wParam is used for wchar */
941  if (!bPacket)
942  {
943  if (bExt)
944  Msg.lParam |= KF_EXTENDED << 16;
946  Msg.lParam |= KF_ALTDOWN << 16;
947  if (bWasSimpleDown)
948  Msg.lParam |= KF_REPEAT << 16;
949  if (!bIsDown)
950  Msg.lParam |= KF_UP << 16;
951  /* FIXME: Set KF_DLGMODE and KF_MENUMODE when needed */
952  if (pFocusQueue->QF_flags & QF_DIALOGACTIVE)
953  Msg.lParam |= KF_DLGMODE << 16;
954  if (pFocusQueue->MenuOwner) // pti->pMenuState->fMenuStarted
955  Msg.lParam |= KF_MENUMODE << 16;
956  }
957 
958  // Post mouse move before posting key buttons, to keep it syned.
959  if (pFocusQueue->QF_flags & QF_MOUSEMOVED)
960  {
962  }
963 
964  /* Post a keyboard message */
965  TRACE("Posting keyboard msg %u wParam 0x%x lParam 0x%x\n", Msg.message, Msg.wParam, Msg.lParam);
966  if (!Wnd) {ERR("Window is NULL\n");}
967  MsqPostMessage(pti, &Msg, TRUE, QS_KEY, 0, dwExtraInfo);
968  }
969  return TRUE;
970 }
#define KF_MENUMODE
Definition: winuser.h:2424
BOOL NTAPI co_UserProcessHotKeys(WORD wVk, BOOL bIsDown)
Definition: hotkey.c:177
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define TRUE
Definition: types.h:120
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define MAKELPARAM(l, h)
Definition: winuser.h:3984
PTHREADINFO ptiKeyboard
Definition: msgqueue.h:56
#define KF_UP
Definition: winuser.h:2427
#define VK_TAB
Definition: winuser.h:2175
#define VK_MENU
Definition: winuser.h:2180
#define VK_ESCAPE
Definition: winuser.h:2190
#define QF_DIALOGACTIVE
Definition: msgqueue.h:106
#define KF_DLGMODE
Definition: winuser.h:2423
HANDLE ghKeyboardDevice
Definition: input.c:19
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1276
PSERVERINFO gpsi
Definition: main.c:27
static LRESULT co_CallLowLevelKeyboardHook(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD dwTime, DWORD dwExtraInfo)
Definition: keyboard.c:687
#define VK_F10
Definition: winuser.h:2240
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define VK_SHIFT
Definition: winuser.h:2178
THRDESKHEAD head
Definition: ntuser.h:665
#define WM_KEYDOWN
Definition: winuser.h:1698
#define KF_EXTENDED
Definition: winuser.h:2422
DWORD dwTime
Definition: solitaire.cpp:26
#define UserHMGetHandle(obj)
Definition: ntuser.h:213
#define KF_REPEAT
Definition: winuser.h:2426
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_KEYUP
Definition: winuser.h:1699
unsigned short WORD
Definition: ntddk_ex.h:93
static NTSTATUS APIENTRY IntKeyboardUpdateLeds(HANDLE hKeyboardDevice, WORD wVk, WORD wScanCode)
Definition: keyboard.c:107
VOID FASTCALL MsqPostMessage(PTHREADINFO pti, MSG *Msg, BOOLEAN HardwareMessage, DWORD MessageBits, DWORD dwQEvent, LONG_PTR ExtraInfo)
Definition: msgqueue.c:1338
VOID FASTCALL IntCoalesceMouseMove(PTHREADINFO pti)
Definition: msgqueue.c:551
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static VOID NTAPI UpdateAsyncKeyState(WORD wVk, BOOL bIsDown)
Definition: keyboard.c:666
static WORD IntSimplifyVk(WORD wVk)
Definition: keyboard.c:219
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:663
#define WM_SYSKEYUP
Definition: winuser.h:1703
static WORD IntFixVk(WORD wVk, BOOL bExt)
Definition: keyboard.c:247
#define NULL
Definition: types.h:112
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
#define KF_ALTDOWN
Definition: winuser.h:2425
#define VK_CONTROL
Definition: winuser.h:2179
struct @1587 Msg[]
#define WM_SYSKEYDOWN
Definition: winuser.h:1702
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
#define QS_KEY
Definition: winuser.h:883
#define QF_MOUSEMOVED
Definition: msgqueue.h:99
#define VK_SNAPSHOT
Definition: winuser.h:2207
static VOID SnapWindow(HWND hWnd)
Definition: keyboard.c:723

Referenced by UserSendKeyboardInput().

◆ SnapWindow()

static VOID SnapWindow ( HWND  hWnd)
static

Definition at line 723 of file keyboard.c.

724 {
725  HBITMAP hbm = NULL, hbmOld;
726  HDC hdc = NULL, hdcMem;
727  SETCLIPBDATA scd;
728  INT cx, cy;
729  PWND pWnd = NULL;
730 
731  TRACE("SnapWindow(%p)\n", hWnd);
732 
733  /* If no windows is given, make snapshot of desktop window */
734  if (!hWnd)
736 
737  pWnd = UserGetWindowObject(hWnd);
738  if (!pWnd)
739  {
740  ERR("Invalid window\n");
741  goto cleanup;
742  }
743 
745  if (!hdc)
746  {
747  ERR("UserGetDCEx failed!\n");
748  goto cleanup;
749  }
750 
751  cx = pWnd->rcWindow.right - pWnd->rcWindow.left;
752  cy = pWnd->rcWindow.bottom - pWnd->rcWindow.top;
753 
755  if (!hbm)
756  {
757  ERR("NtGdiCreateCompatibleBitmap failed!\n");
758  goto cleanup;
759  }
760 
762  if (!hdcMem)
763  {
764  ERR("NtGdiCreateCompatibleDC failed!\n");
765  goto cleanup;
766  }
767 
768  hbmOld = NtGdiSelectBitmap(hdcMem, hbm);
769  NtGdiBitBlt(hdcMem, 0, 0, cx, cy, hdc, 0, 0, SRCCOPY, 0, 0);
770  NtGdiSelectBitmap(hdcMem, hbmOld);
772 
773  /* Save snapshot in clipboard */
774  if (UserOpenClipboard(NULL))
775  {
777  scd.fIncSerialNumber = TRUE;
778  scd.fGlobalHandle = FALSE;
779  if (UserSetClipboardData(CF_BITMAP, hbm, &scd))
780  {
781  /* Bitmap is managed by system now */
782  hbm = NULL;
783  }
785  }
786 
787 cleanup:
788  if (hbm)
790  if (hdc)
791  UserReleaseDC(pWnd, hdc, FALSE);
792 }
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define TRUE
Definition: types.h:120
BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL)
Definition: dclife.c:892
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
LONG top
Definition: windef.h:307
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
LONG left
Definition: windef.h:306
BOOL NTAPI UserOpenClipboard(HWND hWnd)
Definition: clipboard.c:488
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
#define DCX_WINDOW
Definition: winuser.h:2096
#define FALSE
Definition: types.h:117
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:545
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:585
BOOL fGlobalHandle
Definition: ntuser.h:1126
#define CF_BITMAP
Definition: constants.h:397
__kernel_entry W32KAPI BOOL APIENTRY NtGdiBitBlt(_In_ HDC hdcDst, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_opt_ HDC hdcSrc, _In_ INT xSrc, _In_ INT ySrc, _In_ DWORD rop4, _In_ DWORD crBackColor, _In_ FLONG fl)
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:103
#define TRACE(s)
Definition: solgame.cpp:4
HDC hdc
Definition: main.c:9
RECT rcWindow
Definition: ntuser.h:686
__kernel_entry W32KAPI HDC APIENTRY NtGdiCreateCompatibleDC(_In_opt_ HDC hdc)
BOOL NTAPI UserEmptyClipboard(VOID)
Definition: clipboard.c:680
#define ERR(fmt,...)
Definition: debug.h:110
Definition: ntuser.h:663
HWND FASTCALL IntGetDesktopWindow(VOID)
Definition: desktop.c:1343
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
BOOL fIncSerialNumber
Definition: ntuser.h:1127
#define NULL
Definition: types.h:112
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:917
_Out_opt_ int * cx
Definition: commctrl.h:585
LONG bottom
Definition: windef.h:309
char * cleanup(char *str)
Definition: wpickclick.c:99
static HBITMAP
Definition: button.c:44
#define SRCCOPY
Definition: wingdi.h:333
HANDLE NTAPI UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
Definition: clipboard.c:1023
HDC hdcMem
Definition: welcome.c:104

Referenced by ProcessKeyEvent().

◆ UpdateAsyncKeyState()

static VOID NTAPI UpdateAsyncKeyState ( WORD  wVk,
BOOL  bIsDown 
)
static

Definition at line 666 of file keyboard.c.

667 {
668  if (bIsDown)
669  {
670  /* If it's first key down event, xor lock bit */
671  if (!IS_KEY_DOWN(gafAsyncKeyState, wVk))
673 
675  gafAsyncKeyStateRecentDown[wVk / 8] |= (1 << (wVk % 8));
676  }
677  else
679 }
#define TRUE
Definition: types.h:120
BYTE gafAsyncKeyState[256 *2/8]
Definition: keyboard.c:13
#define FALSE
Definition: types.h:117
#define SET_KEY_DOWN(ks, vk, down)
Definition: input.h:100
#define IS_KEY_LOCKED(ks, vk)
Definition: input.h:99
static BYTE gafAsyncKeyStateRecentDown[256/8]
Definition: keyboard.c:14
#define IS_KEY_DOWN(ks, vk)
Definition: input.h:98
#define SET_KEY_LOCKED(ks, vk, down)
Definition: input.h:103

Referenced by ProcessKeyEvent().

◆ UserGetKeyboardType()

DWORD FASTCALL UserGetKeyboardType ( DWORD  dwTypeFlag)

Definition at line 1538 of file keyboard.c.

1540 {
1541  switch (dwTypeFlag)
1542  {
1543  case 0: /* Keyboard type */
1545  case 1: /* Keyboard Subtype */
1547  case 2: /* Number of F-keys */
1549  default:
1550  ERR("Unknown type!\n");
1551  return 0; /* Note: we don't have to set last error here */
1552  }
1553 }
UCHAR Type
Definition: ntddkbd.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
KEYBOARD_ID KeyboardIdentifier
Definition: ntddkbd.h:124
UCHAR Subtype
Definition: ntddkbd.h:102
#define ERR(fmt,...)
Definition: debug.h:110
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
KEYBOARD_ATTRIBUTES gKeyboardInfo
Definition: keyboard.c:17

Referenced by NtUserCallOneParam().

◆ 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:112
LONG NTSTATUS
Definition: precomp.h:26
static KEYBOARD_INDICATOR_PARAMETERS gIndicators
Definition: keyboard.c:16
#define KEYBOARD_CAPS_LOCK_ON
Definition: ntddkbd.h:81
static PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans
Definition: keyboard.c:15
Status
Definition: gdiplustypes.h:24
#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
#define ERR(fmt,...)
Definition: debug.h:110
USHORT NumberOfFunctionKeys
Definition: ntddkbd.h:126
#define VK_SCROLL
Definition: winuser.h:2256
#define VK_NUMLOCK
Definition: winuser.h:2255
#define KEYBOARD_SCROLL_LOCK_ON
Definition: ntddkbd.h:83
#define VK_CAPITAL
Definition: winuser.h:2182
#define NULL
Definition: types.h:112
#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  pKbdInputData)

Definition at line 1054 of file keyboard.c.

1056 {
1057  WORD wScanCode, wVk;
1058  PKL pKl = NULL;
1059  PKBDTABLES pKbdTbl;
1060  PUSER_MESSAGE_QUEUE pFocusQueue;
1061 
1062  /* Calculate scan code with prefix */
1063  wScanCode = pKbdInputData->MakeCode & 0x7F;
1064  if (pKbdInputData->Flags & KEY_E0)
1065  wScanCode |= 0xE000;
1066  if (pKbdInputData->Flags & KEY_E1)
1067  wScanCode |= 0xE100;
1068 
1069  /* Find the target thread whose locale is in effect */
1070  pFocusQueue = IntGetFocusMessageQueue();
1071 
1072  if (pFocusQueue && pFocusQueue->ptiKeyboard)
1073  {
1074  pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
1075  }
1076 
1077  if (!pKl)
1078  pKl = W32kGetDefaultKeyLayout();
1079  if (!pKl)
1080  return;
1081 
1082  pKbdTbl = pKl->spkf->pKbdTbl;
1083 
1084  /* Convert scan code to virtual key.
1085  Note: We could call UserSendKeyboardInput using scan code,
1086  but it wouldn't interpret E1 key(s) properly */
1087  wVk = IntVscToVk(wScanCode, pKbdTbl);
1088  TRACE("UserProcessKeyboardInput: %x (break: %u) -> %x\n",
1089  wScanCode, (pKbdInputData->Flags & KEY_BREAK) ? 1u : 0, wVk);
1090 
1091  if (wVk)
1092  {
1093  KEYBDINPUT KbdInput;
1094 
1095  /* Support numlock */
1097  {
1098  wVk = IntTranslateNumpadKey(wVk & 0xFF);
1099  }
1100 
1101  /* Send keyboard input */
1102  KbdInput.wVk = wVk & 0xFF;
1103  KbdInput.wScan = wScanCode & 0x7F;
1104  KbdInput.dwFlags = 0;
1105  if (pKbdInputData->Flags & KEY_BREAK)
1106  KbdInput.dwFlags |= KEYEVENTF_KEYUP;
1107 
1108  if (wVk & KBDEXT)
1109  KbdInput.dwFlags |= KEYEVENTF_EXTENDEDKEY;
1110  //
1111  // Based on wine input:test_Input_blackbox this is okay. It seems the
1112  // bit did not get set and more research is needed. Now the right
1113  // shift works.
1114  //
1115  if (wVk == VK_RSHIFT)
1116  KbdInput.dwFlags |= KEYEVENTF_EXTENDEDKEY;
1117 
1118  KbdInput.time = 0;
1119  KbdInput.dwExtraInfo = pKbdInputData->ExtraInformation;
1120  UserSendKeyboardInput(&KbdInput, FALSE);
1121 
1122  /* E1 keys don't have break code */
1123  if (pKbdInputData->Flags & KEY_E1)
1124  {
1125  /* Send key up event */
1126  KbdInput.dwFlags |= KEYEVENTF_KEYUP;
1127  UserSendKeyboardInput(&KbdInput, FALSE);
1128  }
1129  }
1130 }
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:1276
#define KBDNUMPAD
Definition: kbd.h:11
#define FALSE
Definition: types.h:117
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:2259
struct tagKL * KeyboardLayout
Definition: win32.h:91
#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:2255
#define KEY_E0
Definition: ntddkbd.h:72
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:396
#define NULL
Definition: types.h:112
ULONG ExtraInformation
Definition: ntddkbd.h:90
#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().

◆ 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  DWORD dwTime;
980  BOOL bExt = (pKbdInput->dwFlags & KEYEVENTF_EXTENDEDKEY) ? TRUE : FALSE;
981 
983 
984  /* Find the target thread whose locale is in effect */
985  pFocusQueue = IntGetFocusMessageQueue();
986 
987  if (pFocusQueue && pFocusQueue->ptiKeyboard)
988  {
989  pKl = pFocusQueue->ptiKeyboard->KeyboardLayout;
990  }
991 
992  if (!pKl)
993  pKl = W32kGetDefaultKeyLayout();
994  if (!pKl)
995  {
996  ERR("No keyboard layout!\n");
997  return FALSE;
998  }
999 
1000  pKbdTbl = pKl->spkf->pKbdTbl;
1001 
1002  /* Note: wScan field is always used */
1003  wScanCode = pKbdInput->wScan;
1004 
1005  if (pKbdInput->dwFlags & KEYEVENTF_UNICODE)
1006  {
1007  /* Generate WM_KEYDOWN msg with wParam == VK_PACKET and
1008  high order word of lParam == pKbdInput->wScan */
1009  wVk = VK_PACKET;
1010  }
1011  else
1012  {
1013  wScanCode &= 0x7F;
1014  if (pKbdInput->dwFlags & KEYEVENTF_SCANCODE)
1015  {
1016  /* Don't ignore invalid scan codes */
1017  wVk = IntVscToVk(wScanCode | (bExt ? 0xE000 : 0), pKbdTbl);
1018  if (!wVk) /* use 0xFF if vsc is invalid */
1019  wVk = 0xFF;
1020  }
1021  else
1022  {
1023  wVk = pKbdInput->wVk;
1024  }
1025 
1026  /* Remove all virtual key flags (KBDEXT, KBDMULTIVK, KBDSPECIAL, KBDNUMPAD) */
1027  wVk &= 0xFF;
1028  }
1029 
1030  /* If time is given, use it */
1031  if (pKbdInput->time)
1032  dwTime = pKbdInput->time;
1033  else
1034  {
1036  }
1037 
1038  if (wVk == VK_RMENU && (pKbdTbl->fLocaleFlags & KLLF_ALTGR))
1039  {
1040  /* For AltGr keyboards RALT generates CTRL events */
1041  ProcessKeyEvent(VK_LCONTROL, 0, pKbdInput->dwFlags & KEYEVENTF_KEYUP, bInjected, dwTime, 0);
1042  }
1043 
1044  /* Finally process this key */
1045  return ProcessKeyEvent(wVk, wScanCode, pKbdInput->dwFlags, bInjected, dwTime, pKbdInput->dwExtraInfo);
1046 }
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define TRUE
Definition: types.h:120
#define VK_RMENU
Definition: winuser.h:2263
#define EngGetTickCount32()
Definition: eng.h:43
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
PUSER_MESSAGE_QUEUE FASTCALL IntGetFocusMessageQueue(VOID)
Definition: desktop.c:1276
#define KLLF_ALTGR
Definition: kbd.h:91
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
Definition: input.h:26
DWORD dwTime
Definition: solitaire.cpp:26
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:91
#define ERR(fmt,...)
Definition: debug.h:110
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:396
#define NULL
Definition: types.h:112
#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:2260
WORD wVk
Definition: winable.h:47

Referenced by NtUserSendInput(), and UserProcessKeyboardInput().

Variable Documentation

◆ gafAsyncKeyState

◆ gafAsyncKeyStateRecentDown

BYTE gafAsyncKeyStateRecentDown[256/8]
static

Definition at line 14 of file keyboard.c.

Referenced by InitKeyboardImpl(), NtUserGetAsyncKeyState(), and UpdateAsyncKeyState().

◆ gdwLanguageToggleKey

DWORD gdwLanguageToggleKey = 0

◆ gIndicators

KEYBOARD_INDICATOR_PARAMETERS gIndicators = {0, 0}
static

Definition at line 16 of file keyboard.c.

Referenced by IntKeyboardUpdateLeds(), and UserInitKeyboard().

◆ gKeyboardInfo

KEYBOARD_ATTRIBUTES gKeyboardInfo

◆ gLanguageToggleKeyState

int gLanguageToggleKeyState = 0

Definition at line 18 of file keyboard.c.

Referenced by co_IntProcessKeyboardMessage().

◆ gpKeyboardIndicatorTrans

PKEYBOARD_INDICATOR_TRANSLATION gpKeyboardIndicatorTrans = NULL
static

Definition at line 15 of file keyboard.c.

Referenced by IntKeyboardUpdateLeds(), and UserInitKeyboard().