mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
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).
This commit is contained in:
@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user