From 54ea3c47c8ec50c62126ef7e01c21efc0c19799b Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Wed, 25 Nov 2020 07:48:00 -0500 Subject: [PATCH] controllers/npad: Make press_state atomic --- src/core/hle/service/hid/controllers/npad.cpp | 2 +- src/core/hle/service/hid/controllers/npad.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index f6a0770bf9..d280e7caf9 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -1058,7 +1058,7 @@ void Controller_NPad::ClearAllControllers() { } u32 Controller_NPad::GetAndResetPressState() { - return std::exchange(press_state, 0); + return press_state.exchange(0); } bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const { diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 9fac002318..e2e8266237 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include "common/bit_field.h" #include "common/common_types.h" #include "core/frontend/input.h" @@ -415,7 +416,7 @@ private: bool IsControllerSupported(NPadControllerType controller) const; void RequestPadStateUpdate(u32 npad_id); - u32 press_state{}; + std::atomic press_state{}; NpadStyleSet style{}; std::array shared_memory_entries{};