From 4a39ca249c2a834f6bafdce190218b57fab607e1 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Fri, 3 Oct 2025 04:44:36 -0500 Subject: [PATCH] WiimoteReal/IOhidapi: Move VID/PID check to a helper function that other backends can use in the future. --- Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp | 3 +-- Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp | 5 +++++ Source/Core/Core/HW/WiimoteReal/WiimoteReal.h | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp b/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp index 2b21af3194b..c9b11d94e4e 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp @@ -70,8 +70,7 @@ void WiimoteScannerHidapi::FindWiimotes(std::vector& wiimotes, Wiimote { const std::string name = device->product_string ? WStringToUTF8(device->product_string) : ""; const bool is_wiimote = - IsValidDeviceName(name) || (device->vendor_id == 0x057e && - (device->product_id == 0x0306 || device->product_id == 0x0330)); + IsValidDeviceName(name) || IsKnownDeviceId({device->vendor_id, device->product_id}); if (!is_wiimote || !IsNewWiimote(device->path) || !IsDeviceUsable(device->path)) continue; diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 10f1cc12ef2..03341941b53 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -983,6 +983,11 @@ bool IsNewWiimote(const std::string& identifier) return !s_known_ids.contains(identifier); } +bool IsKnownDeviceId(const USBUtils::DeviceInfo& device_info) +{ + return device_info.vid == 0x057e && (device_info.pid == 0x0306 || device_info.pid == 0x0330); +} + void HandleWiimoteSourceChange(unsigned int index) { std::lock_guard wm_lk(g_wiimotes_mutex); diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h index 103ea073f27..024ed9a7404 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h @@ -20,6 +20,7 @@ #include "Core/HW/WiimoteCommon/WiimoteConstants.h" #include "Core/HW/WiimoteCommon/WiimoteHid.h" #include "Core/HW/WiimoteCommon/WiimoteReport.h" +#include "Core/USBUtils.h" class PointerWrap; @@ -222,6 +223,8 @@ bool IsValidDeviceName(const std::string& name); bool IsBalanceBoardName(const std::string& name); bool IsNewWiimote(const std::string& identifier); +bool IsKnownDeviceId(const USBUtils::DeviceInfo&); + void HandleWiimoteSourceChange(unsigned int wiimote_number); #ifdef ANDROID