Prevent mouse from going beyond monitor bounds when gaming

I have a dual-monitor setup and I noticed in at least one game (Starfield) that the mouse cursor is not locked to the monitor while moving the mouse in-game. It is very annoying especially in FPS/third-person games where you move around the mouse a lot and then suddenly lose focus of the game because the mouse is on your other monitor.
Is there a way to prevent this from happening? I am not using game mode, just the normal desktop mode.

I ran into the same thing playing El Paso, Elsewhere. I ended up just disabling my laptop’s built-in display as a workaround. That’s the only game so far that I’ve encountered this issue on.

I ran into the same issue with Redfall and A Game About Digging a Hole
The solution for me was to run those games through gamescope and using the force grab cursor argument (add this to the game’s launch arguments on steam):
gamescope --force-grab-cursor – %command%
Note that for some games you need to specify native and output resolution for the game to run properly: example with 2560*1440
gamescope -w 2560 -h 1440 -W 2560 -H 1440 --force-grab-cursor – %command%

Gamescope solved the mouse locking problem, however it introduced a new problem, namely the steam overlay (with shift-tab) doesn’t work anymore when using it.
After searching around a bit I also discovered that there is something called ScopeBuddy installed on Bazzite (ScopeBuddy - Bazzite Documentation) which claims can fix the steam overlay, but it doesn’t (at least for me).
I also found an open issue of gamescope breaking the overlay: Gamescope breaks Steam Overlay · Issue #835 · ValveSoftware/gamescope · GitHub

1 Like

Found another fix, posting here if anyone runs into this problem again:
I ran into the same issue with Stalker 2, but gamescope wouldn’t work with it, but I stumbled upon this post talking about how ProtonGE could fix it: Reddit - The heart of the internet
So I downloaded the latest ProtonGE using proton plus, set Stalker 2 to launch with it in compatibility options, and added PROTON_ENABLE_WAYLAND=1 %command% to launch options.
From my understanding, this issue can happen when using XWayland, so forcing native wayland fixes it, in Stalker 2 at least, haven’t tested with other games yet.

Hello, have you still had issues?

I have a multi monitor setup, different resolutions (1440p and 2160p) and I had bad mouse issues with Halo Infinite. Ultimately, I run the game through gamescope if you are not doing that. Resolutions are annoying with gamescope, but that is easier if you configure scopebuddy.

The command –-force-grab-cursor allowed me to play Halo without mouse capturing issues.

In total, my launch command looked like:

gamescope -H 2160 -f -b --force-grab-cursor --hdr-enabled --adaptive-sync --mangoapp -- %command%

I recommend looking at scopebuddy:

1 Like