Skip to content

Commit

Permalink
prevent other hooks of keyDown from being triggered twice
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Feb 14, 2024
1 parent 228e106 commit 1f00646
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/EditorUI.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <Geode/Bindings.hpp>
#include <Geode/modify/EditorUI.hpp>
#include <Geode/modify/EditorPauseLayer.hpp>
#include <unordered_map>
Expand Down
8 changes: 6 additions & 2 deletions src/UILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ struct $modify(PauseLayer) {

struct $modify(UILayer) {
static void onModify(auto& self) {
(void)self.setHookPriority("UILayer::keyDown", 1000);
(void)self.setHookPriority("UILayer::keyUp", 1000);
// These are negative because in this class we make a lot of use of the fallthrough trick,
// and if a mod hooks these functions (cough megahack), then their hook gets called twice.
// Doing this makes their hook only get called once, although `key` will be the key we are pretending to press,
// however i think its a fair compromise.
(void)self.setHookPriority("UILayer::keyDown", -1000);
(void)self.setHookPriority("UILayer::keyUp", -1000);
}

static inline int platformButton() {
Expand Down

0 comments on commit 1f00646

Please sign in to comment.