summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorGravatar Merry2022-04-07 19:32:09 +0100
committerGravatar Merry2022-04-07 19:44:07 +0100
commit159ae5e47ceff0a44c1021379cbca601b36f4fb0 (patch)
treea7f56f5ef64351ebf9d2d4cae70751b8415fcab9 /src/input_common/drivers/sdl_driver.cpp
parentcore: Replace lock_guard with scoped_lock (diff)
downloadyuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.gz
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.tar.xz
yuzu-159ae5e47ceff0a44c1021379cbca601b36f4fb0.zip
input_common: Replace lock_guard with scoped_lock
Diffstat (limited to '')
-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:
62 62
63 bool UpdateMotion(SDL_ControllerSensorEvent event) { 63 bool UpdateMotion(SDL_ControllerSensorEvent event) {
64 constexpr float gravity_constant = 9.80665f; 64 constexpr float gravity_constant = 9.80665f;
65 std::lock_guard lock{mutex}; 65 std::scoped_lock lock{mutex};
66 const u64 time_difference = event.timestamp - last_motion_update; 66 const u64 time_difference = event.timestamp - last_motion_update;
67 last_motion_update = event.timestamp; 67 last_motion_update = event.timestamp;
68 switch (event.sensor) { 68 switch (event.sensor) {
@@ -241,7 +241,7 @@ private:
241}; 241};
242 242
243std::shared_ptr<SDLJoystick> SDLDriver::GetSDLJoystickByGUID(const std::string& guid, int port) { 243std::shared_ptr<SDLJoystick> SDLDriver::GetSDLJoystickByGUID(const std::string& guid, int port) {
244 std::lock_guard lock{joystick_map_mutex}; 244 std::scoped_lock lock{joystick_map_mutex};
245 const auto it = joystick_map.find(guid); 245 const auto it = joystick_map.find(guid);
246 246
247 if (it != joystick_map.end()) { 247 if (it != joystick_map.end()) {
@@ -263,7 +263,7 @@ std::shared_ptr<SDLJoystick> SDLDriver::GetSDLJoystickBySDLID(SDL_JoystickID sdl
263 auto sdl_joystick = SDL_JoystickFromInstanceID(sdl_id); 263 auto sdl_joystick = SDL_JoystickFromInstanceID(sdl_id);
264 const std::string guid = GetGUID(sdl_joystick); 264 const std::string guid = GetGUID(sdl_joystick);
265 265
266 std::lock_guard lock{joystick_map_mutex}; 266 std::scoped_lock lock{joystick_map_mutex};
267 const auto map_it = joystick_map.find(guid); 267 const auto map_it = joystick_map.find(guid);
268 268
269 if (map_it == joystick_map.end()) { 269 if (map_it == joystick_map.end()) {
@@ -297,7 +297,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
297 297
298 const std::string guid = GetGUID(sdl_joystick); 298 const std::string guid = GetGUID(sdl_joystick);
299 299
300 std::lock_guard lock{joystick_map_mutex}; 300 std::scoped_lock lock{joystick_map_mutex};
301 if (joystick_map.find(guid) == joystick_map.end()) { 301 if (joystick_map.find(guid) == joystick_map.end()) {
302 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller); 302 auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
303 PreSetController(joystick->GetPadIdentifier()); 303 PreSetController(joystick->GetPadIdentifier());
@@ -326,7 +326,7 @@ void SDLDriver::InitJoystick(int joystick_index) {
326void SDLDriver::CloseJoystick(SDL_Joystick* sdl_joystick) { 326void SDLDriver::CloseJoystick(SDL_Joystick* sdl_joystick) {
327 const std::string guid = GetGUID(sdl_joystick); 327 const std::string guid = GetGUID(sdl_joystick);
328 328
329 std::lock_guard lock{joystick_map_mutex}; 329 std::scoped_lock lock{joystick_map_mutex};
330 // This call to guid is safe since the joystick is guaranteed to be in the map 330 // This call to guid is safe since the joystick is guaranteed to be in the map
331 const auto& joystick_guid_list = joystick_map[guid]; 331 const auto& joystick_guid_list = joystick_map[guid];
332 const auto joystick_it = std::find_if(joystick_guid_list.begin(), joystick_guid_list.end(), 332 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) {
392} 392}
393 393
394void SDLDriver::CloseJoysticks() { 394void SDLDriver::CloseJoysticks() {
395 std::lock_guard lock{joystick_map_mutex}; 395 std::scoped_lock lock{joystick_map_mutex};
396 joystick_map.clear(); 396 joystick_map.clear();
397} 397}
398 398