summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/CoreDevice.h
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2023-05-24 22:58:30 +0300
committerFiloppi <filippotarpini@hotmail.it>2023-12-18 21:45:22 +0200
commite456bef163c1b667ff5a045a4bda66b30326ae90 (patch)
treeec2483dc88b79eb0ec9f510e31d692b86c693b6e /Source/Core/InputCommon/ControllerInterface/CoreDevice.h
parente498759d1425a64ecf19524dc3196f103354e033 (diff)
Input: Improve Controller Interface devices threading
This specific issue was already addressed by https://github.com/dolphin-emu/dolphin/pull/11635 though I felt like there was something more we could do, and wasn't too happy with the likelihood of devices update calls being skipped (due to `m_devices_population_mutex` being locked).
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/CoreDevice.h')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/CoreDevice.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/CoreDevice.h b/Source/Core/InputCommon/ControllerInterface/CoreDevice.h
index a2176637ab..1667b42a00 100644
--- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.h
+++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.h
@@ -36,6 +36,12 @@ constexpr ControlState BATTERY_INPUT_MAX_VALUE = 100.0;
namespace Core
{
+enum class DeviceRemoval
+{
+ Remove,
+ Keep,
+};
+
class Device
{
public:
@@ -118,7 +124,7 @@ public:
virtual std::string GetName() const = 0;
virtual std::string GetSource() const = 0;
std::string GetQualifiedName() const;
- virtual void UpdateInput() {}
+ virtual DeviceRemoval UpdateInput() { return DeviceRemoval::Keep; }
// May be overridden to implement hotplug removal.
// Currently handled on a per-backend basis but this could change.
@@ -242,7 +248,8 @@ public:
std::recursive_mutex& GetDevicesMutex() const { return m_devices_mutex; }
protected:
- // Exclusively needed when reading/writing "m_devices"
+ // Exclusively needed when reading/writing the "m_devices" array.
+ // Not needed when individually readring/writing a single device ptr.
mutable std::recursive_mutex m_devices_mutex;
std::vector<std::shared_ptr<Device>> m_devices;
};