From 6987d1a773181b5ae981389a91db5d32303e4461 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 25 Sep 2023 02:57:59 +0200 Subject: [PATCH] remove unneeded function --- config/ConfigFormUnit.cpp | 30 ++++++++++++------------------ config/ConfigFormUnit.h | 3 +-- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 1a9e4f7..66d8be5 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -1226,21 +1226,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) @@ -1264,21 +1270,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) { @@ -1300,6 +1293,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 83ed66a..3a77681 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -123,8 +123,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); public: // Benutzer-Deklarationen __fastcall TConfigForm(TComponent* Owner);