We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5274 - [REGRESSION] [PATCH] Numlock state changes scancodes of numpad arrow keys
Summary: [REGRESSION] [PATCH] Numlock state changes scancodes of numpad arrow keys
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: x86 Windows 10
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-28 00:56 UTC by Cameron Gutman
Modified: 2020-11-12 02:58 UTC (History)
1 user (show)

See Also:


Attachments
Patch (1.97 KB, patch)
2020-08-28 00:57 UTC, Cameron Gutman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Gutman 2020-08-28 00:56:45 UTC
The fix for bug 4709 introduced a regression in SDL 2.0.12 which caused the scancodes of the number pad's arrow keys to change based on whether numlock is enabled or disabled. When enabled, the scan codes are appropriately mapped to SDL_SCANCODE_KP_8, SDL_SCANCODE_KP_4, etc. However, when disabled, they are incorrectly switched to the scancodes corresponding to the primary arrow keys (SDL_SCANCODE_UP, SDL_SCANCODE_LEFT, etc).

The cause of this issue is that VKeytoScancode() is mapping VK_LEFT, VK_RIGHT, etc. to SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, etc. prior to the code in WindowsScanCodeToSDLScanCode() which fixes up the numpad's scancodes to be consistent with and without numlock.

Because we only want to perform that mapping for the on-screen keyboard if no scan code is reported in the event, I've fixed this by only performing the VK_LEFT -> SDL_SCANCODE_LEFT mapping if none of the other mappings in WindowsScanCodeToSDLScanCode() match. This should fix this issue without regressing the on-screen keyboard fix in bug 4709.
Comment 1 Cameron Gutman 2020-08-28 00:57:43 UTC
Created attachment 4453 [details]
Patch
Comment 2 Cameron Gutman 2020-11-12 00:50:50 UTC
Can we add target-2.0.14 for this one? This is a 2.0.12 regression impacting real apps - https://twitter.com/voidpnt/status/1250803819484573698
Comment 3 Sam Lantinga 2020-11-12 02:58:28 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/9296b2bfb5d1