diff --git a/Amalgam/src/Features/ImGui/Menu/Components.h b/Amalgam/src/Features/ImGui/Menu/Components.h index f2b44711..49e2a623 100644 --- a/Amalgam/src/Features/ImGui/Menu/Components.h +++ b/Amalgam/src/Features/ImGui/Menu/Components.h @@ -2085,22 +2085,35 @@ namespace ImGui { SetActiveID(uId, GetCurrentWindow()); - int iKeyPressed = 0; - for (short iKey = 0; iKey < 255; iKey++) + for (short iKey = 1; iKey < 255; iKey++) { - if (!vIgnore.empty() && std::find(vIgnore.begin(), vIgnore.end(), iKey) != vIgnore.end()) + bool bValid = U::KeyHandler.Pressed(iKey); + if (!bValid) continue; - if (U::KeyHandler.Pressed(iKey)) - { - iKeyPressed = iKey; - break; - } - } + bValid = vIgnore.empty() || std::find(vIgnore.begin(), vIgnore.end(), iKey) == vIgnore.end(); + if (!bValid) + continue; - if (iKeyPressed && (iKeyPressed != VK_LBUTTON || !bHovered)) - { - switch (iKeyPressed) + switch (iKey) + { + case VK_LBUTTON: + bValid = !bHovered; break; + case VK_SHIFT: + case VK_LSHIFT: + case VK_RSHIFT: + case VK_CONTROL: + case VK_LCONTROL: + case VK_RCONTROL: + case VK_MENU: + case VK_LMENU: + case VK_RMENU: + bValid = iKey != iOutput; break; + } + if (!bValid) + continue; + + switch (iKey) { case VK_ESCAPE: if (iFlags & FKeybindEnum::AllowNone) @@ -2110,9 +2123,10 @@ namespace ImGui } [[fallthrough]]; default: - iOutput = iKeyPressed; + iOutput = iKey; } ClearActiveID(); + break; } GetCurrentContext()->ActiveIdAllowOverlap = true; diff --git a/Amalgam/src/Features/ImGui/Menu/Menu.cpp b/Amalgam/src/Features/ImGui/Menu/Menu.cpp index 8e95f300..76efe3f7 100644 --- a/Amalgam/src/Features/ImGui/Menu/Menu.cpp +++ b/Amalgam/src/Features/ImGui/Menu/Menu.cpp @@ -4135,7 +4135,7 @@ void CMenu::Render() m_bInKeybind = false; if (m_bIsOpen) { - for (short iKey = 0; iKey < 256; iKey++) + for (short iKey = 1; iKey < 255; iKey++) U::KeyHandler.StoreKey(iKey); } else diff --git a/Amalgam/src/SDK/Helpers/Draw/Draw.cpp b/Amalgam/src/SDK/Helpers/Draw/Draw.cpp index f8f647af..70813082 100644 --- a/Amalgam/src/SDK/Helpers/Draw/Draw.cpp +++ b/Amalgam/src/SDK/Helpers/Draw/Draw.cpp @@ -70,7 +70,7 @@ void CDraw::UpdateKeyStrings() if (HKL pCurrLayout = GetKeyboardLayout(0); pCurrLayout != pLastLayout) { pLastLayout = pCurrLayout; - for (short iKey = 0; iKey < 256; iKey++) + for (short iKey = 1; iKey < 255; iKey++) U::KeyHandler.String(iKey, true); } } diff --git a/Amalgam/src/Utils/KeyHandler/KeyHandler.cpp b/Amalgam/src/Utils/KeyHandler/KeyHandler.cpp index 98a73281..425006e0 100644 --- a/Amalgam/src/Utils/KeyHandler/KeyHandler.cpp +++ b/Amalgam/src/Utils/KeyHandler/KeyHandler.cpp @@ -26,7 +26,9 @@ void CKeyHandler::StoreKey(byte iKey, KeyStorage* pStorage) pStorage->m_bIsPressed = bPressed; pStorage->m_bIsDouble = bDouble; pStorage->m_bIsReleased = bReleased; - if (bPressed) + if (bDouble) + pStorage->m_dPressTime = 0.0; + else if (bPressed) pStorage->m_dPressTime = dFloatTime; } diff --git a/Amalgam/src/Utils/KeyHandler/KeyHandler.h b/Amalgam/src/Utils/KeyHandler/KeyHandler.h index 134c9b74..8cb8a420 100644 --- a/Amalgam/src/Utils/KeyHandler/KeyHandler.h +++ b/Amalgam/src/Utils/KeyHandler/KeyHandler.h @@ -26,7 +26,7 @@ public: public: std::string& String(byte iKey, const bool bStore = false); - std::array m_aStringStorage = {}; + std::array m_aStringStorage = { "none" }; }; ADD_FEATURE_CUSTOM(CKeyHandler, KeyHandler, U); \ No newline at end of file