Skip to content
This repository was archived by the owner on Jul 5, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@
"platforms": ["desktop"],
"enable-if": "enable-fixed-mouse-controls"
},
"mouse-scroll-sensitivity": {
"type": "float",
"default": 32.0,
"name": "Mouse Scroll Sensitivity",
"description": "Controls the sensitivity of the mouse scroll input.",
"platforms": ["win"],
"enable-if": "enable-fixed-mouse-controls"
},
"pinch-to-zoom": {
"type": "bool",
"default": true,
Expand Down
68 changes: 50 additions & 18 deletions src/features/FixMouseControls.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include <Geode/modify/EditorUI.hpp>
#include <Geode/modify/CCEGLView.hpp>
#include <Geode/loader/Mod.hpp>
#include <Geode/binding/LevelEditorLayer.hpp>
#include <Geode/utils/cocos.hpp>
Expand All @@ -13,6 +14,38 @@ using namespace geode::prelude;

#ifdef GEODE_IS_DESKTOP

#ifdef GEODE_IS_WINDOWS

class $modify(MouseScrollWindowsFix, CCEGLView){
static void onModify(auto& self) {
// The static version inlines the actual callback, so i uninline it by hooking it
(void)Mod::get()->hook((void*)(base::getCocos() + 0x76390), &MouseScrollWindowsFix::onGLFWMouseScrollCallbackStatic, "onGLFWMouseScrollCallbackStatic");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this wont work on 2.207 but im not sure............


(void)self.setHookPriority("cocos2d::CCEGLView::onGLFWMouseScrollCallback", Priority::Replace);
}

static MouseScrollWindowsFix* get() {
return static_cast<MouseScrollWindowsFix*>(CCEGLView::get());
}

//

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good comment i like it
yes im a qualified betteredit reviewer official now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good comment i like it yes im a qualified betteredit reviewer official now

this is a good review comment i like it
i'm not a qualified betteredit reviewer unofficial real

$override
void onGLFWMouseScrollCallback(GLFWwindow* window, double xpos, double ypos) {
if (!Mod::get()->getSettingValue<bool>("enable-fixed-mouse-controls")) {
return CCEGLView::onGLFWMouseScrollCallback(window, xpos, ypos);
}

auto sensitivity = Mod::get()->getSettingValue<double>("mouse-scroll-sensitivity");
CCDirector::get()->getMouseDispatcher()->dispatchScrollMSG(-ypos * sensitivity, xpos * sensitivity);
}

static void onGLFWMouseScrollCallbackStatic(GLFWwindow* window, double xpos, double ypos) {
MouseScrollWindowsFix::get()->CCEGLView::onGLFWMouseScrollCallback(window, xpos, ypos);
}
};

#endif

class $modify(EditorUI) {
$override
virtual void scrollWheel(float y, float x) {
Expand Down Expand Up @@ -60,27 +93,26 @@ class $modify(EditorUI) {
}
// otherwise move screen
else {
constexpr float mult = 2.f;

// move horizontally on shift
if (CCKeyboardDispatcher::get()->getShiftKeyPressed()) {
objLayer->setPositionX(
objLayer->getPositionX() - y * mult
);
// move normally if x doesnt exist
if (std::fabs(x) < std::numeric_limits<float>::epsilon()) {
// move horizontally on shift
if (CCKeyboardDispatcher::get()->getShiftKeyPressed()) {
objLayer->setPositionX(
objLayer->getPositionX() - y
);
}
// otherwise move as is in vanilla
else {
objLayer->setPositionY(
objLayer->getPositionY() + y
);
}
}
// otherwise move as is in vanilla
// use both axes, ignore shift
else {
// add support for the horizontal trackpad scrolling on mac
// causes the editor to move sideways when scrolling on windows
#ifdef GEODE_IS_MACOS
objLayer->setPositionX(
objLayer->getPositionX() + y * mult
);
#else
objLayer->setPositionY(
objLayer->getPositionY() + y * mult
objLayer->setPosition(
objLayer->getPosition() + ccp(x, y)
);
#endif
}

// call original but make it not do anything other than update
Expand Down