fix alternative keyboard layout handling for extended scancodes

This commit is contained in:
CasualPokePlayer 2024-01-26 07:00:45 -08:00
parent acf368e67f
commit 2f11560b14
1 changed files with 17 additions and 2 deletions

View File

@ -89,8 +89,23 @@ namespace BizHawk.Bizware.Input
/*private*/ internal static DInputKey MapToRealKeyViaScanCode(DInputKey key)
{
const uint MAPVK_VSC_TO_VK_EX = 0x03;
// DInputKey is a scancode as is
var virtualKey = MapVirtualKeyW((uint) key, MAPVK_VSC_TO_VK_EX);
// DInputKey is a scancode with bit 7 indicating an E0 prefix
var scanCode = (uint)key;
if ((scanCode & 0x80) != 0)
{
// exception for the Pause key (which uses an E1 prefix rather with 1D)
if (key == DInputKey.Pause)
{
scanCode = 0xE11D;
}
else
{
scanCode &= 0x7F;
scanCode |= 0xE000;
}
}
var virtualKey = MapVirtualKeyW(scanCode, MAPVK_VSC_TO_VK_EX);
return VKeyToDKeyMap.GetValueOrDefault(virtualKey, DInputKey.Unknown);
}