summaryrefslogtreecommitdiff
path: root/src/core/hid
diff options
context:
space:
mode:
authorGravatar german772021-11-01 14:17:53 -0600
committerGravatar Narr the Reg2021-11-24 20:30:26 -0600
commit77fa4d4bf60526826ef8b53ee3870f7d2a761976 (patch)
tree3c6c07d535bd912ed085be9b826103a6eabe718f /src/core/hid
parentsettings: Fix Debug controller type options (diff)
downloadyuzu-77fa4d4bf60526826ef8b53ee3870f7d2a761976.tar.gz
yuzu-77fa4d4bf60526826ef8b53ee3870f7d2a761976.tar.xz
yuzu-77fa4d4bf60526826ef8b53ee3870f7d2a761976.zip
second commit lion review
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/emulated_console.cpp5
-rw-r--r--src/core/hid/emulated_controller.cpp5
-rw-r--r--src/core/hid/emulated_devices.cpp5
-rw-r--r--src/core/hid/hid_core.cpp3
-rw-r--r--src/core/hid/hid_core.h10
-rw-r--r--src/core/hid/input_converter.h12
6 files changed, 29 insertions, 11 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index 012909954..dfbaa3f8c 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -209,10 +209,11 @@ int EmulatedConsole::SetCallback(ConsoleUpdateCallback update_callback) {
209 209
210void EmulatedConsole::DeleteCallback(int key) { 210void EmulatedConsole::DeleteCallback(int key) {
211 std::lock_guard lock{mutex}; 211 std::lock_guard lock{mutex};
212 if (!callback_list.contains(key)) { 212 const auto& iterator = callback_list.find(key);
213 if (iterator == callback_list.end()) {
213 LOG_ERROR(Input, "Tried to delete non-existent callback {}", key); 214 LOG_ERROR(Input, "Tried to delete non-existent callback {}", key);
214 return; 215 return;
215 } 216 }
216 callback_list.erase(key); 217 callback_list.erase(iterator);
217} 218}
218} // namespace Core::HID 219} // namespace Core::HID
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 9a1864279..7bab00bb1 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -993,10 +993,11 @@ int EmulatedController::SetCallback(ControllerUpdateCallback update_callback) {
993 993
994void EmulatedController::DeleteCallback(int key) { 994void EmulatedController::DeleteCallback(int key) {
995 std::lock_guard lock{mutex}; 995 std::lock_guard lock{mutex};
996 if (!callback_list.contains(key)) { 996 const auto& iterator = callback_list.find(key);
997 if (iterator == callback_list.end()) {
997 LOG_ERROR(Input, "Tried to delete non-existent callback {}", key); 998 LOG_ERROR(Input, "Tried to delete non-existent callback {}", key);
998 return; 999 return;
999 } 1000 }
1000 callback_list.erase(key); 1001 callback_list.erase(iterator);
1001} 1002}
1002} // namespace Core::HID 1003} // namespace Core::HID
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp
index c76a86b6c..e97470240 100644
--- a/src/core/hid/emulated_devices.cpp
+++ b/src/core/hid/emulated_devices.cpp
@@ -362,10 +362,11 @@ int EmulatedDevices::SetCallback(InterfaceUpdateCallback update_callback) {
362 362
363void EmulatedDevices::DeleteCallback(int key) { 363void EmulatedDevices::DeleteCallback(int key) {
364 std::lock_guard lock{mutex}; 364 std::lock_guard lock{mutex};
365 if (!callback_list.contains(key)) { 365 const auto& iterator = callback_list.find(key);
366 if (iterator == callback_list.end()) {
366 LOG_ERROR(Input, "Tried to delete non-existent callback {}", key); 367 LOG_ERROR(Input, "Tried to delete non-existent callback {}", key);
367 return; 368 return;
368 } 369 }
369 callback_list.erase(key); 370 callback_list.erase(iterator);
370} 371}
371} // namespace Core::HID 372} // namespace Core::HID
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp
index 3cb26e1e7..741a69c3c 100644
--- a/src/core/hid/hid_core.cpp
+++ b/src/core/hid/hid_core.cpp
@@ -3,6 +3,9 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/assert.h" 5#include "common/assert.h"
6#include "core/hid/emulated_console.h"
7#include "core/hid/emulated_controller.h"
8#include "core/hid/emulated_devices.h"
6#include "core/hid/hid_core.h" 9#include "core/hid/hid_core.h"
7 10
8namespace Core::HID { 11namespace Core::HID {
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h
index a4a66a3a4..1fe2fd89b 100644
--- a/src/core/hid/hid_core.h
+++ b/src/core/hid/hid_core.h
@@ -6,9 +6,13 @@
6 6
7#include <memory> 7#include <memory>
8 8
9#include "core/hid/emulated_console.h" 9#include "core/hid/hid_types.h"
10#include "core/hid/emulated_controller.h" 10
11#include "core/hid/emulated_devices.h" 11namespace Core::HID {
12class EmulatedConsole;
13class EmulatedController;
14class EmulatedDevices;
15} // namespace Core::HID
12 16
13namespace Core::HID { 17namespace Core::HID {
14 18
diff --git a/src/core/hid/input_converter.h b/src/core/hid/input_converter.h
index b38e657b0..2a722b39f 100644
--- a/src/core/hid/input_converter.h
+++ b/src/core/hid/input_converter.h
@@ -4,9 +4,17 @@
4 4
5#pragma once 5#pragma once
6 6
7namespace Input { 7namespace Common::Input {
8struct CallbackStatus; 8struct CallbackStatus;
9}; 9enum class BatteryLevel : u32;
10using BatteryStatus = BatteryLevel;
11struct AnalogStatus;
12struct ButtonStatus;
13struct MotionStatus;
14struct StickStatus;
15struct TouchStatus;
16struct TriggerStatus;
17}; // namespace Common::Input
10 18
11namespace Core::HID { 19namespace Core::HID {
12 20