mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Qt: Fix IOWindow keeping a shared ptr to devices even after them being removed by the ControllerInterface
this prevented some devices from being recreated correctly, as they were exclusive (e.g. DInput Joysticks) This is achieved by calling Settings::ReleaseDevices(), which releases all the UI devices shared ptrs. If we are the host (Qt) thread, DevicesChanged() is now called in line, to avoid devices being hanged onto by the UI. For this, I had to add a method to check whether we are the Host Thread to Qt. Avoid calling ControllerInterface::RefreshDevices() from the CPU thread if the emulation is running and we manually refresh devices from Qt, as that is not necessary anymore. Refactored the way IOWindow lists devices to make it clearer and hold onto disconnected devices. There were so many issues with the previous code: -Devices changes would not be reflected until the window was re-opened -If there was no default device, it would fail to select the device at index 0 -It could have crashed if we had 0 devices -The default device was not highlighted as such
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include <QComboBox>
|
||||
@ -69,16 +70,16 @@ public:
|
||||
explicit IOWindow(MappingWidget* parent, ControllerEmu::EmulatedController* m_controller,
|
||||
ControlReference* ref, Type type);
|
||||
|
||||
std::shared_ptr<ciface::Core::Device> GetSelectedDevice();
|
||||
|
||||
private:
|
||||
std::shared_ptr<ciface::Core::Device> GetSelectedDevice() const;
|
||||
|
||||
void CreateMainLayout();
|
||||
void ConnectWidgets();
|
||||
void ConfigChanged();
|
||||
void Update();
|
||||
|
||||
void OnDialogButtonPressed(QAbstractButton* button);
|
||||
void OnDeviceChanged(const QString& device);
|
||||
void OnDeviceChanged();
|
||||
void OnDetectButtonPressed();
|
||||
void OnTestButtonPressed();
|
||||
void OnRangeChanged(int range);
|
||||
@ -86,6 +87,7 @@ private:
|
||||
void AppendSelectedOption();
|
||||
void UpdateOptionList();
|
||||
void UpdateDeviceList();
|
||||
void ReleaseDevices();
|
||||
|
||||
enum class UpdateMode
|
||||
{
|
||||
@ -135,4 +137,5 @@ private:
|
||||
ciface::Core::DeviceQualifier m_devq;
|
||||
Type m_type;
|
||||
std::shared_ptr<ciface::Core::Device> m_selected_device;
|
||||
std::mutex m_selected_device_mutex;
|
||||
};
|
||||
|
Reference in New Issue
Block a user