Improve handling of High-DPI mice

- Reduce lower bound of mouse sensitivity
 - Add error accumulators to prevent small motions from being rounded off
This commit is contained in:
Jameson Ernst
2022-09-14 22:11:32 -07:00
parent 5996854ff5
commit 84f5d9c393
6 changed files with 15 additions and 5 deletions

View File

@@ -54,6 +54,7 @@ extern "C" {
#include <86box/video.h>
double mouse_sensitivity = 1.0;
double mouse_x_error = 0.0, mouse_y_error = 0.0;
}
struct mouseinputdata {
@@ -151,8 +152,14 @@ RendererStack::mousePoll()
#endif
this->mouse_poll_func();
mouse_x *= mouse_sensitivity;
mouse_y *= mouse_sensitivity;
double scaled_x = mouse_x * mouse_sensitivity + mouse_x_error;
double scaled_y = mouse_y * mouse_sensitivity + mouse_y_error;
mouse_x = static_cast<int>(scaled_x);
mouse_y = static_cast<int>(scaled_y);
mouse_x_error = scaled_x - mouse_x;
mouse_y_error = scaled_y - mouse_y;
}
int ignoreNextMouseEvent = 1;