diff options
| author | Filoppi <filippotarpini@hotmail.it> | 2021-05-15 12:20:20 +0300 |
|---|---|---|
| committer | Filoppi <filippotarpini@hotmail.it> | 2021-06-07 11:07:06 +0300 |
| commit | a0ecca1a84afb61809aa848405f119a9a7fff965 (patch) | |
| tree | 2a8bf13471a9d692152d3c5306587b915c835287 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | |
| parent | dcc345400e38e54ac84819e5cbcdf65c9cd95f96 (diff) | |
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.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index dd22ffe730..7c17a61448 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -135,6 +135,26 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) // This wasn't thread safe in multiple device sources. std::lock_guard lk_population(m_devices_population_mutex); +#if defined(CIFACE_USE_WIN32) && !defined(CIFACE_USE_XLIB) && !defined(CIFACE_USE_OSX) + // If only the window changed, avoid removing and re-adding all devices. + // Instead only refresh devices that require the window handle. + if (reason == RefreshReason::WindowChangeOnly) + { + m_populating_devices_counter.fetch_add(1); + + { + std::lock_guard lk(m_devices_mutex); + // No need to do anything else in this case. + // Only (Win32) DInput needs the window handle to be updated. + ciface::Win32::ChangeWindow(m_wsi.render_window); + } + + if (m_populating_devices_counter.fetch_sub(1) == 1) + InvokeDevicesChangedCallbacks(); + return; + } +#endif + m_populating_devices_counter.fetch_add(1); // We lock m_devices_mutex here to make everything simpler. |
