mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-08 04:02:40 +00:00
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.
This commit is contained in:
parent
dcc345400e
commit
a0ecca1a84
8 changed files with 140 additions and 37 deletions
Source/Core/InputCommon/ControllerInterface
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue