Skip to content

Commit

Permalink
Merge pull request #4195 from leoetlino/direct-hci
Browse files Browse the repository at this point in the history
Add ability to passthrough a Bluetooth adapter
  • Loading branch information
shuffle2 committed Oct 3, 2016
2 parents 2c66f5b + 6ff06ed commit 6ec7569
Show file tree
Hide file tree
Showing 37 changed files with 1,776 additions and 647 deletions.
1 change: 1 addition & 0 deletions Source/Core/Common/CommonPaths.h
Expand Up @@ -120,6 +120,7 @@
#define WII_STATE "state.dat"

#define WII_SDCARD "sd.raw"
#define WII_BTDINF_BACKUP "btdinf.bak"

#define WII_SETTING "setting.txt"

Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/BootManager.cpp
Expand Up @@ -35,6 +35,7 @@
#include "Core/HW/Sram.h"
#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/Host.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h"
#include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "VideoCommon/VideoBackendBase.h"
Expand Down Expand Up @@ -399,6 +400,8 @@ bool BootCore(const std::string& _rFilename)
// TODO: remove this if and once Dolphin supports WC24 standby mode.
SConfig::GetInstance().m_SYSCONF->SetData<u8>("IPL.IDL", 0x00);
NOTICE_LOG(BOOT, "Disabling WC24 'standby' (shutdown to idle) to avoid hanging on shutdown");

RestoreBTInfoSection();
}

// Run the game
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/Core/CMakeLists.txt
Expand Up @@ -145,7 +145,9 @@ set(SRCS ActionReplay.cpp
IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp
IPC_HLE/WII_IPC_HLE_Device_stm.cpp
IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp
IPC_HLE/WII_IPC_HLE_Device_usb.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp
IPC_HLE/WII_IPC_HLE_WiiMote.cpp
Expand Down Expand Up @@ -243,7 +245,8 @@ set(LIBS
if(LIBUSB_FOUND)
# Using shared LibUSB
set(LIBS ${LIBS} ${LIBUSB_LIBRARIES})
set(SRCS ${SRCS} IPC_HLE/WII_IPC_HLE_Device_hid.cpp)
set(SRCS ${SRCS} IPC_HLE/WII_IPC_HLE_Device_hid.cpp
IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.cpp)
endif(LIBUSB_FOUND)

set(LIBS ${LIBS} ${MBEDTLS_LIBRARIES})
Expand Down
23 changes: 23 additions & 0 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -55,6 +55,7 @@ void SConfig::SaveSettings()
NOTICE_LOG(BOOT, "Saving settings to %s", File::GetUserPath(F_DOLPHINCONFIG_IDX).c_str());
IniFile ini;
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // load first to not kill unknown stuff
m_SYSCONF->Reload();

SaveGeneralSettings(ini);
SaveInterfaceSettings(ini);
Expand All @@ -67,6 +68,7 @@ void SConfig::SaveSettings()
SaveFifoPlayerSettings(ini);
SaveAnalyticsSettings(ini);
SaveNetworkSettings(ini);
SaveBluetoothPassthroughSettings(ini);

ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
m_SYSCONF->Save();
Expand Down Expand Up @@ -322,6 +324,16 @@ void SConfig::SaveAnalyticsSettings(IniFile& ini)
analytics->Set("PermissionAsked", m_analytics_permission_asked);
}

void SConfig::SaveBluetoothPassthroughSettings(IniFile& ini)
{
IniFile::Section* section = ini.GetOrCreateSection("BluetoothPassthrough");

section->Set("Enabled", m_bt_passthrough_enabled);
section->Set("VID", m_bt_passthrough_vid);
section->Set("PID", m_bt_passthrough_pid);
section->Set("LinkKeys", m_bt_passthrough_link_keys);
}

void SConfig::LoadSettings()
{
INFO_LOG(BOOT, "Loading Settings from %s", File::GetUserPath(F_DOLPHINCONFIG_IDX).c_str());
Expand All @@ -339,6 +351,7 @@ void SConfig::LoadSettings()
LoadFifoPlayerSettings(ini);
LoadNetworkSettings(ini);
LoadAnalyticsSettings(ini);
LoadBluetoothPassthroughSettings(ini);

m_SYSCONF = new SysConf();
}
Expand Down Expand Up @@ -604,6 +617,16 @@ void SConfig::LoadAnalyticsSettings(IniFile& ini)
analytics->Get("PermissionAsked", &m_analytics_permission_asked, false);
}

void SConfig::LoadBluetoothPassthroughSettings(IniFile& ini)
{
IniFile::Section* section = ini.GetOrCreateSection("BluetoothPassthrough");

section->Get("Enabled", &m_bt_passthrough_enabled, false);
section->Get("VID", &m_bt_passthrough_vid, -1);
section->Get("PID", &m_bt_passthrough_pid, -1);
section->Get("LinkKeys", &m_bt_passthrough_link_keys, "");
}

void SConfig::LoadDefaults()
{
bEnableDebugging = false;
Expand Down
8 changes: 8 additions & 0 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -143,6 +143,12 @@ struct SConfig : NonCopyable
bool m_analytics_enabled = false;
bool m_analytics_permission_asked = false;

// Bluetooth passthrough mode settings
bool m_bt_passthrough_enabled = false;
int m_bt_passthrough_pid = -1;
int m_bt_passthrough_vid = -1;
std::string m_bt_passthrough_link_keys;

// Fifo Player related settings
bool bLoopFifoReplay = true;

Expand Down Expand Up @@ -325,6 +331,7 @@ struct SConfig : NonCopyable
void SaveFifoPlayerSettings(IniFile& ini);
void SaveNetworkSettings(IniFile& ini);
void SaveAnalyticsSettings(IniFile& ini);
void SaveBluetoothPassthroughSettings(IniFile& ini);

void LoadGeneralSettings(IniFile& ini);
void LoadInterfaceSettings(IniFile& ini);
Expand All @@ -337,6 +344,7 @@ struct SConfig : NonCopyable
void LoadFifoPlayerSettings(IniFile& ini);
void LoadNetworkSettings(IniFile& ini);
void LoadAnalyticsSettings(IniFile& ini);
void LoadBluetoothPassthroughSettings(IniFile& ini);

static SConfig* m_Instance;
};
10 changes: 5 additions & 5 deletions Source/Core/Core/Core.cpp
Expand Up @@ -52,7 +52,7 @@
#include "Core/HW/SystemTimers.h"
#include "Core/HW/VideoInterface.h"
#include "Core/HW/Wiimote.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h"
#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h"
#include "Core/IPC_HLE/WII_Socket.h"
#include "Core/Movie.h"
Expand Down Expand Up @@ -297,7 +297,7 @@ void Stop() // - Hammertime!

g_video_backend->Video_ExitLoop();
}
#if defined(__LIBUSB__) || defined(_WIN32)
#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif

Expand Down Expand Up @@ -528,7 +528,7 @@ void EmuThread()
}

// Load and Init Wiimotes - only if we are booting in Wii mode
if (core_parameter.bWii)
if (core_parameter.bWii && !SConfig::GetInstance().m_bt_passthrough_enabled)
{
if (init_controllers)
Wiimote::Initialize(s_window_handle, !s_state_filename.empty() ?
Expand Down Expand Up @@ -698,7 +698,7 @@ void SetState(EState state)
// stopped (including the CPU).
CPU::EnableStepping(true); // Break
Wiimote::Pause();
#if defined(__LIBUSB__) || defined(_WIN32)
#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif
break;
Expand Down Expand Up @@ -818,7 +818,7 @@ bool PauseAndLock(bool do_lock, bool unpause_on_unlock)
// (s_efbAccessRequested).
Fifo::PauseAndLock(do_lock, false);

#if defined(__LIBUSB__) || defined(_WIN32)
#if defined(__LIBUSB__)
GCAdapter::ResetRumble();
#endif

Expand Down
12 changes: 10 additions & 2 deletions Source/Core/Core/Core.vcxproj
Expand Up @@ -185,7 +185,12 @@
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_net_ssl.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_stm.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_base.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_emu.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_real.cpp">
<DisableSpecificWarnings>4200;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_ven.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_WiiMote.cpp" />
Expand Down Expand Up @@ -389,7 +394,10 @@
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_net_ssl.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_stm.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_base.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_emu.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_real.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_ven.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_WiiMote.h" />
Expand Down
22 changes: 20 additions & 2 deletions Source/Core/Core/Core.vcxproj.filters
Expand Up @@ -591,7 +591,16 @@
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_hid.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb.cpp">
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_base.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_emu.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_real.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_WiiMote.cpp">
Expand Down Expand Up @@ -1148,7 +1157,16 @@
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_hid.h">
<Filter>IPC HLE %28IOS/Starlet%29\USB</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb.h">
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_base.h">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_emu.h">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_real.h">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_bt_stub.h">
<Filter>IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_WiiMote.h">
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -702,7 +702,8 @@ void Initialize(::Wiimote::InitializeMode init_mode)
g_wiimote_scanner.StartThread();
}

if (SConfig::GetInstance().m_WiimoteContinuousScanning)
if (SConfig::GetInstance().m_WiimoteContinuousScanning &&
!SConfig::GetInstance().m_bt_passthrough_enabled)
g_wiimote_scanner.SetScanMode(WiimoteScanMode::CONTINUOUSLY_SCAN);
else
g_wiimote_scanner.SetScanMode(WiimoteScanMode::DO_NOT_SCAN);
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/HotkeyManager.cpp
Expand Up @@ -32,6 +32,7 @@ const std::string hotkey_labels[] = {
_trans("Take Screenshot"),
_trans("Exit"),

_trans("Press Sync Button"),
_trans("Connect Wiimote 1"),
_trans("Connect Wiimote 2"),
_trans("Connect Wiimote 3"),
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/HotkeyManager.h
Expand Up @@ -31,6 +31,7 @@ enum Hotkey
HK_SCREENSHOT,
HK_EXIT,

HK_TRIGGER_SYNC_BUTTON,
HK_WIIMOTE1_CONNECT,
HK_WIIMOTE2_CONNECT,
HK_WIIMOTE3_CONNECT,
Expand Down

0 comments on commit 6ec7569

Please sign in to comment.