From 3555cd68b2566530d70b00b9fe5c52cfd6ca7032 Mon Sep 17 00:00:00 2001 From: Craig Carnell <1188869+cscd98@users.noreply.github.com> Date: Tue, 10 Feb 2026 12:03:23 +0000 Subject: [PATCH] libretro: fix bluetooth passthrough mode --- .../Core/DolphinLibretro/Common/Options.cpp | 2 +- Source/Core/DolphinLibretro/Input.cpp | 22 +++++++++++++++---- Source/Core/DolphinLibretro/Input.h | 1 + Source/Core/DolphinLibretro/Main.cpp | 4 +++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinLibretro/Common/Options.cpp b/Source/Core/DolphinLibretro/Common/Options.cpp index 78637fbf1c9c..fc1f0f1224b7 100644 --- a/Source/Core/DolphinLibretro/Common/Options.cpp +++ b/Source/Core/DolphinLibretro/Common/Options.cpp @@ -519,7 +519,7 @@ static struct retro_core_option_v2_definition option_defs[] = { Libretro::Options::main_bluetooth::BLUETOOTH_PASSTHROUGH, "System Configuration > Bluetooth passthrough mode", "Bluetooth passthrough mode", - "Pass all traffic directly to the host's Bluetooth adapter. This might CRASH if your adaptor is not compatible.", + "Pass all traffic directly to the host's Bluetooth adapter. Press F12 to begin the sync process.", nullptr, CATEGORY_SYSCONF, { diff --git a/Source/Core/DolphinLibretro/Input.cpp b/Source/Core/DolphinLibretro/Input.cpp index e1d3090a53d9..4c20bc91c2ea 100644 --- a/Source/Core/DolphinLibretro/Input.cpp +++ b/Source/Core/DolphinLibretro/Input.cpp @@ -8,6 +8,7 @@ #include "Common/IniFile.h" #include "Common/Logging/Log.h" #include "Core/Config/MainSettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigManager.h" #include "Core/FreeLookManager.h" #include "Core/HW/GBAPad.h" @@ -21,8 +22,10 @@ #include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/HW/SI/SI.h" #include "Core/HW/SI/SI_Device.h" +#include "Core/IOS/USB/Bluetooth/BTReal.h" #include "Core/Host.h" #include "Core/System.h" +#include "Core/WiiUtils.h" #include "DolphinLibretro/Input.h" #include "DolphinLibretro/Common/Options.h" #include "InputCommon/ControlReference/ControlReference.h" @@ -34,10 +37,6 @@ #include "InputCommon/GCAdapter.h" #include "InputCommon/GCPadStatus.h" #include "InputCommon/InputConfig.h" -#include "Core/Config/WiimoteSettings.h" - -//#include "UICommon/UICommon.h" -//#include "Core/HotkeyManager.h" #define RETRO_DEVICE_WIIMOTE RETRO_DEVICE_JOYPAD #define RETRO_DEVICE_WIIMOTE_SW ((2 << 8) | RETRO_DEVICE_JOYPAD) @@ -581,6 +580,21 @@ void ResetControllers() retro_set_controller_port_device(port, input_types[port]); } +void BluetoothPassthroughBind() +{ + static bool was_pressed = false; + bool sync = Libretro::Input::input_cb(0, RETRO_DEVICE_KEYBOARD, 0, RETROK_F12); + + if (sync && !was_pressed) + { + auto bt_real = WiiUtils::GetBluetoothRealDevice(); + if (bt_real) + bt_real->TriggerSyncButtonPressedEvent(); + } + + was_pressed = sync; +} + } // namespace Input } // namespace Libretro diff --git a/Source/Core/DolphinLibretro/Input.h b/Source/Core/DolphinLibretro/Input.h index 95f6fa8ccc35..51d7beae3810 100644 --- a/Source/Core/DolphinLibretro/Input.h +++ b/Source/Core/DolphinLibretro/Input.h @@ -12,5 +12,6 @@ void InitStage2(); void Update(); void Shutdown(); void ResetControllers(); +void BluetoothPassthroughBind(); } } diff --git a/Source/Core/DolphinLibretro/Main.cpp b/Source/Core/DolphinLibretro/Main.cpp index a3475d24ffce..14260d26e7e1 100644 --- a/Source/Core/DolphinLibretro/Main.cpp +++ b/Source/Core/DolphinLibretro/Main.cpp @@ -36,7 +36,6 @@ #include "VideoCommon/VideoConfig.h" #include "VideoCommon/Widescreen.h" #include "Core/Boot/Boot.h" -#include "Core/HW/CPU.h" #ifdef PERF_TEST static struct retro_perf_callback perf_cb; @@ -245,6 +244,9 @@ void retro_run(void) WiimoteReal::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); } + if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED)) + Libretro::Input::BluetoothPassthroughBind(); + RETRO_PERFORMANCE_INIT(dolphin_main_func); RETRO_PERFORMANCE_START(dolphin_main_func);