-
Notifications
You must be signed in to change notification settings - Fork 252
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
[Runtime Issue]: Mouse input code misses multiple mouse events per timestep leading to jerky mouselook #634
Comments
Hello. I've tested suggested changes and cannot confirm that mouse movement became better. On high resolutions (like 1920x1080) mouselook is still not smooth. I've tested both on mouse grab and mouse free modes. |
I added some logging statements to the code: diff --git a/ddio/lnxmouse.cpp b/ddio/lnxmouse.cpp
index 558d2519..61eeecde 100644
--- a/ddio/lnxmouse.cpp
+++ b/ddio/lnxmouse.cpp
@@ -399,6 +399,7 @@ int sdlMouseMotionFilter(SDL_Event const *event) {
DDIO_mouse_state.dy = event->motion.yrel;
DDIO_mouse_state.x += DDIO_mouse_state.dx;
DDIO_mouse_state.y += DDIO_mouse_state.dy;
+ LOG_WARNING.printf("event dx, dy: %d, %d", DDIO_mouse_state.dx, DDIO_mouse_state.dy);
} // if
else {
DDIO_mouse_state.dx = event->motion.x - DDIO_mouse_state.x;
@@ -435,6 +436,8 @@ int ddio_MouseGetState(int *x, int *y, int *dx, int *dy, int *z, int *dz) {
// update mouse timer.
int btn_mask = DDIO_mouse_state.btn_mask;
+ LOG_WARNING.printf("ddio_MouseGetState: dx=%d dy=%d", DDIO_mouse_state.dx, DDIO_mouse_state.dy);
+
// get return values.
if (x)
*x = DDIO_mouse_state.x;
diff --git a/ddio/sdlcontroller.cpp b/ddio/sdlcontroller.cpp
index 35eadbb0..9d394f3a 100644
--- a/ddio/sdlcontroller.cpp
+++ b/ddio/sdlcontroller.cpp
@@ -1237,6 +1237,7 @@ float sdlgameController::get_axis_value(int8_t controller, uint8_t axis, ct_form
if (invert)
val = -val;
+ LOG_WARNING.printf("mouselook x: %f", val);
vm_AnglesToMatrix(&orient, 0.0, val * (((float)(65535.0f / 20)) * .5), 0.0);
@@ -1260,6 +1261,7 @@ float sdlgameController::get_axis_value(int8_t controller, uint8_t axis, ct_form
if (invert)
val = -val;
+ LOG_WARNING.printf("mouselook y: %f", val);
vm_AnglesToMatrix(&orient, val * (((float)(65535.0f / 20)) * .5), 0.0, 0.0);
Then I launched the game and moved the mouse at various speeds. Here's the the logs with slow and fast mouse movement with unmodified mouse code:
My understanding of what's happening is that Then, I implemented my changes, and turned down the mouse sensitivity. Here's the logs with slow + fast mouse movement:
Now the |
I tried the changes and can confirm that the mouse movement is faster in the game. Without the changes I tried a mouse sensitivity of 0.2 which also allows pixel So far I believe
|
Build Version
398699e
Operating System Environment
CPU Environment
Game Modes Affected
Game Environment
No response
Description
Mouselook is very jerky regardless of sensitivity settings. The issue is that the code in lnxmouse.cpp sets the dx/dy values based on the xrel/yrel values, which discards the xrel/yrel values coming from earlier mouse events in the same timestep. Here's how I fixed it:
Note that this makes the mouse move a lot faster than in the base game, necessitating rescaling the mouse sensitivity in some way. I opted to increase the resolution of the sensitivity range, and then turn down the sensitivity:
I don't know the implication of these changes, but I figured I'd share these rough versions of them in case they can help a well-thought-out solution. For me at least, this is an enormously impactful change, making mouselook actually a viable way to play.
Regression Status
No response
Steps to Reproduce
The text was updated successfully, but these errors were encountered: