diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 2387f8f..5b51d7d 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -1240,21 +1240,27 @@ void __fastcall TConfigForm::HotkeyEdtKeyUp(TObject *Sender, WORD &Key, TShiftSt SaveSettings(); } -WORD TConfigForm::GetKeyCode(System::UnicodeString key) +WORD TConfigForm::GetKeyCode(System::UnicodeString text) { - if (key == L"PrtScn") { + if (text == L"PrtScn") { return VK_SNAPSHOT; } - if (key == L"Pause_") { + if (text == L"Pause_") { return VK_PAUSE; } - if (key == L"R " + KeyToText(VK_CONTROL)) { + if (text == L"R " + KeyToText(VK_CONTROL)) { return VK_RCONTROL; } - return TextToKey(key); + for (WORD i = 0; i < 256; i++) { + if (KeyNames[i] == text) { + return i; + } + } + + return 0; } System::UnicodeString TConfigForm::GetKeyText(WORD key) @@ -1278,21 +1284,8 @@ System::UnicodeString TConfigForm::GetKeyText(WORD key) return KeyToText(key); } -WORD TConfigForm::TextToKey(System::UnicodeString Text) -{ - for (WORD i = 0; i < 256; i++) { - if (KeyNames[i] == Text) { - return i; - } - } - - return 0; -} - System::UnicodeString TConfigForm::KeyToText(WORD key) { - WCHAR keyName[256] = {}; - UINT scanCode = MapVirtualKeyW(key, MAPVK_VK_TO_VSC); switch (key) { @@ -1314,6 +1307,7 @@ System::UnicodeString TConfigForm::KeyToText(WORD key) } } + WCHAR keyName[256] = {}; GetKeyNameTextW(scanCode << 16, keyName, sizeof(keyName) / sizeof(WCHAR)); KeyNames[(BYTE)key] = keyName; diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index 7b0425f..8a8a14c 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -120,8 +120,7 @@ private: // Benutzer-Deklarationen bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue); void ApplyTranslation(TIniFile *ini); System::UnicodeString GetKeyText(WORD key); - WORD GetKeyCode(System::UnicodeString key); - WORD TextToKey(System::UnicodeString Text); + WORD GetKeyCode(System::UnicodeString text); System::UnicodeString KeyToText(WORD key); void DisableGameUX(); void AddDllOverride();