From 718a2a2f71e10bbdcce5e34c5ebeab76e0e448ac Mon Sep 17 00:00:00 2001 From: kingminer7 <100500023+Kingminer7@users.noreply.github.com> Date: Sat, 21 Feb 2026 22:58:37 -0500 Subject: [PATCH 1/4] Make it a keybind setting (and bump to v4) --- mod.json | 13 ++++++++++++- src/main.cpp | 19 ++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/mod.json b/mod.json index f01cf90..12af3d9 100644 --- a/mod.json +++ b/mod.json @@ -1,5 +1,5 @@ { - "geode": "5.0.0-beta.1", + "geode": "5.0.0-beta.4", "version": "v1.13.0", "gd": { "win": "2.2081", @@ -25,6 +25,17 @@ "name": "Use GD window", "description": "Determines if the DevTools should use a custom GD window or not. Required to disable for some exotic configurations (MacOS Wine).", "default": true + }, + "open-bind": { + "type": "keybind", + "name": "DevTools Keybind", + "descriptions": "The keybind to open DevTools", + "default": { + "win": "F11", + "mac": ["F10", "F11"], + "android": "F11", + "ios": "F11" + } } }, "resources": { diff --git a/src/main.cpp b/src/main.cpp index a210de8..ea1d67d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,24 +20,17 @@ class $modify(CCNode) { } }; -// todo: use shortcuts api once Geode has those -#ifndef GEODE_IS_IOS -class $modify(CCKeyboardDispatcher) { - bool dispatchKeyboardMSG(enumKeyCodes key, bool down, bool arr, double timestamp) { - if (down && (key == KEY_F11 GEODE_MACOS(|| key == KEY_F10))) { - DevTools::get()->toggle(); - return true; - } - return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, arr, timestamp); - } -}; -#endif - #include $execute { GameEvent(GameEventType::Loaded).listen([] { if (DevTools::get()->isButtonEnabled()) DevTools::get()->setupDragButton(); }).leak(); + + listenForKeybindSettingPresses("open-bind", [](Keybind const& keybind, bool down, bool repeat, double timestamp) { + if (down && !repeat) { + DevTools::get()->toggle(); + } + }); } #include From 6a51a7ba14853f70c7f5b9b9e9ebafd80229f866 Mon Sep 17 00:00:00 2001 From: kingminer7 <100500023+Kingminer7@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:28:28 -0500 Subject: [PATCH 2/4] use the input events instead! --- src/backend.cpp | 56 +++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/backend.cpp b/src/backend.cpp index 394efa5..418496b 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -329,25 +329,6 @@ void DevTools::renderDrawData(ImDrawData* draw_data) { glDisable(GL_SCISSOR_TEST); } -static float SCROLL_SENSITIVITY = 10; - -#ifndef GEODE_IS_IOS -class $modify(CCMouseDispatcher) { - bool dispatchScrollMSG(float y, float x) { - if(!DevTools::get()->isSetup()) return true; - - auto& io = ImGui::GetIO(); - io.AddMouseWheelEvent(x / SCROLL_SENSITIVITY, -y / SCROLL_SENSITIVITY); - - if (!io.WantCaptureMouse || shouldPassEventsToGDButTransformed()) { - return CCMouseDispatcher::dispatchScrollMSG(y, x); - } - - return true; - } -}; -#endif - class $modify(CCTouchDispatcher) { static void onModify(auto& self) { /* @@ -486,15 +467,16 @@ ImGuiKey cocosToImGuiKey(cocos2d::enumKeyCodes key) { } } -#ifndef GEODE_IS_IOS -class $modify(CCKeyboardDispatcher) { - bool dispatchKeyboardMSG(enumKeyCodes key, bool down, bool repeat, double a4) { - if(!DevTools::get()->isSetup()) return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, repeat, a4); +static float SCROLL_SENSITIVITY = 10; + +$on_mod(Loaded) { + KeyboardInputEvent().listen([](KeyboardInputData& data){ + if(!DevTools::get()->isSetup()) return ListenerResult::Propagate; auto& io = ImGui::GetIO(); - const auto imKey = cocosToImGuiKey(key); + const auto imKey = cocosToImGuiKey(data.key); if (imKey != ImGuiKey_None) { - io.AddKeyEvent(imKey, down); + io.AddKeyEvent(imKey, data.action != KeyboardInputData::Action::Release); } // CCIMEDispatcher stuff only gets called on mobile if the virtual keyboard would be up. @@ -525,13 +507,28 @@ class $modify(CCKeyboardDispatcher) { #endif if (io.WantCaptureKeyboard) { - return false; + return ListenerResult::Stop; } else { - return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, repeat, a4); + return ListenerResult::Propagate; } - } + }).leak(); + + ScrollWheelEvent().listen([](float x, float y) { + if(!DevTools::get()->isSetup()) return true; + + auto& io = ImGui::GetIO(); + io.AddMouseWheelEvent(x / SCROLL_SENSITIVITY, -y / SCROLL_SENSITIVITY); - #if defined(GEODE_IS_MACOS) + if (!io.WantCaptureMouse || shouldPassEventsToGDButTransformed()) { + return ListenerResult::Propagate; + } + + return ListenerResult::Stop; + }).leak(); +} + +#if defined(GEODE_IS_MACOS) +class $modify(CCKeyboardDispatcher) { static void onModify(auto& self) { Result<> res = self.setHookPriorityBeforePre("CCKeyboardDispatcher::updateModifierKeys", "geode.custom-keybinds"); if (!res) { @@ -547,6 +544,5 @@ class $modify(CCKeyboardDispatcher) { io.AddKeyEvent(ImGuiKey_ModSuper, cmd); CCKeyboardDispatcher::updateModifierKeys(shft, ctrl, alt, cmd); } - #endif }; #endif \ No newline at end of file From 1d27787a83daff22bc1964fc5eb98d410ea3903a Mon Sep 17 00:00:00 2001 From: km7dev <100500023+Kingminer7@users.noreply.github.com> Date: Fri, 27 Feb 2026 17:45:35 -0500 Subject: [PATCH 3/4] Did not notice this somehow --- src/backend.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend.cpp b/src/backend.cpp index 418496b..8293965 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -482,16 +482,16 @@ static float SCROLL_SENSITIVITY = 10; // CCIMEDispatcher stuff only gets called on mobile if the virtual keyboard would be up. // Similarly, CCKeyboardDispatcher doesn't get called if the virtual keyboard would be up. #ifdef GEODE_IS_MOBILE - if (down) { + if (data.action != KeyboardEventData::Action::Release) { char c = 0; - if (key >= KEY_A && key <= KEY_Z) { - c = static_cast(key); + if (data.key >= KEY_A && data.key <= KEY_Z) { + c = static_cast(data.key); if (!io.KeyShift) { c = static_cast(tolower(c)); } - } else if (key >= KEY_Zero && key <= KEY_Nine) { - c = static_cast('0' + (key - KEY_Zero)); - } else if (key == KEY_Space) { + } else if (data.key >= KEY_Zero && data.key <= KEY_Nine) { + c = static_cast('0' + (data.key - KEY_Zero)); + } else if (data.key == KEY_Space) { c = ' '; } @@ -500,7 +500,7 @@ static float SCROLL_SENSITIVITY = 10; io.AddInputCharactersUTF8(str.c_str()); } } - if (key == KEY_Backspace) { + if (data.key == KEY_Backspace) { io.AddKeyEvent(ImGuiKey_Backspace, true); io.AddKeyEvent(ImGuiKey_Backspace, false); } @@ -545,4 +545,4 @@ class $modify(CCKeyboardDispatcher) { CCKeyboardDispatcher::updateModifierKeys(shft, ctrl, alt, cmd); } }; -#endif \ No newline at end of file +#endif From 264782890700924f9cf0fff92e3f88066c335881 Mon Sep 17 00:00:00 2001 From: km7dev <100500023+Kingminer7@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:14:39 -0500 Subject: [PATCH 4/4] fix another mistake --- src/backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.cpp b/src/backend.cpp index 8293965..bd6c7b7 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -482,7 +482,7 @@ static float SCROLL_SENSITIVITY = 10; // CCIMEDispatcher stuff only gets called on mobile if the virtual keyboard would be up. // Similarly, CCKeyboardDispatcher doesn't get called if the virtual keyboard would be up. #ifdef GEODE_IS_MOBILE - if (data.action != KeyboardEventData::Action::Release) { + if (data.action != KeyboardInputData::Action::Release) { char c = 0; if (data.key >= KEY_A && data.key <= KEY_Z) { c = static_cast(data.key);