From e456bef163c1b667ff5a045a4bda66b30326ae90 Mon Sep 17 00:00:00 2001 From: Filoppi Date: Wed, 24 May 2023 22:58:30 +0300 Subject: 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). --- Source/Core/InputCommon/ControllerInterface/CoreDevice.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/CoreDevice.h') 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> m_devices; }; -- cgit v1.2.3