WiimoteControllersWidget: Fix UI hang on opening

Fix the UI hanging for several seconds when opening the Controllers
window.

Move the scan for Bluetooth adapters onto a separate thread so the Host
thread doesn't have to wait for it.

Only automatically scan for adapters once, when opening the Controllers
window for the first time. Add a Refresh button to let the user refresh
the adapter list afterward.
This commit is contained in:
Dentomologist
2025-05-15 02:37:01 -07:00
parent fc833f845c
commit ffd46cd10c
3 changed files with 76 additions and 12 deletions

View File

@ -3,9 +3,12 @@
#pragma once
#include <array>
#include <QWidget>
#include <array>
#include "Common/WorkQueueThread.h"
#include "Core/IOS/USB/Bluetooth/BTReal.h"
class QCheckBox;
class QComboBox;
@ -26,17 +29,21 @@ class WiimoteControllersWidget final : public QWidget
Q_OBJECT
public:
explicit WiimoteControllersWidget(QWidget* parent);
~WiimoteControllersWidget();
void UpdateBluetoothAvailableStatus();
void RefreshBluetoothAdapters();
private:
void SaveSettings();
void OnBluetoothPassthroughDeviceChanged(int index);
void OnBluetoothPassthroughSyncPressed();
void OnBluetoothPassthroughResetPressed();
void OnBluetoothAdapterRefreshComplete(
const std::vector<IOS::HLE::BluetoothRealDevice::BluetoothDeviceInfo>& devices);
void OnWiimoteRefreshPressed();
void OnWiimoteConfigure(size_t index);
void StartBluetoothAdapterRefresh();
void UpdateBluetoothAdapterWidgetsEnabled(Core::State state);
void CreateLayout();
void ConnectWidgets();
@ -50,10 +57,14 @@ private:
std::array<QHBoxLayout*, 4> m_wiimote_groups;
std::array<QLabel*, 2> m_wiimote_pt_labels;
Common::AsyncWorkThreadSP m_bluetooth_adapter_refresh_thread;
bool m_bluetooth_adapter_scan_in_progress = false;
QRadioButton* m_wiimote_emu;
QRadioButton* m_wiimote_passthrough;
QLabel* m_bluetooth_adapters_label;
QComboBox* m_bluetooth_adapters;
QPushButton* m_bluetooth_adapters_refresh;
QPushButton* m_wiimote_sync;
QPushButton* m_wiimote_reset;
QCheckBox* m_wiimote_continuous_scanning;