From e5f80430377bdc0259eab1f477661216c0ffcc0a Mon Sep 17 00:00:00 2001
From: expikr <[EMAIL REDACTED]>
Date: Wed, 19 Mar 2025 02:05:17 +0800
Subject: [PATCH] chore: rename integer mode field names
(cherry picked from commit f52f982b1e9ce2f510f2c26c6119e79dbb5b20a0)
---
src/events/SDL_mouse.c | 18 +++++++++---------
src/events/SDL_mouse_c.h | 12 +++++++-----
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 5d78c209ccca6..777733fe7724c 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -239,9 +239,9 @@ static void SDLCALL SDL_MouseIntegerModeChanged(void *userdata, const char *name
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
if (hint && *hint) {
- mouse->integer_mode = (Uint8)SDL_atoi(hint);
+ mouse->integer_mode_flags = (Uint8)SDL_atoi(hint);
} else {
- mouse->integer_mode = 0;
+ mouse->integer_mode_flags = 0;
}
}
@@ -734,10 +734,10 @@ static void SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL
y *= mouse->normal_speed_scale;
}
}
- if (mouse->integer_mode >= 1) {
+ if (mouse->integer_mode_flags & 1) {
// Accumulate the fractional relative motion and only process the integer portion
- mouse->xrel_frac = SDL_modff(mouse->xrel_frac + x, &x);
- mouse->yrel_frac = SDL_modff(mouse->yrel_frac + y, &y);
+ mouse->integer_mode_residual_motion_x = SDL_modff(mouse->integer_mode_residual_motion_x + x, &x);
+ mouse->integer_mode_residual_motion_y = SDL_modff(mouse->integer_mode_residual_motion_y + y, &y);
}
xrel = x;
yrel = y;
@@ -745,7 +745,7 @@ static void SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL
y = (mouse->last_y + yrel);
ConstrainMousePosition(mouse, window, &x, &y);
} else {
- if (mouse->integer_mode >= 1) {
+ if (mouse->integer_mode_flags & 1) {
// Discard the fractional component from absolute coordinates
x = SDL_truncf(x);
y = SDL_truncf(y);
@@ -1023,9 +1023,9 @@ void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseI
}
// Accumulate fractional wheel motion if integer mode is enabled
- if (mouse->integer_mode >= 2) {
- mouse->wheel_x_frac = SDL_modff(mouse->wheel_x_frac + x, &x);
- mouse->wheel_y_frac = SDL_modff(mouse->wheel_y_frac + y, &y);
+ if (mouse->integer_mode_flags & 2) {
+ mouse->integer_mode_residual_scroll_x = SDL_modff(mouse->integer_mode_residual_scroll_x + x, &x);
+ mouse->integer_mode_residual_scroll_y = SDL_modff(mouse->integer_mode_residual_scroll_y + y, &y);
}
if (x == 0.0f && y == 0.0f) {
diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h
index 8d8cf63676306..dd9a0c15ebce4 100644
--- a/src/events/SDL_mouse_c.h
+++ b/src/events/SDL_mouse_c.h
@@ -91,6 +91,13 @@ typedef struct
void (*ApplySystemScale)(void *internal, Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float *x, float *y);
void *system_scale_data;
+ // integer mode data
+ Uint8 integer_mode_flags; // 1 to enable mouse quantization, 2 to enable wheel quantization
+ float integer_mode_residual_motion_x;
+ float integer_mode_residual_motion_y;
+ float integer_mode_residual_scroll_x;
+ float integer_mode_residual_scroll_y;
+
// Data common to all mice
SDL_Window *focus;
float x;
@@ -98,13 +105,8 @@ typedef struct
float x_accu;
float y_accu;
float last_x, last_y; // the last reported x and y coordinates
- float xrel_frac;
- float yrel_frac;
- float wheel_x_frac;
- float wheel_y_frac;
double click_motion_x;
double click_motion_y;
- Uint8 integer_mode;
bool has_position;
bool relative_mode;
bool relative_mode_warp_motion;