summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers
diff options
context:
space:
mode:
authorMerry <git@mary.rs>2022-04-07 20:32:09 +0200
committerMerry <git@mary.rs>2022-04-07 20:44:07 +0200
commit159ae5e47ceff0a44c1021379cbca601b36f4fb0 (patch)
treea7f56f5ef64351ebf9d2d4cae70751b8415fcab9 /src/input_common/drivers
parentcore: Replace lock_guard with scoped_lock (diff)
downloadyuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.gz
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.bz2
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.lz
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.xz
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.zst
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.zip
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index c17ea305e..b3e4c3f64 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -62,7 +62,7 @@ public:
bool UpdateMotion(SDL_ControllerSensorEvent event) {
constexpr float gravity_constant = 9.80665f;
- std::lock_guard lock{mutex};
+ std::scoped_lock lock{mutex};
const u64 time_difference = event.timestamp - last_motion_update;
last_motion_update = event.timestamp;
switch (event.sensor) {
@@ -241,7 +241,7 @@ private:
};
std::shared_ptr<SDLJoystick> SDLDriver::GetSDLJoystickByGUID(const std::string& guid, int port) {
- std::lock_guard lock{joystick_map_mutex};
+ std::scoped_lock lock{joystick_map_mutex};
const auto it = joystick_map.find(guid);
if (it != joystick_map.end()) {
@@ -263,7 +263,7 @@ std::shared_ptr<SDLJoystick> SDLDriver::GetSDLJoystickBySDLID(SDL_JoystickID sdl
auto sdl_joystick = SDL_JoystickFromInstanceID(sdl_id);
const std::string guid = GetGUID(sdl_joystick);
- std::lock_guard lock{joystick_map_mutex};
+ std::scoped_lock lock{joystick_map_mutex};
const auto map_it = joystick_map.find(guid);
if (map_it == joystick_map.end()) {
@@ -297,7 +297,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
const std::string guid = GetGUID(sdl_joystick);
- std::lock_guard lock{joystick_map_mutex};
+ std::scoped_lock lock{joystick_map_mutex};
if (joystick_map.find(guid) == joystick_map.end()) {
auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
PreSetController(joystick->GetPadIdentifier());
@@ -326,7 +326,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
void SDLDriver::CloseJoystick(SDL_Joystick* sdl_joystick) {
const std::string guid = GetGUID(sdl_joystick);
- std::lock_guard lock{joystick_map_mutex};
+ std::scoped_lock lock{joystick_map_mutex};
// This call to guid is safe since the joystick is guaranteed to be in the map
const auto& joystick_guid_list = joystick_map[guid];
const auto joystick_it = std::find_if(joystick_guid_list.begin(), joystick_guid_list.end(),
@@ -392,7 +392,7 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
}
void SDLDriver::CloseJoysticks() {
- std::lock_guard lock{joystick_map_mutex};
+ std::scoped_lock lock{joystick_map_mutex};
joystick_map.clear();
}