1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

remove unneeded function

This commit is contained in:
FunkyFr3sh 2023-09-25 02:57:59 +02:00
parent da0ccd99e8
commit 6987d1a773
2 changed files with 13 additions and 20 deletions

View File

@ -1226,21 +1226,27 @@ void __fastcall TConfigForm::HotkeyEdtKeyUp(TObject *Sender, WORD &Key, TShiftSt
SaveSettings(); SaveSettings();
} }
WORD TConfigForm::GetKeyCode(System::UnicodeString key) WORD TConfigForm::GetKeyCode(System::UnicodeString text)
{ {
if (key == L"PrtScn") { if (text == L"PrtScn") {
return VK_SNAPSHOT; return VK_SNAPSHOT;
} }
if (key == L"Pause_") { if (text == L"Pause_") {
return VK_PAUSE; return VK_PAUSE;
} }
if (key == L"R " + KeyToText(VK_CONTROL)) { if (text == L"R " + KeyToText(VK_CONTROL)) {
return VK_RCONTROL; 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) System::UnicodeString TConfigForm::GetKeyText(WORD key)
@ -1264,21 +1270,8 @@ System::UnicodeString TConfigForm::GetKeyText(WORD key)
return KeyToText(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) System::UnicodeString TConfigForm::KeyToText(WORD key)
{ {
WCHAR keyName[256] = {};
UINT scanCode = MapVirtualKeyW(key, MAPVK_VK_TO_VSC); UINT scanCode = MapVirtualKeyW(key, MAPVK_VK_TO_VSC);
switch (key) { switch (key) {
@ -1300,6 +1293,7 @@ System::UnicodeString TConfigForm::KeyToText(WORD key)
} }
} }
WCHAR keyName[256] = {};
GetKeyNameTextW(scanCode << 16, keyName, sizeof(keyName) / sizeof(WCHAR)); GetKeyNameTextW(scanCode << 16, keyName, sizeof(keyName) / sizeof(WCHAR));
KeyNames[(BYTE)key] = keyName; KeyNames[(BYTE)key] = keyName;

View File

@ -123,8 +123,7 @@ private: // Benutzer-Deklarationen
bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue); bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue);
void ApplyTranslation(TIniFile *ini); void ApplyTranslation(TIniFile *ini);
System::UnicodeString GetKeyText(WORD key); System::UnicodeString GetKeyText(WORD key);
WORD GetKeyCode(System::UnicodeString key); WORD GetKeyCode(System::UnicodeString text);
WORD TextToKey(System::UnicodeString Text);
System::UnicodeString KeyToText(WORD key); System::UnicodeString KeyToText(WORD key);
public: // Benutzer-Deklarationen public: // Benutzer-Deklarationen
__fastcall TConfigForm(TComponent* Owner); __fastcall TConfigForm(TComponent* Owner);