Skip to content

Commit

Permalink
Automatically detach/reattach bluetooth driver in passthrough
Browse files Browse the repository at this point in the history
When the bluetooth adapter device is opened/closed by dolphin, the
kernel driver is automatically detached/reattached.

This enables transparent sharing of the same bluetooth wiimotes and
bluetooth adapters between the hosts system and the emulated one using
the same.
  • Loading branch information
randomstuff committed Jun 17, 2019
1 parent b3525ad commit dbdab58
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
Expand Up @@ -555,11 +555,14 @@ bool BluetoothReal::OpenDevice(libusb_device* device)
// Detaching always fails as a regular user on FreeBSD
// https://lists.freebsd.org/pipermail/freebsd-usb/2016-March/014161.html
#ifndef __FreeBSD__
const int result = libusb_detach_kernel_driver(m_handle, INTERFACE);
if (result < 0 && result != LIBUSB_ERROR_NOT_FOUND && result != LIBUSB_ERROR_NOT_SUPPORTED)
{
PanicAlertT("Failed to detach kernel driver for BT passthrough: %s", libusb_error_name(result));
return false;
int result = libusb_set_auto_detach_kernel_driver(m_handle, 1);
if (result != 0) {
result = libusb_detach_kernel_driver(m_handle, INTERFACE);
if (result < 0 && result != LIBUSB_ERROR_NOT_FOUND && result != LIBUSB_ERROR_NOT_SUPPORTED)
{
PanicAlertT("Failed to detach kernel driver for BT passthrough: %s", libusb_error_name(result));
return false;
}
}
#endif
if (libusb_claim_interface(m_handle, INTERFACE) < 0)
Expand Down

0 comments on commit dbdab58

Please sign in to comment.