Skip to content

Commit aadd3a1

Browse files
cscd98warmenhoven
authored andcommitted
libretro: fix bluetooth passthrough mode
1 parent c330a6d commit aadd3a1

4 files changed

Lines changed: 23 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 begin the sync process.",
523523
nullptr,
524524
CATEGORY_SYSCONF,
525525
{

Source/Core/DolphinLibretro/Input.cpp

Lines changed: 18 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,10 @@
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/USB/Bluetooth/BTReal.h"
2426
#include "Core/Host.h"
2527
#include "Core/System.h"
28+
#include "Core/WiiUtils.h"
2629
#include "DolphinLibretro/Input.h"
2730
#include "DolphinLibretro/Common/Options.h"
2831
#include "InputCommon/ControlReference/ControlReference.h"
@@ -34,10 +37,6 @@
3437
#include "InputCommon/GCAdapter.h"
3538
#include "InputCommon/GCPadStatus.h"
3639
#include "InputCommon/InputConfig.h"
37-
#include "Core/Config/WiimoteSettings.h"
38-
39-
//#include "UICommon/UICommon.h"
40-
//#include "Core/HotkeyManager.h"
4140

4241
#define RETRO_DEVICE_WIIMOTE RETRO_DEVICE_JOYPAD
4342
#define RETRO_DEVICE_WIIMOTE_SW ((2 << 8) | RETRO_DEVICE_JOYPAD)
@@ -581,6 +580,21 @@ void ResetControllers()
581580
retro_set_controller_port_device(port, input_types[port]);
582581
}
583582

583+
void BluetoothPassthroughBind()
584+
{
585+
static bool was_pressed = false;
586+
bool sync = Libretro::Input::input_cb(0, RETRO_DEVICE_KEYBOARD, 0, RETROK_F12);
587+
588+
if (sync && !was_pressed)
589+
{
590+
auto bt_real = WiiUtils::GetBluetoothRealDevice();
591+
if (bt_real)
592+
bt_real->TriggerSyncButtonPressedEvent();
593+
}
594+
595+
was_pressed = sync;
596+
}
597+
584598
} // namespace Input
585599
} // namespace Libretro
586600

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)