mirror of https://github.com/encounter/SDL.git
prefer virtual keycodes over scancodes for extended keys
This commit is contained in:
parent
195b8bd8ee
commit
34769abd46
|
@ -82,15 +82,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static SDL_Scancode
|
static SDL_Scancode
|
||||||
WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
VKeytoScancode(WPARAM vkey)
|
||||||
{
|
{
|
||||||
SDL_Scancode code;
|
switch (vkey) {
|
||||||
char bIsExtended;
|
|
||||||
int nScanCode = (lParam >> 16) & 0xFF;
|
|
||||||
|
|
||||||
/* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */
|
|
||||||
if (nScanCode == 0 || nScanCode == 0x45) {
|
|
||||||
switch(wParam) {
|
|
||||||
case VK_CLEAR: return SDL_SCANCODE_CLEAR;
|
case VK_CLEAR: return SDL_SCANCODE_CLEAR;
|
||||||
case VK_MODECHANGE: return SDL_SCANCODE_MODE;
|
case VK_MODECHANGE: return SDL_SCANCODE_MODE;
|
||||||
case VK_SELECT: return SDL_SCANCODE_SELECT;
|
case VK_SELECT: return SDL_SCANCODE_SELECT;
|
||||||
|
@ -143,6 +137,18 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
||||||
|
|
||||||
default: return SDL_SCANCODE_UNKNOWN;
|
default: return SDL_SCANCODE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static SDL_Scancode
|
||||||
|
WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
||||||
|
{
|
||||||
|
SDL_Scancode code;
|
||||||
|
char bIsExtended;
|
||||||
|
int nScanCode = (lParam >> 16) & 0xFF;
|
||||||
|
|
||||||
|
/* 0x45 here to work around both pause and numlock sharing the same scancode, so use the VK key to tell them apart */
|
||||||
|
if (nScanCode == 0 || nScanCode == 0x45) {
|
||||||
|
return VKeytoScancode(wParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nScanCode > 127)
|
if (nScanCode > 127)
|
||||||
|
@ -178,6 +184,11 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* prefer virtual keycodes over scancodes for extended keys */
|
||||||
|
} else {
|
||||||
|
SDL_Scancode vc = VKeytoScancode(wParam);
|
||||||
|
if (vc != SDL_SCANCODE_UNKNOWN) {
|
||||||
|
code = vc;
|
||||||
} else {
|
} else {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case SDL_SCANCODE_RETURN:
|
case SDL_SCANCODE_RETURN:
|
||||||
|
@ -194,6 +205,7 @@ WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue