WiiUtils: Add helper functions to get emulated/real Bluetooth device

This adds a function to get the emulated or real Bluetooth device for
an active emulation instance. This lets us deduplicate all the
`ios->GetDeviceByName("/dev/usb/oh1/57e/305")` calls that are currently
scattered in the codebase and ensures Bluetooth passthrough is being
handled correctly.

This also fixes the broken check in WiimoteCommon::UpdateSource.
There was a confusion between "emulated Bluetooth" (as opposed to
"real Bluetooth" aka Bluetooth passthrough) and "emulated Wiimote".
This commit is contained in:
Léo Lam
2021-04-12 12:49:29 +02:00
parent 136f59b434
commit 336518049d
8 changed files with 50 additions and 45 deletions

View File

@ -62,6 +62,7 @@
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
#include "Core/NetPlayProto.h"
#include "Core/State.h"
#include "Core/WiiUtils.h"
#include "DiscIO/Enums.h"
@ -469,16 +470,13 @@ void ChangeWiiPads(bool instantly)
if (instantly && (s_controllers >> 4) == controllers)
return;
const auto ios = IOS::HLE::GetIOS();
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
nullptr;
const auto bt = WiiUtils::GetBluetoothEmuDevice();
for (int i = 0; i < MAX_WIIMOTES; ++i)
{
const bool is_using_wiimote = IsUsingWiimote(i);
WiimoteCommon::SetSource(i, is_using_wiimote ? WiimoteSource::Emulated : WiimoteSource::None);
if (!SConfig::GetInstance().m_bt_passthrough_enabled && bt)
if (bt != nullptr)
bt->AccessWiimoteByIndex(i)->Activate(is_using_wiimote);
}
}