From 125971d9f2cbfff81985610a750364a54c3d452d Mon Sep 17 00:00:00 2001 From: Filoppi Date: Sat, 27 Nov 2021 14:31:04 +0200 Subject: InputCommon: fix default input config default device not being loaded/found Fixes bug: https://bugs.dolphin-emu.org/issues/12744 Before https://github.com/dolphin-emu/dolphin/commit/e1e3db13baabefa89991388d37db0bb260c4f535 the ControllerInterface m_devices_mutex was "wrongfully" locked for the whole Initialize() call, which included the first device population refresh, this has the unwanted (accidental) consequence of often preventing the different pads (GC Pad, Wii Contollers, ...) input configs from loading until that mutex was released (the input config defaults loading was blocked in EmulatedController::LoadDefaults()), which meant that the devices population would often have the time to finish adding its first device, which would then be selected as default device (by design, the first device added to the CI is the default default device, usually the "Keyboard and Mouse" device). After the commit mentioned above removed the unnecessary m_devices_mutex calls, the default default device would fail to load (be found) causing the default input mappings, which are specifically written for the default default device on every platform, to not be bound to any physical device input, breaking input on new dolphin installations (until a user tried to customize the default device manually). Default devices are now always added synchronously to avoid the problem, and so they should in the future (I added comments and warnings to help with that) --- Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp b/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp index 3d224b3cf4..4e46179fc6 100644 --- a/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp +++ b/Source/Core/InputCommon/ControllerInterface/CoreDevice.cpp @@ -258,10 +258,18 @@ std::vector DeviceContainer::GetAllDeviceStrings() const return device_strings; } +bool DeviceContainer::HasDefaultDevice() const +{ + std::lock_guard lk(m_devices_mutex); + // Devices are already sorted by priority + return !m_devices.empty() && m_devices[0]->GetSortPriority() >= 0; +} + std::string DeviceContainer::GetDefaultDeviceString() const { std::lock_guard lk(m_devices_mutex); - if (m_devices.empty()) + // Devices are already sorted by priority + if (m_devices.empty() || m_devices[0]->GetSortPriority() < 0) return ""; DeviceQualifier device_qualifier; -- cgit v1.2.3