mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-30 15:08:31 +00:00
Use the new SDL_clamp() macro where sensible
There were a few places throughout the SDL code where values were clamped using SDL_min() and SDL_max(). Now that we have an SDL_clamp() macro, use this instead.
This commit is contained in:
@@ -146,7 +146,7 @@ static int SDL_DoEventLogging = 0;
|
||||
static void SDLCALL
|
||||
SDL_EventLoggingChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_DoEventLogging = (hint && *hint) ? SDL_max(SDL_min(SDL_atoi(hint), 2), 0) : 0;
|
||||
SDL_DoEventLogging = (hint && *hint) ? SDL_clamp(SDL_atoi(hint), 0, 2) : 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -783,9 +783,9 @@ IOS_AccelerometerUpdate(SDL_Joystick *joystick)
|
||||
*/
|
||||
|
||||
/* clamp the data */
|
||||
accel.x = SDL_min(SDL_max(accel.x, -maxgforce), maxgforce);
|
||||
accel.y = SDL_min(SDL_max(accel.y, -maxgforce), maxgforce);
|
||||
accel.z = SDL_min(SDL_max(accel.z, -maxgforce), maxgforce);
|
||||
accel.x = SDL_clamp(accel.x, -maxgforce, maxgforce);
|
||||
accel.y = SDL_clamp(accel.y, -maxgforce, maxgforce);
|
||||
accel.z = SDL_clamp(accel.z, -maxgforce, maxgforce);
|
||||
|
||||
/* pass in data mapped to range of SInt16 */
|
||||
SDL_PrivateJoystickAxis(joystick, 0, (accel.x / maxgforce) * maxsint16);
|
||||
|
@@ -925,7 +925,7 @@ keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard,
|
||||
int32_t rate, int32_t delay)
|
||||
{
|
||||
struct SDL_WaylandInput *input = data;
|
||||
input->keyboard_repeat.repeat_rate = SDL_max(0, SDL_min(rate, 1000));
|
||||
input->keyboard_repeat.repeat_rate = SDL_clamp(rate, 0, 1000);
|
||||
input->keyboard_repeat.repeat_delay = delay;
|
||||
input->keyboard_repeat.is_initialized = SDL_TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user