From 336518049d0c1d63dbdfd9dcd55d1e84fcb5ba21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 12 Apr 2021 12:49:29 +0200 Subject: WiiUtils: Add helper functions to get emulated/real Bluetooth device This adds a function to get the emulated or real Bluetooth device for an active emulation instance. This lets us deduplicate all the `ios->GetDeviceByName("/dev/usb/oh1/57e/305")` calls that are currently scattered in the codebase and ensures Bluetooth passthrough is being handled correctly. This also fixes the broken check in WiimoteCommon::UpdateSource. There was a confusion between "emulated Bluetooth" (as opposed to "real Bluetooth" aka Bluetooth passthrough) and "emulated Wiimote". --- Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp') diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp index a871063b7e..bc3418b656 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp @@ -24,6 +24,7 @@ #include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/IOS/IOS.h" #include "Core/IOS/USB/Bluetooth/BTReal.h" +#include "Core/WiiUtils.h" #include "DolphinQt/Config/Mapping/MappingWindow.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" @@ -242,11 +243,9 @@ void WiimoteControllersWidget::OnBluetoothPassthroughResetPressed() return; } - auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305"); + auto device = WiiUtils::GetBluetoothRealDevice(); if (device != nullptr) - { - std::static_pointer_cast(device)->TriggerSyncButtonHeldEvent(); - } + device->TriggerSyncButtonHeldEvent(); } void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed() @@ -260,13 +259,9 @@ void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed() return; } - auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305"); - + auto device = WiiUtils::GetBluetoothRealDevice(); if (device != nullptr) - { - std::static_pointer_cast(device) - ->TriggerSyncButtonPressedEvent(); - } + device->TriggerSyncButtonPressedEvent(); } void WiimoteControllersWidget::OnWiimoteRefreshPressed() -- cgit v1.2.3