From 9e188aa0a075fcd892c9f9f66f998b32312e9092 Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Fri, 14 Feb 2025 10:23:12 +0000 Subject: [PATCH] Misc: Handle SDL2-SDL3 int->bool return type changes --- pcsx2/Host/SDLAudioStream.cpp | 2 +- pcsx2/Input/SDLInputSource.cpp | 6 +++--- pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pcsx2/Host/SDLAudioStream.cpp b/pcsx2/Host/SDLAudioStream.cpp index 4969ea8f44..0fc4a8a66f 100644 --- a/pcsx2/Host/SDLAudioStream.cpp +++ b/pcsx2/Host/SDLAudioStream.cpp @@ -41,7 +41,7 @@ static bool InitializeSDLAudio(Error* error) SDL_SetHint("SDL_AUDIO_DEVICE_APP_NAME", "PCSX2"); // May as well keep it alive until the process exits. - if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) + if (!SDL_InitSubSystem(SDL_INIT_AUDIO)) { Error::SetStringFmt(error, "SDL_InitSubSystem(SDL_INIT_AUDIO) failed: {}", SDL_GetError()); return false; diff --git a/pcsx2/Input/SDLInputSource.cpp b/pcsx2/Input/SDLInputSource.cpp index 464fff9a8f..b1b7f442da 100644 --- a/pcsx2/Input/SDLInputSource.cpp +++ b/pcsx2/Input/SDLInputSource.cpp @@ -296,7 +296,7 @@ void SDLInputSource::SetHints() bool SDLInputSource::InitializeSubsystem() { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC) < 0) + if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC)) { Console.Error("SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC) failed"); return false; @@ -738,7 +738,7 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller) SDL_GetNumJoystickAxes(joystick), SDL_GetNumJoystickButtons(joystick), num_hats); } - cd.use_game_controller_rumble = (gcontroller && SDL_RumbleGamepad(gcontroller, 0, 0, 0) == 0); + cd.use_game_controller_rumble = (gcontroller && SDL_RumbleGamepad(gcontroller, 0, 0, 0)); if (cd.use_game_controller_rumble) { INFO_LOG("SDLInputSource: Rumble is supported on '{}' via gamecontroller", name); @@ -761,7 +761,7 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller) else { ERROR_LOG("SDLInputSource: Failed to create haptic left/right effect: {}", SDL_GetError()); - if (SDL_HapticRumbleSupported(haptic) && SDL_InitHapticRumble(haptic) != 0) + if (SDL_HapticRumbleSupported(haptic) && SDL_InitHapticRumble(haptic)) { cd.haptic = haptic; } diff --git a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp index 47fa61abbf..d997046421 100644 --- a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp +++ b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp @@ -199,7 +199,7 @@ namespace usb_pad if (m_constant_effect.constant.level != new_level) { m_constant_effect.constant.level = new_level; - if (SDL_UpdateHapticEffect(m_haptic, m_constant_effect_id, &m_constant_effect) != 0) + if (!SDL_UpdateHapticEffect(m_haptic, m_constant_effect_id, &m_constant_effect)) Console.Warning("SDL_UpdateHapticEffect() for constant failed: %s", SDL_GetError()); } @@ -217,7 +217,7 @@ namespace usb_pad // This is the reason for use_ffb_dropout_workaround. if (!m_constant_effect_running || use_ffb_dropout_workaround) { - if (SDL_RunHapticEffect(m_haptic, m_constant_effect_id, SDL_HAPTIC_INFINITY) == 0) + if (SDL_RunHapticEffect(m_haptic, m_constant_effect_id, SDL_HAPTIC_INFINITY)) m_constant_effect_running = true; else Console.Error("SDL_RunHapticEffect() for constant failed: %s", SDL_GetError()); @@ -248,12 +248,12 @@ namespace usb_pad m_spring_effect.condition.deadband[0] = ClampU16(ff.u.condition.deadband); m_spring_effect.condition.center[0] = ClampS16(ff.u.condition.center); - if (SDL_UpdateHapticEffect(m_haptic, m_spring_effect_id, &m_spring_effect) != 0) + if (!SDL_UpdateHapticEffect(m_haptic, m_spring_effect_id, &m_spring_effect)) Console.Warning("SDL_UpdateHapticEffect() for spring failed: %s", SDL_GetError()); if (!m_spring_effect_running) { - if (SDL_RunHapticEffect(m_haptic, m_spring_effect_id, SDL_HAPTIC_INFINITY) == 0) + if (SDL_RunHapticEffect(m_haptic, m_spring_effect_id, SDL_HAPTIC_INFINITY)) m_spring_effect_running = true; else Console.Error("SDL_RunHapticEffect() for spring failed: %s", SDL_GetError()); @@ -272,12 +272,12 @@ namespace usb_pad m_damper_effect.condition.deadband[0] = ClampU16(ff.u.condition.deadband); m_damper_effect.condition.center[0] = ClampS16(ff.u.condition.center); - if (SDL_UpdateHapticEffect(m_haptic, m_damper_effect_id, &m_damper_effect) != 0) + if (!SDL_UpdateHapticEffect(m_haptic, m_damper_effect_id, &m_damper_effect)) Console.Warning("SDL_UpdateHapticEffect() for damper failed: %s", SDL_GetError()); if (!m_damper_effect_running) { - if (SDL_RunHapticEffect(m_haptic, m_damper_effect_id, SDL_HAPTIC_INFINITY) == 0) + if (SDL_RunHapticEffect(m_haptic, m_damper_effect_id, SDL_HAPTIC_INFINITY)) m_damper_effect_running = true; else Console.Error("SDL_RunHapticEffect() for damper failed: %s", SDL_GetError()); @@ -296,9 +296,9 @@ namespace usb_pad m_friction_effect.condition.deadband[0] = ClampU16(ff.u.condition.deadband); m_friction_effect.condition.center[0] = ClampS16(ff.u.condition.center); - if (SDL_UpdateHapticEffect(m_haptic, m_friction_effect_id, &m_friction_effect) != 0) + if (!SDL_UpdateHapticEffect(m_haptic, m_friction_effect_id, &m_friction_effect)) { - if (!m_friction_effect_running && SDL_RunHapticEffect(m_haptic, m_friction_effect_id, SDL_HAPTIC_INFINITY) == 0) + if (!m_friction_effect_running && SDL_RunHapticEffect(m_haptic, m_friction_effect_id, SDL_HAPTIC_INFINITY)) m_friction_effect_running = true; else Console.Error("SDL_UpdateHapticEffect() for friction failed: %s", SDL_GetError()); @@ -309,7 +309,7 @@ namespace usb_pad { if (m_autocenter_supported) { - if (SDL_SetHapticAutocenter(m_haptic, value) != 0) + if (!SDL_SetHapticAutocenter(m_haptic, value)) Console.Warning("SDL_SetHapticAutocenter() failed: %s", SDL_GetError()); } }