From f90d851e2519d46f62e2037896053bc546e7133b Mon Sep 17 00:00:00 2001 From: Filoppi Date: Sat, 15 May 2021 11:32:00 +0300 Subject: ControllerInterface: mixed comments --- Source/Core/InputCommon/ControllerInterface/CoreDevice.h | 1 + 1 file changed, 1 insertion(+) (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 c368578949..1994cb402c 100644 --- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.h +++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.h @@ -227,6 +227,7 @@ public: std::chrono::milliseconds maximum_wait) const; protected: + // Exclusively needed when reading/writing "m_devices" mutable std::recursive_mutex m_devices_mutex; std::vector> m_devices; }; -- cgit v1.2.3 From dcc345400e38e54ac84819e5cbcdf65c9cd95f96 Mon Sep 17 00:00:00 2001 From: Filoppi Date: Sat, 15 May 2021 12:14:11 +0300 Subject: ControllerInterface: devices population is now async so implement devices sorting priority This helps us keeping the most important devices (e.g. Mouse and Keyboard) on the top of the list of devices (they still are on all OSes supported by dolphin and to make hotplug devices like DSU appear at the bottom. --- Source/Core/InputCommon/ControllerInterface/CoreDevice.h | 5 +++++ 1 file changed, 5 insertions(+) (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 1994cb402c..e094d2477d 100644 --- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.h +++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.h @@ -128,6 +128,11 @@ public: // (e.g. Xbox 360 controllers have controller number LEDs which should match the ID we use.) virtual std::optional GetPreferredId() const; + // Use this to change the order in which devices are sorted in their list. + // A higher priority means it will be one of the first ones (smaller index), making it more + // likely to be index 0, which is automatically set as the default device when there isn't one. + virtual int GetSortPriority() const { return 0; } + const std::vector& Inputs() const { return m_inputs; } const std::vector& Outputs() const { return m_outputs; } -- cgit v1.2.3 From a0ecca1a84afb61809aa848405f119a9a7fff965 Mon Sep 17 00:00:00 2001 From: Filoppi Date: Sat, 15 May 2021 12:20:20 +0300 Subject: ControllerInterface: Implement ChangeWindow on DInput without recreating the devices Also polished DInput code in general to try and mitigate issue 11702. Added a lot of logging and comments. --- Source/Core/InputCommon/ControllerInterface/CoreDevice.h | 6 ++++++ 1 file changed, 6 insertions(+) (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 e094d2477d..d3312568b2 100644 --- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.h +++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.h @@ -125,6 +125,12 @@ public: // Currently handled on a per-backend basis but this could change. virtual bool IsValid() const { return true; } + // Returns true whether this device is "virtual/emulated", not linked + // to any actual physical device. Mostly used by keyboard and mouse devices, + // and to avoid uselessly recreating the device unless really necessary. + // Doesn't necessarily need to be set to true if the device is virtual. + virtual bool IsVirtualDevice() const { return false; } + // (e.g. Xbox 360 controllers have controller number LEDs which should match the ID we use.) virtual std::optional GetPreferredId() const; -- cgit v1.2.3