Skip to content

Commit

Permalink
Fix extended key such as navigational and num pad
Browse files Browse the repository at this point in the history
  • Loading branch information
Electronicks committed Nov 16, 2021
1 parent 840ffd5 commit 911ccb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Nicolas is adding Nielk1's trigger effect to JSM.
### Bugfixes
* Fixed virtual DS4 left stick having a heavy bias to the corners.
* Analog output of triggers are registered as chords to enable gyro button and chords but not digital mappings
* Fixing the oldest bug in the history of JSM: numpad and navigational buttons depending on num lock

## 3.2.3

Expand Down
11 changes: 8 additions & 3 deletions JoyShockMapper/src/win32/InputHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ bool isNumLockKey(KeyCode key)

bool isExtendedKey(KeyCode key)
{
return (key.code >= VK_LEFT && key.code <= VK_DOWN) ||
(key.code >= VK_LWIN && key.code <= VK_NUMPAD9) ||
(key.code >= VK_BROWSER_BACK && key.code <= VK_LAUNCH_APP2);
return ((key.code >= VK_PRIOR && key.code <= VK_HELP) && key.code != VK_SNAPSHOT) ||
(key.code >= VK_LWIN && key.code <= VK_DIVIDE) ||
(key.code >= VK_BROWSER_BACK && key.code <= VK_LAUNCH_APP2);
}

// send key press
Expand All @@ -123,6 +123,11 @@ int pressKey(KeyCode vkKey, bool pressed)
input.type = INPUT_KEYBOARD;
input.ki.time = 0;
input.ki.dwFlags = pressed ? 0 : KEYEVENTF_KEYUP;
if (isExtendedKey(vkKey))
{
input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
}

if (isNumLockKey(vkKey))
{
input.ki.wVk = vkKey.code;
Expand Down

0 comments on commit 911ccb0

Please sign in to comment.