mirror of https://github.com/libsdl-org/SDL.git
chore: rename integer mode field names
This commit is contained in:
parent
8407a16255
commit
f52f982b1e
|
|
@ -239,9 +239,9 @@ static void SDLCALL SDL_MouseIntegerModeChanged(void *userdata, const char *name
|
||||||
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
|
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
|
||||||
|
|
||||||
if (hint && *hint) {
|
if (hint && *hint) {
|
||||||
mouse->integer_mode = (Uint8)SDL_atoi(hint);
|
mouse->integer_mode_flags = (Uint8)SDL_atoi(hint);
|
||||||
} else {
|
} else {
|
||||||
mouse->integer_mode = 0;
|
mouse->integer_mode_flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -739,10 +739,10 @@ static void SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL
|
||||||
y *= mouse->normal_speed_scale;
|
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
|
// Accumulate the fractional relative motion and only process the integer portion
|
||||||
mouse->xrel_frac = SDL_modff(mouse->xrel_frac + x, &x);
|
mouse->integer_mode_residual_motion_x = SDL_modff(mouse->integer_mode_residual_motion_x + x, &x);
|
||||||
mouse->yrel_frac = SDL_modff(mouse->yrel_frac + y, &y);
|
mouse->integer_mode_residual_motion_y = SDL_modff(mouse->integer_mode_residual_motion_y + y, &y);
|
||||||
}
|
}
|
||||||
xrel = x;
|
xrel = x;
|
||||||
yrel = y;
|
yrel = y;
|
||||||
|
|
@ -750,7 +750,7 @@ static void SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL
|
||||||
y = (mouse->last_y + yrel);
|
y = (mouse->last_y + yrel);
|
||||||
ConstrainMousePosition(mouse, window, &x, &y);
|
ConstrainMousePosition(mouse, window, &x, &y);
|
||||||
} else {
|
} else {
|
||||||
if (mouse->integer_mode >= 1) {
|
if (mouse->integer_mode_flags & 1) {
|
||||||
// Discard the fractional component from absolute coordinates
|
// Discard the fractional component from absolute coordinates
|
||||||
x = SDL_truncf(x);
|
x = SDL_truncf(x);
|
||||||
y = SDL_truncf(y);
|
y = SDL_truncf(y);
|
||||||
|
|
@ -1028,9 +1028,9 @@ void SDL_SendMouseWheel(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accumulate fractional wheel motion if integer mode is enabled
|
// Accumulate fractional wheel motion if integer mode is enabled
|
||||||
if (mouse->integer_mode >= 2) {
|
if (mouse->integer_mode_flags & 2) {
|
||||||
mouse->wheel_x_frac = SDL_modff(mouse->wheel_x_frac + x, &x);
|
mouse->integer_mode_residual_scroll_x = SDL_modff(mouse->integer_mode_residual_scroll_x + x, &x);
|
||||||
mouse->wheel_y_frac = SDL_modff(mouse->wheel_y_frac + y, &y);
|
mouse->integer_mode_residual_scroll_y = SDL_modff(mouse->integer_mode_residual_scroll_y + y, &y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x == 0.0f && y == 0.0f) {
|
if (x == 0.0f && y == 0.0f) {
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,13 @@ typedef struct
|
||||||
SDL_MouseMotionTransformCallback InputTransform;
|
SDL_MouseMotionTransformCallback InputTransform;
|
||||||
void *input_transform_data;
|
void *input_transform_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
|
// Data common to all mice
|
||||||
SDL_Window *focus;
|
SDL_Window *focus;
|
||||||
float x;
|
float x;
|
||||||
|
|
@ -102,13 +109,8 @@ typedef struct
|
||||||
float x_accu;
|
float x_accu;
|
||||||
float y_accu;
|
float y_accu;
|
||||||
float last_x, last_y; // the last reported x and y coordinates
|
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_x;
|
||||||
double click_motion_y;
|
double click_motion_y;
|
||||||
Uint8 integer_mode;
|
|
||||||
bool has_position;
|
bool has_position;
|
||||||
bool relative_mode;
|
bool relative_mode;
|
||||||
bool relative_mode_warp_motion;
|
bool relative_mode_warp_motion;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue