From 4b27ef36cda085d5a8580c5ecc495eac1a51f726 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Sat, 4 Oct 2025 23:29:47 -0300 Subject: [PATCH 1/3] make custom keybinds optional on windows --- mod.json | 6 +++--- src/main.cpp | 51 ++++++++++++++++++++++++++++++++----------------- src/windows.cpp | 8 ++++++-- src/windows.hpp | 1 + 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/mod.json b/mod.json index b302fbf..0a0532a 100644 --- a/mod.json +++ b/mod.json @@ -1,5 +1,5 @@ { - "geode": "4.4.0", + "geode": "4.9.0", "gd": { "win": "2.2074", "android": "2.2074", @@ -13,8 +13,8 @@ "description": "Allows inputs to register between frames.", "dependencies": { "geode.custom-keybinds": { - "importance": "required", - "version": ">=v1.10.0", + "importance": "suggested", + "version": ">=v1.11.0", "platforms": ["win"] } }, diff --git a/src/main.cpp b/src/main.cpp index b56e734..a3dfd14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,6 +39,7 @@ bool skipUpdate = true; // true -> dont split steps during PlayerObject::update( bool enableInput = false; bool linuxNative = false; bool lateCutoff; // false -> ignore inputs that happen after the start of the frame; true -> check for inputs at the latest possible moment +bool useCustomKeybinds = false; std::array, 6> inputBinds; std::unordered_set heldInputs; @@ -141,37 +142,51 @@ Step popStepQueue() { } #ifdef GEODE_IS_WINDOWS -#include +#include /* send list of keybinds to the input thread */ void updateKeybinds() { - std::array, 6> binds; - std::vector> v; - enableRightClick.store(Mod::get()->getSettingValue("right-click")); - v = keybinds::BindManager::get()->getBindsFor("robtop.geometry-dash/jump-p1"); - for (int i = 0; i < v.size(); i++) binds[p1Jump].emplace(v[i]->getHash()); - - v = keybinds::BindManager::get()->getBindsFor("robtop.geometry-dash/move-left-p1"); - for (int i = 0; i < v.size(); i++) binds[p1Left].emplace(v[i]->getHash()); + auto* mod = Loader::get()->getLoadedMod("geode.custom-keybinds"); + useCustomKeybinds = mod && mod->isEnabled(); - v = keybinds::BindManager::get()->getBindsFor("robtop.geometry-dash/move-right-p1"); - for (int i = 0; i < v.size(); i++) binds[p1Right].emplace(v[i]->getHash()); + if (!useCustomKeybinds) { + std::lock_guard lock(keybindsLock); + // controller ones probably dont do anything but lets match CK + inputBinds[p1Jump] = { KEY_Space, KEY_W, CONTROLLER_A, CONTROLLER_Up, CONTROLLER_RB }; + inputBinds[p1Left] = { KEY_A, CONTROLLER_Left, CONTROLLER_LTHUMBSTICK_LEFT }; + inputBinds[p1Right] = { KEY_D, CONTROLLER_Right, CONTROLLER_LTHUMBSTICK_RIGHT }; + + inputBinds[p2Jump] = { KEY_Up, CONTROLLER_LB }; + inputBinds[p2Left] = { KEY_Left, CONTROLLER_RTHUMBSTICK_LEFT }; + inputBinds[p2Right] = { KEY_Right, CONTROLLER_RTHUMBSTICK_RIGHT }; + return; + } - v = keybinds::BindManager::get()->getBindsFor("robtop.geometry-dash/jump-p2"); - for (int i = 0; i < v.size(); i++) binds[p2Jump].emplace(v[i]->getHash()); + std::array, 6> bindsSet; - v = keybinds::BindManager::get()->getBindsFor("robtop.geometry-dash/move-left-p2"); - for (int i = 0; i < v.size(); i++) binds[p2Left].emplace(v[i]->getHash()); + const auto loadBinds = [&](int key, std::string const& id) -> geode::Result<> { + GEODE_UNWRAP_INTO(auto binds, keybinds::BindManagerV2::getBindsFor(id)); + for (auto const& bind : binds) { + // this should probably be using Keybind::getKey instead of getHash, + // but no way to call that from the optional api atm + bindsSet[key].emplace(bind->getHash()); + } + return Ok(); + }; - v = keybinds::BindManager::get()->getBindsFor("robtop.geometry-dash/move-right-p2"); - for (int i = 0; i < v.size(); i++) binds[p2Right].emplace(v[i]->getHash()); + (void) loadBinds(p1Jump, "robtop.geometry-dash/jump-p1"); + (void) loadBinds(p1Left, "robtop.geometry-dash/move-left-p1"); + (void) loadBinds(p1Right, "robtop.geometry-dash/move-right-p1"); + (void) loadBinds(p2Jump, "robtop.geometry-dash/jump-p2"); + (void) loadBinds(p2Left, "robtop.geometry-dash/move-left-p2"); + (void) loadBinds(p2Right, "robtop.geometry-dash/move-right-p2"); { std::lock_guard lock(keybindsLock); - inputBinds = binds; + inputBinds = std::move(bindsSet); } } #endif diff --git a/src/windows.cpp b/src/windows.cpp index a68dd41..9fac9be 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -1,5 +1,5 @@ #include "includes.hpp" -#include +#include TimestampType getCurrentTimestamp() { LARGE_INTEGER t; @@ -92,7 +92,11 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) else if (flags & RI_MOUSE_BUTTON_2_UP) inputState = Release; else return 0; - queueInMainThread([inputState]() {keybinds::InvokeBindEvent("robtop.geometry-dash/jump-p2", inputState).post();}); + if (useCustomKeybinds) { + queueInMainThread([inputState]() { + keybinds::InvokeBindEventV2("robtop.geometry-dash/jump-p2", inputState).post(); + }); + } } QueryPerformanceCounter(&time); // dont call on mouse move events diff --git a/src/windows.hpp b/src/windows.hpp index 8962589..8d41d07 100644 --- a/src/windows.hpp +++ b/src/windows.hpp @@ -14,6 +14,7 @@ extern HANDLE hMutex; extern LPVOID pBuf; extern bool linuxNative; +extern bool useCustomKeybinds; inline LARGE_INTEGER largeFromTimestamp(TimestampType t) { LARGE_INTEGER res; From 7548c7ce288df7dea7096f996573b3f30d8180f4 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Tue, 7 Oct 2025 00:37:32 -0300 Subject: [PATCH 2/3] properly implement p2 jump when no custom keybinds --- src/windows.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/windows.cpp b/src/windows.cpp index 9fac9be..f4f9725 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -92,11 +92,16 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) else if (flags & RI_MOUSE_BUTTON_2_UP) inputState = Release; else return 0; - if (useCustomKeybinds) { - queueInMainThread([inputState]() { + queueInMainThread([inputState]() { + if (useCustomKeybinds) { keybinds::InvokeBindEventV2("robtop.geometry-dash/jump-p2", inputState).post(); - }); - } + } else { + auto* pl = PlayLayer::get(); + if (pl == nullptr || pl != CCScene::get()->getChildByType(0)) return; + pl->queueButton(1, inputState, true); + pl->m_uiLayer->m_p2Jumping = inputState; + } + }); } QueryPerformanceCounter(&time); // dont call on mouse move events From 0c1ab7090a1c9164005f7820eefdec4c43eaf0d5 Mon Sep 17 00:00:00 2001 From: matcool <26722564+matcool@users.noreply.github.com> Date: Tue, 7 Oct 2025 01:01:47 -0300 Subject: [PATCH 3/3] actually use it regardless of customkeybinds --- src/windows.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/windows.cpp b/src/windows.cpp index f4f9725..49d6834 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -1,5 +1,4 @@ #include "includes.hpp" -#include TimestampType getCurrentTimestamp() { LARGE_INTEGER t; @@ -93,14 +92,11 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) else return 0; queueInMainThread([inputState]() { - if (useCustomKeybinds) { - keybinds::InvokeBindEventV2("robtop.geometry-dash/jump-p2", inputState).post(); - } else { - auto* pl = PlayLayer::get(); - if (pl == nullptr || pl != CCScene::get()->getChildByType(0)) return; - pl->queueButton(1, inputState, true); - pl->m_uiLayer->m_p2Jumping = inputState; - } + auto* pl = PlayLayer::get(); + // check for fake playlayers + if (pl == nullptr || pl != CCScene::get()->getChildByType(0)) return; + pl->queueButton(1, inputState, true); + pl->m_uiLayer->m_p2Jumping = inputState; }); }