From c679de8e39047d2b4245b6801b94fee072a28cd2 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 10 Jun 2023 12:21:32 +0100 Subject: [PATCH] USB: Properly initialise effect unions (C rules gotcha) --- pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp | 4 ++++ pcsx2/USB/usb-pad/usb-pad-sdl-ff.h | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp index 42bd8166ba..6b4513de8b 100644 --- a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp +++ b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.cpp @@ -31,6 +31,10 @@ namespace usb_pad SDLFFDevice::SDLFFDevice(SDL_Haptic* haptic) : m_haptic(haptic) { + std::memset(&m_constant_effect, 0, sizeof(m_constant_effect)); + std::memset(&m_spring_effect, 0, sizeof(m_spring_effect)); + std::memset(&m_damper_effect, 0, sizeof(m_damper_effect)); + std::memset(&m_friction_effect, 0, sizeof(m_friction_effect)); } SDLFFDevice::~SDLFFDevice() diff --git a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h index daca5885b8..32b4401d60 100644 --- a/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h +++ b/pcsx2/USB/usb-pad/usb-pad-sdl-ff.h @@ -45,19 +45,19 @@ namespace usb_pad SDL_Haptic* m_haptic = nullptr; - SDL_HapticEffect m_constant_effect = {}; + SDL_HapticEffect m_constant_effect; int m_constant_effect_id = -1; bool m_constant_effect_running = false; - SDL_HapticEffect m_spring_effect = {}; + SDL_HapticEffect m_spring_effect; int m_spring_effect_id = -1; bool m_spring_effect_running = false; - SDL_HapticEffect m_damper_effect = {}; + SDL_HapticEffect m_damper_effect; int m_damper_effect_id = -1; bool m_damper_effect_running = false; - SDL_HapticEffect m_friction_effect = {}; + SDL_HapticEffect m_friction_effect; int m_friction_effect_id = -1; bool m_friction_effect_running = false;