summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-10-03 23:08:05 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2025-10-12 12:37:04 -0500
commit8845fbdb7e84f4707e7b664b01e381419d7deadb (patch)
tree587d4275a156d5c7fc6478675dfd612af6b2d0ee /Source/Core
parente0c40025a95cfd223fbf547796a5390755f478ae (diff)
WiimoteReal: Detect already connected Wii remotes on Windows without having to use the Refresh button.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteReal/IOWin.cpp14
-rw-r--r--Source/Core/Core/HW/WiimoteReal/IOWin.h1
-rw-r--r--Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp22
-rw-r--r--Source/Core/Core/HW/WiimoteReal/WiimoteReal.h4
4 files changed, 28 insertions, 13 deletions
diff --git a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp
index 1f2e76b161..6f037019e7 100644
--- a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp
+++ b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp
@@ -675,13 +675,19 @@ void WiimoteScannerWindows::FindWiimoteHIDDevices(std::vector<Wiimote*>& found_w
}
}
-void WiimoteScannerWindows::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
- Wiimote*& found_board)
+void WiimoteScannerWindows::FindWiimotes(std::vector<Wiimote*>&, Wiimote*&)
{
+ // Ideally we'd only enumerate the radios once.
RemoveUnusableWiimoteBluetoothDevices();
DiscoverAndPairWiimotes(DEFAULT_INQUIRY_LENGTH);
- // TODO: This sleep is hacky. We should run FindWiimoteHIDDevices when a new device is created.
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
+
+ // Kinda odd that we never return any remotes here. The scanner interface is odd.
+ // We return all the results in FindAlreadyConnectedWiimote.
+}
+
+void WiimoteScannerWindows::FindAttachedDevices(std::vector<Wiimote*>& found_wiimotes,
+ Wiimote*& found_board)
+{
FindWiimoteHIDDevices(found_wiimotes, found_board);
}
diff --git a/Source/Core/Core/HW/WiimoteReal/IOWin.h b/Source/Core/Core/HW/WiimoteReal/IOWin.h
index 16bdeba0fd..12c577f950 100644
--- a/Source/Core/Core/HW/WiimoteReal/IOWin.h
+++ b/Source/Core/Core/HW/WiimoteReal/IOWin.h
@@ -53,6 +53,7 @@ public:
WiimoteScannerWindows();
bool IsReady() const override;
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
+ void FindAttachedDevices(std::vector<Wiimote*>&, Wiimote*&) override;
void Update() override;
void RequestStopSearching() override {}
diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
index 36fda0bc8a..7451c5d02b 100644
--- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
+++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
@@ -689,15 +689,12 @@ void WiimoteScanner::ThreadFunc()
g_controller_interface.PlatformPopulateDevices([] { ProcessWiimotePool(); });
}
- // Does stuff needed to detect disconnects on Windows
+ // Currently does nothing. To be removed.
for (const auto& backend : m_backends)
backend->Update();
CheckForDisconnectedWiimotes();
- if (m_scan_mode.load() == WiimoteScanMode::DO_NOT_SCAN)
- continue;
-
// If we don't want Wiimotes in ControllerInterface, we may not need them at all.
if (!Config::Get(Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE))
{
@@ -715,11 +712,22 @@ void WiimoteScanner::ThreadFunc()
continue;
}
+ // Stop scanning if not in continuous mode.
+ auto scan_mode = WiimoteScanMode::SCAN_ONCE;
+ m_scan_mode.compare_exchange_strong(scan_mode, WiimoteScanMode::DO_NOT_SCAN);
+
for (const auto& backend : m_backends)
{
std::vector<Wiimote*> found_wiimotes;
Wiimote* found_board = nullptr;
- backend->FindWiimotes(found_wiimotes, found_board);
+
+ // When not scanning we still look for already attached devices.
+ // This allows Windows and DolphinBar remotes to be quickly discovered.
+ if (scan_mode == WiimoteScanMode::DO_NOT_SCAN)
+ backend->FindAttachedDevices(found_wiimotes, found_board);
+ else
+ backend->FindWiimotes(found_wiimotes, found_board);
+
{
std::unique_lock wm_lk(g_wiimotes_mutex);
@@ -745,10 +753,6 @@ void WiimoteScanner::ThreadFunc()
}
}
}
-
- // Stop scanning if not in continuous mode.
- auto scan_mode = WiimoteScanMode::SCAN_ONCE;
- m_scan_mode.compare_exchange_strong(scan_mode, WiimoteScanMode::DO_NOT_SCAN);
}
{
diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
index 168d9a6100..dd0f699aed 100644
--- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
+++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
@@ -189,6 +189,10 @@ public:
virtual void Update() = 0;
// requests the backend to stop scanning if FindWiimotes is blocking
virtual void RequestStopSearching() = 0;
+
+ // Used by Windows to search for HID interfaces of already connected Wii remotes.
+ // hidapi should probably implement the equivalent.
+ virtual void FindAttachedDevices(std::vector<Wiimote*>&, Wiimote*&) {}
};
enum class WiimoteScanMode