mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
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:
@ -24,6 +24,7 @@
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "Core/IOS/IOS.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||
@ -242,11 +243,9 @@ void WiimoteControllersWidget::OnBluetoothPassthroughResetPressed()
|
||||
return;
|
||||
}
|
||||
|
||||
auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305");
|
||||
auto device = WiiUtils::GetBluetoothRealDevice();
|
||||
if (device != nullptr)
|
||||
{
|
||||
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)->TriggerSyncButtonHeldEvent();
|
||||
}
|
||||
device->TriggerSyncButtonHeldEvent();
|
||||
}
|
||||
|
||||
void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed()
|
||||
@ -260,13 +259,9 @@ void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed()
|
||||
return;
|
||||
}
|
||||
|
||||
auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305");
|
||||
|
||||
auto device = WiiUtils::GetBluetoothRealDevice();
|
||||
if (device != nullptr)
|
||||
{
|
||||
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)
|
||||
->TriggerSyncButtonPressedEvent();
|
||||
}
|
||||
device->TriggerSyncButtonPressedEvent();
|
||||
}
|
||||
|
||||
void WiimoteControllersWidget::OnWiimoteRefreshPressed()
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "Core/IOS/IOS.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
||||
#include "Core/State.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
@ -231,15 +233,8 @@ void HotkeyScheduler::Run()
|
||||
emit ToggleReadOnlyMode();
|
||||
|
||||
// Wiimote
|
||||
if (SConfig::GetInstance().m_bt_passthrough_enabled)
|
||||
{
|
||||
const auto ios = IOS::HLE::GetIOS();
|
||||
auto device = ios ? ios->GetDeviceByName("/dev/usb/oh1/57e/305") : nullptr;
|
||||
|
||||
if (device != nullptr)
|
||||
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)->UpdateSyncButtonState(
|
||||
IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
|
||||
}
|
||||
if (auto bt = WiiUtils::GetBluetoothRealDevice())
|
||||
bt->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
|
||||
|
||||
if (SConfig::GetInstance().bEnableDebugging)
|
||||
{
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
#include "Core/State.h"
|
||||
#include "Core/WiiUtils.h"
|
||||
|
||||
#include "DiscIO/NANDImporter.h"
|
||||
|
||||
@ -1723,12 +1724,8 @@ void MainWindow::ShowTASInput()
|
||||
|
||||
void MainWindow::OnConnectWiiRemote(int id)
|
||||
{
|
||||
const auto ios = IOS::HLE::GetIOS();
|
||||
if (!ios || SConfig::GetInstance().m_bt_passthrough_enabled)
|
||||
return;
|
||||
Core::RunAsCPUThread([&] {
|
||||
if (const auto bt = std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
|
||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305")))
|
||||
if (const auto bt = WiiUtils::GetBluetoothEmuDevice())
|
||||
{
|
||||
const auto wm = bt->AccessWiimoteByIndex(id);
|
||||
wm->Activate(!wm->IsConnected());
|
||||
|
@ -1023,12 +1023,8 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
|
||||
m_perform_online_update_for_current_region->setEnabled(tmd.IsValid());
|
||||
}
|
||||
|
||||
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 bool enable_wiimotes =
|
||||
emulation_started && bt && !SConfig::GetInstance().m_bt_passthrough_enabled;
|
||||
const auto bt = WiiUtils::GetBluetoothEmuDevice();
|
||||
const bool enable_wiimotes = emulation_started && bt != nullptr;
|
||||
|
||||
for (std::size_t i = 0; i < m_wii_remotes.size(); i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user