diff --git a/src/main.cpp b/src/main.cpp index c7e87ef..ad3cc4e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -18,6 +19,31 @@ using namespace geode::prelude; using namespace keybinds; +class $modify(CCEGLView){ + + /** + * GD does not pass shift into dispatchKeyboardMSG, causing the modifier to break when holding. + * We need to manually pass in shift from onGLFWKeyCallback to resolve this bug. + */ + void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) { + enumKeyCodes keycode = enumKeyCodes::KEY_Unknown; + + switch (key) { + case GLFW_KEY_LEFT_SHIFT: + keycode = enumKeyCodes::KEY_LeftShift; + break; + case GLFW_KEY_RIGHT_SHIFT: + keycode = enumKeyCodes::KEY_RightShift; + break; + } + + if (keycode != enumKeyCodes::KEY_Unknown) { + CCKeyboardDispatcher::get()->dispatchKeyboardMSG(keycode, action >= 1, action == 2); + } + CCEGLView::onGLFWKeyCallback(window, key, scancode, action, mods); + } +}; + class $modify(CCKeyboardDispatcher) { static inline std::unordered_set s_held {}; @@ -67,8 +93,12 @@ class $modify(CCKeyboardDispatcher) { // dispatch release events for Modifier + Key combos else { // If no actual key was being held, just modifiers - if (s_held.empty() && !down) { - return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, p2); + if (!down) { + // Stop repeats here, resolves repeat issue when keys and modifiers are pressed in reverse + BindManager::get()->stopAllRepeats(); + if (s_held.empty()) { + return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, p2); + } } std::unordered_set modifiersToToggle = this->getModifiersToToggle(key, down); bool ok = true;