mirror of https://github.com/FreeRDP/FreeRDP
[winpr,input] fix GetKeycodeFromVirtualKeyCode(code, KEYCODE_TYPE_XKB)
As KEYCODE_TYPE_XKB is 3, in the previous code we were doing some "and masking" and so when calling GetKeycodeFromVirtualKeyCode(code, KEYCODE_TYPE_XKB), the function was always interpreting the virtual key code with the apple layout. This patch fixes that and also mutualize the search in the code array.
This commit is contained in:
parent
4be82bf085
commit
46171045ed
|
@ -878,41 +878,32 @@ DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags)
|
|||
DWORD GetKeycodeFromVirtualKeyCode(DWORD vkcode, DWORD dwFlags)
|
||||
{
|
||||
DWORD index;
|
||||
DWORD keycode = 0;
|
||||
DWORD* targetArray;
|
||||
size_t targetSize;
|
||||
|
||||
if (dwFlags & KEYCODE_TYPE_APPLE)
|
||||
switch (dwFlags)
|
||||
{
|
||||
for (index = 0; index < ARRAYSIZE(KEYCODE_TO_VKCODE_APPLE); index++)
|
||||
{
|
||||
if (vkcode == KEYCODE_TO_VKCODE_APPLE[index])
|
||||
{
|
||||
keycode = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dwFlags & KEYCODE_TYPE_EVDEV)
|
||||
{
|
||||
for (index = 0; index < ARRAYSIZE(KEYCODE_TO_VKCODE_EVDEV); index++)
|
||||
{
|
||||
if (vkcode == KEYCODE_TO_VKCODE_EVDEV[index])
|
||||
{
|
||||
keycode = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dwFlags & KEYCODE_TYPE_XKB)
|
||||
{
|
||||
for (index = 0; index < ARRAYSIZE(KEYCODE_TO_VKCODE_XKB); index++)
|
||||
{
|
||||
if (vkcode == KEYCODE_TO_VKCODE_XKB[index])
|
||||
{
|
||||
keycode = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case KEYCODE_TYPE_APPLE:
|
||||
targetArray = KEYCODE_TO_VKCODE_APPLE;
|
||||
targetSize = ARRAYSIZE(KEYCODE_TO_VKCODE_APPLE);
|
||||
break;
|
||||
case KEYCODE_TYPE_EVDEV:
|
||||
targetArray = KEYCODE_TO_VKCODE_EVDEV;
|
||||
targetSize = ARRAYSIZE(KEYCODE_TO_VKCODE_EVDEV);
|
||||
break;
|
||||
case KEYCODE_TYPE_XKB:
|
||||
targetArray = KEYCODE_TO_VKCODE_XKB;
|
||||
targetSize = ARRAYSIZE(KEYCODE_TO_VKCODE_XKB);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return keycode;
|
||||
for (index = 0; index < targetSize; index++)
|
||||
{
|
||||
if (vkcode == targetArray[index])
|
||||
return index;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue