Skip to content

Commit

Permalink
Fixing keycode issues with improper use of LLKHF_EXTENDED on Windows. F…
Browse files Browse the repository at this point in the history
…ixes #147 and #179
  • Loading branch information
kwhat committed May 6, 2024
1 parent e3acff8 commit c446595
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
22 changes: 11 additions & 11 deletions include/uiohook.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
18 changes: 11 additions & 7 deletions src/windows/input_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,21 @@ uint16_t vkcode_to_uiocode(DWORD vk_code, DWORD flags) {
if (vk_code < sizeof(uiocode_vkcode_table) / sizeof(uiocode_vkcode_table[0])) {
uiocode = uiocode_vkcode_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 extended lookup for vk_code: %li\n",
__FUNCTION__, __LINE__, vk_code);

switch (vk_code) {
case VK_RETURN:
uiocode = VC_KP_ENTER;
break;
}
} else {
logger(LOG_LEVEL_DEBUG, "%s [%u]: Using normal lookup for vk_code: %li\n",
__FUNCTION__, __LINE__, vk_code);

switch (vk_code) {
case VK_PRIOR:
case VK_NEXT:
Expand All @@ -319,14 +330,7 @@ uint16_t vkcode_to_uiocode(DWORD vk_code, DWORD flags) {
case VK_DELETE:
uiocode |= 0xEE00;
break;

case VK_RETURN:
uiocode |= 0x0E00;
break;
}
} else {
logger(LOG_LEVEL_DEBUG, "%s [%u]: Using normal lookup for vk_code: %li\n",
__FUNCTION__, __LINE__, vk_code);
}
}

Expand Down

0 comments on commit c446595

Please sign in to comment.