Skip to content

Commit a5421e7

Browse files
committed
libretro: fix bluetooth passthrough mode
1 parent c330a6d commit a5421e7

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

Source/Core/DolphinLibretro/Common/Options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static struct retro_core_option_v2_definition option_defs[] = {
519519
Libretro::Options::main_bluetooth::BLUETOOTH_PASSTHROUGH,
520520
"System Configuration > Bluetooth passthrough mode",
521521
"Bluetooth passthrough mode",
522-
"Pass all traffic directly to the host's Bluetooth adapter. This might CRASH if your adaptor is not compatible.",
522+
"Pass all traffic directly to the host's Bluetooth adapter. Press F12 to being the sync process.",
523523
nullptr,
524524
CATEGORY_SYSCONF,
525525
{

Source/Core/DolphinLibretro/Input.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "Common/IniFile.h"
99
#include "Common/Logging/Log.h"
1010
#include "Core/Config/MainSettings.h"
11+
#include "Core/Config/WiimoteSettings.h"
1112
#include "Core/ConfigManager.h"
1213
#include "Core/FreeLookManager.h"
1314
#include "Core/HW/GBAPad.h"
@@ -21,8 +22,11 @@
2122
#include "Core/HW/WiimoteReal/WiimoteReal.h"
2223
#include "Core/HW/SI/SI.h"
2324
#include "Core/HW/SI/SI_Device.h"
25+
#include "Core/IOS/Device.h"
26+
#include "Core/IOS/USB/Bluetooth/BTReal.h"
2427
#include "Core/Host.h"
2528
#include "Core/System.h"
29+
#include "Core/WiiUtils.h"
2630
#include "DolphinLibretro/Input.h"
2731
#include "DolphinLibretro/Common/Options.h"
2832
#include "InputCommon/ControlReference/ControlReference.h"
@@ -34,10 +38,6 @@
3438
#include "InputCommon/GCAdapter.h"
3539
#include "InputCommon/GCPadStatus.h"
3640
#include "InputCommon/InputConfig.h"
37-
#include "Core/Config/WiimoteSettings.h"
38-
39-
//#include "UICommon/UICommon.h"
40-
//#include "Core/HotkeyManager.h"
4141

4242
#define RETRO_DEVICE_WIIMOTE RETRO_DEVICE_JOYPAD
4343
#define RETRO_DEVICE_WIIMOTE_SW ((2 << 8) | RETRO_DEVICE_JOYPAD)
@@ -581,6 +581,19 @@ void ResetControllers()
581581
retro_set_controller_port_device(port, input_types[port]);
582582
}
583583

584+
void BluetoothPassthroughBind()
585+
{
586+
bool sync = Libretro::Input::input_cb(0, RETRO_DEVICE_KEYBOARD, 0, RETROK_F12);
587+
588+
if (!sync)
589+
return;
590+
591+
auto bt_real = WiiUtils::GetBluetoothRealDevice();
592+
593+
if (bt_real)
594+
bt_real->TriggerSyncButtonPressedEvent();
595+
}
596+
584597
} // namespace Input
585598
} // namespace Libretro
586599

Source/Core/DolphinLibretro/Input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ void InitStage2();
1212
void Update();
1313
void Shutdown();
1414
void ResetControllers();
15+
void BluetoothPassthroughBind();
1516
}
1617
}

Source/Core/DolphinLibretro/Main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "VideoCommon/VideoConfig.h"
3737
#include "VideoCommon/Widescreen.h"
3838
#include "Core/Boot/Boot.h"
39-
#include "Core/HW/CPU.h"
4039

4140
#ifdef PERF_TEST
4241
static struct retro_perf_callback perf_cb;
@@ -245,6 +244,9 @@ void retro_run(void)
245244
WiimoteReal::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
246245
}
247246

247+
if (Config::Get(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED))
248+
Libretro::Input::BluetoothPassthroughBind();
249+
248250
RETRO_PERFORMANCE_INIT(dolphin_main_func);
249251
RETRO_PERFORMANCE_START(dolphin_main_func);
250252

0 commit comments

Comments
 (0)