Page 1 of 1

[1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Fri Jul 28, 2023 12:04 pm
by undefiened
On Steam Deck one can enable "Gamepad with Mouse Trackpad" mode, which means that controller buttons work normally, but the right trackpad serves as a mouse.
The game cursor can be moved either by the right gamepad stick or by the trackpad (which works as a mouse).
If I move the cursor by the trackpad (mouse) from the center of the screen to the bottom left corner, and then use the right stick, then the cursor moves from the bottom left corner (i.e., where it was left by the trackpad).
However, if I move the cursor from the center of the screen to the bottom left corner using the right gamepad stick, then when I use the trackpad (mouse) the cursor jumps back to the center of the screen.

It looks like the right gamepad stick moves the cursor from where it is now, while the trackpad (mouse) "remembers" the last place where the cursor was put by the mouse and starts from there.

I hope it is understandable what I am trying to describe.

Re: [1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Fri Jul 28, 2023 2:09 pm
by Twinsen
What is happening is that there are 2 mouse cursors:
1. The system cursor.
2. The game's virtual cursor.

When using the trackpad, both cursors are moved. More precisely, the virtual cursor always follows the system cursor as it moves.
When using the right stick, only the virtual cursor is moved.

It works this way because I don't want to teleport the system cursor on desktop. This will make the system cursor teleport very often, such as when targeting entities or navigating guis. This can be annoying when e.g. using the mouse on a secondary screen and the game teleports your system cursor.
I also don't want to "grab" the system cursor as games do sometimes as I also found it very annoying to e.g. switch to other programs in window mode or use the mouse on secondary screens.

I can consider teleporting the system cursor on Steam Deck only. This will lead the the above mentioned annoyances in Steam Deck's desktop mode, but that's not a common use case.

Re: [1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Fri Jul 28, 2023 2:19 pm
by undefiened
Twinsen wrote:
Fri Jul 28, 2023 2:09 pm
What is happening is that there are 2 mouse cursors:
1. The system cursor.
2. The game's virtual cursor.

When using the trackpad, both cursors are moved. More precisely, the virtual cursor always follows the system cursor as it moves.
When using the right stick, only the virtual cursor is moved.

It works this way because I don't want to teleport the system cursor on desktop. This will make the system cursor teleport very often, such as when targeting entities or navigating guis. This can be annoying when e.g. using the mouse on a secondary screen and the game teleports your system cursor.
I also don't want to "grab" the system cursor as games do sometimes as I also found it very annoying to e.g. switch to other programs in window mode or use the mouse on secondary screens.

I can consider teleporting the system cursor on Steam Deck only. This will lead the the above mentioned annoyances in Steam Deck's desktop mode, but that's not a common use case.
Thank you for the detailed explanation!
Maybe it can be possible to introduce a new checkbox in the controls settings menu? "Override system cursor" and some help hint there along the lines of "Overrides system cursor but prevents cursor jumping when switching between mouse and gamepad. Useful for Steam Deck."

Re: [1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Fri Jul 28, 2023 4:23 pm
by Twinsen
In the end I solved it by moving the system cursor. It will only happen when the window is focused and the system cursor is inside the game window. This should avoid most of the annoyances related to the game moving the system cursor.

Fixed in Version: 1.1.89

Re: [1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Thu Aug 03, 2023 1:56 pm
by Twinsen
Turns out the previously mentioned fix didn't work because of some technicalities of how SDL handles mouse teleporting.

I fixed it by adding an option which is on by default on Steam Deck but off by default on PC.
Capture.PNG
Capture.PNG (26.84 KiB) Viewed 4761 times

Re: [1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Mon Aug 21, 2023 3:40 pm
by Twinsen
Unfortunately I had to revert this fix also as this method broke touch screen input.
I might look into other alternatives but it looks like this will have to stay as minor issue.

Re: [1.1.88] Cursor jumps when switching from gamepad to mouse (Steam Deck "Gamepad with Mouse Trackpad")

Posted: Mon Sep 04, 2023 3:35 pm
by Stewmat
In case you decide to revisit this later, I would add that the "capture system mouse" had a warping issue of its own; when opening the quick menu with L, the cursor would sometimes (not always?) warp to the position of the icon that was selected. I found this more annoying than the default behaviour because typically my cursor would already be near where I want to place the item and I'd need to move it back.