Skip to content

Instantly share code, notes, and snippets.

@VoodaGod
Created December 28, 2024 08:21
Show Gist options
  • Save VoodaGod/e4ac5363bd98b86cf7ab739101f852e5 to your computer and use it in GitHub Desktop.
Save VoodaGod/e4ac5363bd98b86cf7ab739101f852e5 to your computer and use it in GitHub Desktop.
gamescope mouse sensitivity <0 dead range fix
--- a/src/wlserver.cpp
+++ b/src/wlserver.cpp
@@ -2336,6 +2336,8 @@ static bool wlserver_apply_constraint( double *dx, double *dy )
return true;
}
+static double rem_x = 0.0;
+static double rem_y = 0.0;
void wlserver_mousemotion( double dx, double dy, uint32_t time )
{
assert( wlserver_is_lock_held() );
@@ -2343,6 +2345,14 @@ void wlserver_mousemotion( double dx, double dy, uint32_t time )
dx *= g_mouseSensitivity;
dy *= g_mouseSensitivity;
+ dx += rem_x;
+ dy += rem_y;
+ rem_x = fmod(dx, 1.0);
+ rem_y = fmod(dy, 1.0);
+ dx -= rem_x;
+ dy -= rem_y;
+ if (abs(dx) <= 0 && abs(dy) <= 0) return;
+
wlserver_perform_rel_pointer_motion( dx, dy );
if ( !wlserver_apply_constraint( &dx, &dy ) )
@VoodaGod
Copy link
Author

VoodaGod commented Dec 28, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment