Skip to content

Commit

Permalink
fix modifiers not working + abi break lol
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 15, 2024
1 parent cb264d0 commit 7d5e24d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.7.1

- Fix modifiers not working with mouse buttons. This most likely breaks existing mouse button bindings
- Internal fixes

## v1.7.0

- Allow assigning mouse side buttons as keybinds
Expand Down
5 changes: 2 additions & 3 deletions include/Keybinds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ namespace keybinds {
CUSTOM_KEYBINDS_DLL bool keyIsController(cocos2d::enumKeyCodes key);

enum class MouseButton {
// Lol, sorry -HJfod
Button3 = 0,
Button4 = 1,
Button4 = 0,
Button5 = 1,
};

CUSTOM_KEYBINDS_DLL std::string mouseToString(MouseButton button);
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"win": "2.206",
"android": "2.206"
},
"version": "v1.7.0",
"version": "v1.7.1",
"id": "geode.custom-keybinds",
"name": "Custom Keybinds",
"developer": "Geode Team",
Expand Down
4 changes: 2 additions & 2 deletions src/Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ bool keybinds::keyIsController(enumKeyCodes key) {

std::string keybinds::mouseToString(MouseButton button) {
switch (button) {
case MouseButton::Button3: return "Page Back";
case MouseButton::Button4: return "Page Next";
case MouseButton::Button4: return "Page Back";
case MouseButton::Button5: return "Page Next";
default: return "Unknown (Mouse)";
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class $modify(CCEGLView){
void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int mods) {
std::optional<MouseButton> mb;
switch (button) {
case 3: mb = MouseButton::Button3; break;
case 4: mb = MouseButton::Button4; break;
case 3: mb = MouseButton::Button4; break;
case 4: mb = MouseButton::Button5; break;
default: break;
}
if (mb) {
Modifier modifiers;
Modifier modifiers = Modifier::None;
if (mods & GLFW_MOD_SHIFT) {
modifiers |= Modifier::Shift;
}
Expand All @@ -63,7 +63,6 @@ class $modify(CCEGLView){
modifiers |= Modifier::Control;
}
if (auto bind = MouseBind::create(*mb, modifiers)) {
log::info("post: {}", action == GLFW_PRESS);
if (PressBindEvent(bind, action == GLFW_PRESS).post() == ListenerResult::Stop) {
return;
}
Expand Down

0 comments on commit 7d5e24d

Please sign in to comment.