Skip to content

Use SDL relative mouse mode for right click dragging where available #3022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

LeeSpork
Copy link
Contributor

The benefit of this is that the mouse is not able to get stopped by the edges of the monitor when using relative mode, thus slightly improving the user experience. Now right mouse dragging works as expected even you start from the edge of your screen!

@@ -56,7 +57,17 @@ namespace OpenLoco::Input
_cursorDragState = 1;
auto cursor = Ui::getCursorPos();
_cursorDragStart = cursor;
Ui::hideCursor();

auto result = SDL_SetRelativeMouseMode(SDL_TRUE);
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be a game option the user can enable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. SDL_SetRelativeMouseMode is, as far as I can tell, a better implementation of a feature OpenLoco had implemented (hiding the cursor and detecting relative mouse motion, without your mouse movements being limited by the size of your screen/window).
It should be look and feel exactly the same to users, except it will now work properly even in edge cases such as starting the right click drag from a position near the edge of your monitor.

The only reason I left the old system in as a fallback is because the documentation says "If relative mode is not supported, this returns -1", and I was being perhaps overly cautious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants