diff --git a/include/uiohook.h b/include/uiohook.h index 49856805..a6b6f113 100644 --- a/include/uiohook.h +++ b/include/uiohook.h @@ -275,7 +275,7 @@ typedef void (*dispatcher_t)(uiohook_event * const, void *); // Begin Numeric Zone #define VC_NUM_LOCK 0x0090 #define VC_KP_CLEAR 0x000C -#define VC_CLEAR VC_KP_CLEAR // Deprecated +#define VC_CLEAR VC_KP_CLEAR // Deprecated, the clear key is only available on the keypad. #define VC_KP_DIVIDE 0x006F #define VC_KP_MULTIPLY 0x006A @@ -298,17 +298,17 @@ typedef void (*dispatcher_t)(uiohook_event * const, void *); #define VC_KP_8 0x0068 #define VC_KP_9 0x0069 -#define VC_KP_END 0xEE00 | VC_KP_1 -#define VC_KP_DOWN 0xEE00 | VC_KP_2 -#define VC_KP_PAGE_DOWN 0xEE00 | VC_KP_3 -#define VC_KP_LEFT 0xEE00 | VC_KP_4 -#define VC_KP_BEGIN 0xEE00 | VC_KP_5 -#define VC_KP_RIGHT 0xEE00 | VC_KP_6 -#define VC_KP_HOME 0xEE00 | VC_KP_7 -#define VC_KP_UP 0xEE00 | VC_KP_8 -#define VC_KP_PAGE_UP 0xEE00 | VC_KP_9 -#define VC_KP_INSERT 0xEE00 | VC_KP_0 -#define VC_KP_DELETE 0xEE00 | VC_KP_SEPARATOR +#define VC_KP_END 0xEE00 | VC_END +#define VC_KP_DOWN 0xEE00 | VC_DOWN +#define VC_KP_PAGE_DOWN 0xEE00 | VC_PAGE_DOWN +#define VC_KP_LEFT 0xEE00 | VC_LEFT +#define VC_KP_BEGIN 0xEE00 | VC_BEGIN +#define VC_KP_RIGHT 0xEE00 | VC_RIGHT +#define VC_KP_HOME 0xEE00 | VC_HOME +#define VC_KP_UP 0xEE00 | VC_UP +#define VC_KP_PAGE_UP 0xEE00 | VC_PAGE_UP +#define VC_KP_INSERT 0xEE00 | VC_INSERT +#define VC_KP_DELETE 0xEE00 | VC_DELETE // End Numeric Zone diff --git a/src/windows/input_helper.c b/src/windows/input_helper.c index 2dc35496..1408eb86 100644 --- a/src/windows/input_helper.c +++ b/src/windows/input_helper.c @@ -301,7 +301,18 @@ unsigned short keycode_to_scancode(DWORD vk_code, DWORD flags) { if (vk_code < sizeof(keycode_scancode_table) / sizeof(keycode_scancode_table[0])) { scancode = keycode_scancode_table[vk_code][0]; + // Check the extended key flag as defined at: + // https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#extended-key-flag if (flags & LLKHF_EXTENDED) { + logger(LOG_LEVEL_DEBUG, "%s [%u]: Using normal lookup for vk_code: %li\n", + __FUNCTION__, __LINE__, vk_code); + + switch (vk_code) { + case VK_RETURN: + scancode = VC_KP_ENTER; + break; + } + } else { logger(LOG_LEVEL_DEBUG, "%s [%u]: Using extended lookup for vk_code: %li\n", __FUNCTION__, __LINE__, vk_code); @@ -319,14 +330,7 @@ unsigned short keycode_to_scancode(DWORD vk_code, DWORD flags) { case VK_DELETE: scancode |= 0xEE00; break; - - case VK_RETURN: - scancode |= 0x0E00; - break; } - } else { - logger(LOG_LEVEL_DEBUG, "%s [%u]: Using normal lookup for vk_code: %li\n", - __FUNCTION__, __LINE__, vk_code); } }