This repository was archived by the owner on Jul 5, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
implement horizontal scrolling with trackpad to windows (and bring ba… #666
Open
altalk23
wants to merge
1
commit into
HJfod:v6
Choose a base branch
from
altalk23:v6
base: v6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
|
|
@@ -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"); | ||
|
|
||
| (void)self.setHookPriority("cocos2d::CCEGLView::onGLFWMouseScrollCallback", Priority::Replace); | ||
| } | ||
|
|
||
| static MouseScrollWindowsFix* get() { | ||
| return static_cast<MouseScrollWindowsFix*>(CCEGLView::get()); | ||
| } | ||
|
|
||
| // | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a good comment i like it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this is a good review comment i like it |
||
| $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) { | ||
|
|
@@ -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 | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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............