Input: Fixed default shortcuts & shortcut display when using non-qwerty layouts
This resets all non-debugger shortcut keys to their default values due to values saved in the config switching from scan codes to virtual key codes.
This commit is contained in:
parent
58c18adc10
commit
08e0820164
2 changed files with 19 additions and 17 deletions
|
@ -28,8 +28,8 @@ namespace Mesen.GUI.Config
|
|||
public NetplayConfig Netplay;
|
||||
public Point WindowLocation;
|
||||
public Size WindowSize;
|
||||
public bool NeedInputReinit = true;
|
||||
public DefaultKeyMappingType DefaultKeyMappings = DefaultKeyMappingType.None;
|
||||
public bool NeedInputReinit2 = true;
|
||||
public DefaultKeyMappingType DefaultKeyMappings = DefaultKeyMappingType.Xbox | DefaultKeyMappingType.ArrowKeys;
|
||||
|
||||
public Configuration()
|
||||
{
|
||||
|
@ -79,11 +79,15 @@ namespace Mesen.GUI.Config
|
|||
|
||||
public void InitializeDefaults()
|
||||
{
|
||||
Preferences.InitializeDefaultShortcuts();
|
||||
if(NeedInputReinit) {
|
||||
if(NeedInputReinit2) {
|
||||
Input.Controllers = new ControllerConfig[5];
|
||||
Preferences.ShortcutKeys1 = null;
|
||||
Preferences.ShortcutKeys2 = null;
|
||||
|
||||
Input.InitializeDefaults(DefaultKeyMappings);
|
||||
NeedInputReinit = false;
|
||||
NeedInputReinit2 = false;
|
||||
}
|
||||
Preferences.InitializeDefaultShortcuts();
|
||||
ConfigManager.ApplyChanges();
|
||||
}
|
||||
|
||||
|
|
|
@ -228,12 +228,11 @@ WindowsKeyManager::WindowsKeyManager(shared_ptr<Console> console, HWND hWnd)
|
|||
|
||||
for(KeyDefinition& keyDef : _keyDefinitions) {
|
||||
_keyNames[keyDef.keyCode] = keyDef.description;
|
||||
_keyExtendedNames[keyDef.keyCode] = keyDef.extDescription.empty() ? "Ext " + keyDef.description : keyDef.extDescription;
|
||||
_keyExtendedNames[keyDef.keyCode | 0x100] = keyDef.extDescription.empty() ? "Ext " + keyDef.description : keyDef.extDescription;
|
||||
|
||||
uint32_t keyCode = keyDef.keyCode <= 0xFFFF ? MapVirtualKeyEx(keyDef.keyCode & 0xFF, MAPVK_VK_TO_VSC, nullptr) : keyDef.keyCode;
|
||||
_keyCodes[keyDef.description] = keyCode;
|
||||
_keyCodes[keyDef.description] = keyDef.keyCode;
|
||||
if(!keyDef.extDescription.empty()) {
|
||||
_keyCodes[keyDef.extDescription] = 0x100 | keyCode;
|
||||
_keyCodes[keyDef.extDescription] = 0x100 | (keyDef.keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,10 +345,9 @@ vector<uint32_t> WindowsKeyManager::GetPressedKeys()
|
|||
return result;
|
||||
}
|
||||
|
||||
string WindowsKeyManager::GetKeyName(uint32_t scanCode)
|
||||
string WindowsKeyManager::GetKeyName(uint32_t keyCode)
|
||||
{
|
||||
uint32_t keyCode = scanCode <= 0xFFFF ? MapVirtualKeyEx(scanCode & 0xFF, MAPVK_VSC_TO_VK, nullptr) : scanCode;
|
||||
bool extendedKey = (scanCode <= 0xFFFF && scanCode & 0x100);
|
||||
bool extendedKey = (keyCode <= 0xFFFF && (keyCode & 0x100));
|
||||
auto keyDef = (extendedKey ? _keyExtendedNames : _keyNames).find(keyCode);
|
||||
if(keyDef != (extendedKey ? _keyExtendedNames : _keyNames).end()) {
|
||||
return keyDef->second;
|
||||
|
@ -381,12 +379,12 @@ void WindowsKeyManager::SetKeyState(uint16_t scanCode, bool state)
|
|||
if(scanCode > 0x1FF) {
|
||||
_mouseState[scanCode & 0x03] = state;
|
||||
} else {
|
||||
uint32_t keyCode = MapVirtualKeyEx(scanCode & 0xFF, MAPVK_VSC_TO_VK, nullptr);
|
||||
uint32_t keyCode = MapVirtualKeyEx(scanCode & 0xFF, MAPVK_VSC_TO_VK, GetKeyboardLayout(0));
|
||||
if(keyCode >= 0x10 && keyCode <= 0x12) {
|
||||
//Ignore "ext" flag for alt, ctrl & shift
|
||||
scanCode = MapVirtualKeyEx(keyCode, MAPVK_VK_TO_VSC, nullptr);
|
||||
scanCode = MapVirtualKeyEx(keyCode, MAPVK_VK_TO_VSC, GetKeyboardLayout(0));
|
||||
}
|
||||
_keyState[scanCode & 0x1FF] = state;
|
||||
_keyState[keyCode | (scanCode & 0x100)] = state;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue