Merge pull request #9638 from leoetlino/btemu-is-not-wiimoteemu
WiiUtils: Add helper functions to get emulated/real Bluetooth device
This commit is contained in:
commit
e8ac63d159
|
@ -16,6 +16,7 @@
|
||||||
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
#include "Core/NetPlayClient.h"
|
#include "Core/NetPlayClient.h"
|
||||||
|
#include "Core/WiiUtils.h"
|
||||||
|
|
||||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||||
#include "InputCommon/InputConfig.h"
|
#include "InputCommon/InputConfig.h"
|
||||||
|
@ -49,16 +50,8 @@ void SetSource(unsigned int index, WiimoteSource source)
|
||||||
|
|
||||||
void UpdateSource(unsigned int index)
|
void UpdateSource(unsigned int index)
|
||||||
{
|
{
|
||||||
const auto ios = IOS::HLE::GetIOS();
|
const auto bluetooth = WiiUtils::GetBluetoothEmuDevice();
|
||||||
if (!ios)
|
if (bluetooth == nullptr)
|
||||||
return;
|
|
||||||
|
|
||||||
if (s_wiimote_sources[index] != WiimoteSource::Emulated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const auto bluetooth = std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
|
|
||||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305"));
|
|
||||||
if (!bluetooth)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bluetooth->AccessWiimoteByIndex(index)->SetSource(GetHIDWiimoteSource(index));
|
bluetooth->AccessWiimoteByIndex(index)->SetSource(GetHIDWiimoteSource(index));
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
||||||
#include "Core/NetPlayProto.h"
|
#include "Core/NetPlayProto.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
#include "Core/WiiUtils.h"
|
||||||
|
|
||||||
#include "DiscIO/Enums.h"
|
#include "DiscIO/Enums.h"
|
||||||
|
|
||||||
|
@ -469,16 +470,13 @@ void ChangeWiiPads(bool instantly)
|
||||||
if (instantly && (s_controllers >> 4) == controllers)
|
if (instantly && (s_controllers >> 4) == controllers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto ios = IOS::HLE::GetIOS();
|
const auto bt = WiiUtils::GetBluetoothEmuDevice();
|
||||||
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
|
|
||||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
|
|
||||||
nullptr;
|
|
||||||
for (int i = 0; i < MAX_WIIMOTES; ++i)
|
for (int i = 0; i < MAX_WIIMOTES; ++i)
|
||||||
{
|
{
|
||||||
const bool is_using_wiimote = IsUsingWiimote(i);
|
const bool is_using_wiimote = IsUsingWiimote(i);
|
||||||
|
|
||||||
WiimoteCommon::SetSource(i, is_using_wiimote ? WiimoteSource::Emulated : WiimoteSource::None);
|
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);
|
bt->AccessWiimoteByIndex(i)->Activate(is_using_wiimote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "Core/IOS/ES/Formats.h"
|
#include "Core/IOS/ES/Formats.h"
|
||||||
#include "Core/IOS/FS/FileSystem.h"
|
#include "Core/IOS/FS/FileSystem.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
|
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
||||||
|
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
||||||
#include "Core/IOS/Uids.h"
|
#include "Core/IOS/Uids.h"
|
||||||
#include "Core/SysConf.h"
|
#include "Core/SysConf.h"
|
||||||
#include "DiscIO/DiscExtractor.h"
|
#include "DiscIO/DiscExtractor.h"
|
||||||
|
@ -957,4 +959,24 @@ bool RepairNAND(IOS::HLE::Kernel& ios)
|
||||||
{
|
{
|
||||||
return !CheckNAND(ios, true).bad;
|
return !CheckNAND(ios, true).bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::shared_ptr<IOS::HLE::Device> GetBluetoothDevice()
|
||||||
|
{
|
||||||
|
auto* ios = IOS::HLE::GetIOS();
|
||||||
|
return ios ? ios->GetDeviceByName("/dev/usb/oh1/57e/305") : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IOS::HLE::BluetoothEmuDevice> GetBluetoothEmuDevice()
|
||||||
|
{
|
||||||
|
if (SConfig::GetInstance().m_bt_passthrough_enabled)
|
||||||
|
return nullptr;
|
||||||
|
return std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(GetBluetoothDevice());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<IOS::HLE::BluetoothRealDevice> GetBluetoothRealDevice()
|
||||||
|
{
|
||||||
|
if (!SConfig::GetInstance().m_bt_passthrough_enabled)
|
||||||
|
return nullptr;
|
||||||
|
return std::static_pointer_cast<IOS::HLE::BluetoothRealDevice>(GetBluetoothDevice());
|
||||||
|
}
|
||||||
} // namespace WiiUtils
|
} // namespace WiiUtils
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Core/IOS/ES/Formats.h"
|
#include "Core/IOS/ES/Formats.h"
|
||||||
|
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
||||||
|
|
||||||
// Small utility functions for common Wii related tasks.
|
// Small utility functions for common Wii related tasks.
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ class VolumeWAD;
|
||||||
|
|
||||||
namespace IOS::HLE
|
namespace IOS::HLE
|
||||||
{
|
{
|
||||||
|
class BluetoothEmuDevice;
|
||||||
class ESDevice;
|
class ESDevice;
|
||||||
class Kernel;
|
class Kernel;
|
||||||
} // namespace IOS::HLE
|
} // namespace IOS::HLE
|
||||||
|
@ -101,4 +103,11 @@ struct NANDCheckResult
|
||||||
};
|
};
|
||||||
NANDCheckResult CheckNAND(IOS::HLE::Kernel& ios);
|
NANDCheckResult CheckNAND(IOS::HLE::Kernel& ios);
|
||||||
bool RepairNAND(IOS::HLE::Kernel& ios);
|
bool RepairNAND(IOS::HLE::Kernel& ios);
|
||||||
|
|
||||||
|
// Get the BluetoothEmuDevice for an active emulation instance.
|
||||||
|
// It is only safe to call this from the CPU thread.
|
||||||
|
// Returns nullptr if we're not currently emulating a Wii game or if Bluetooth passthrough is used.
|
||||||
|
std::shared_ptr<IOS::HLE::BluetoothEmuDevice> GetBluetoothEmuDevice();
|
||||||
|
// Same as GetBluetoothEmuDevice, but for Bluetooth passthrough.
|
||||||
|
std::shared_ptr<IOS::HLE::BluetoothRealDevice> GetBluetoothRealDevice();
|
||||||
} // namespace WiiUtils
|
} // namespace WiiUtils
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
||||||
|
#include "Core/WiiUtils.h"
|
||||||
|
|
||||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||||
|
@ -242,11 +243,9 @@ void WiimoteControllersWidget::OnBluetoothPassthroughResetPressed()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305");
|
auto device = WiiUtils::GetBluetoothRealDevice();
|
||||||
if (device != nullptr)
|
if (device != nullptr)
|
||||||
{
|
device->TriggerSyncButtonHeldEvent();
|
||||||
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)->TriggerSyncButtonHeldEvent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed()
|
void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed()
|
||||||
|
@ -260,13 +259,9 @@ void WiimoteControllersWidget::OnBluetoothPassthroughSyncPressed()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto device = ios->GetDeviceByName("/dev/usb/oh1/57e/305");
|
auto device = WiiUtils::GetBluetoothRealDevice();
|
||||||
|
|
||||||
if (device != nullptr)
|
if (device != nullptr)
|
||||||
{
|
device->TriggerSyncButtonPressedEvent();
|
||||||
std::static_pointer_cast<IOS::HLE::BluetoothBaseDevice>(device)
|
|
||||||
->TriggerSyncButtonPressedEvent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiimoteControllersWidget::OnWiimoteRefreshPressed()
|
void WiimoteControllersWidget::OnWiimoteRefreshPressed()
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#ifdef DeleteFile
|
#ifdef DeleteFile
|
||||||
#undef DeleteFile
|
#undef DeleteFile
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef interface
|
||||||
|
#undef interface
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "DolphinQt/GameList/GameList.h"
|
#include "DolphinQt/GameList/GameList.h"
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
#include "Core/HotkeyManager.h"
|
#include "Core/HotkeyManager.h"
|
||||||
#include "Core/IOS/IOS.h"
|
#include "Core/IOS/IOS.h"
|
||||||
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
||||||
|
#include "Core/IOS/USB/Bluetooth/BTReal.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
#include "Core/WiiUtils.h"
|
||||||
|
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
|
@ -231,15 +233,8 @@ void HotkeyScheduler::Run()
|
||||||
emit ToggleReadOnlyMode();
|
emit ToggleReadOnlyMode();
|
||||||
|
|
||||||
// Wiimote
|
// Wiimote
|
||||||
if (SConfig::GetInstance().m_bt_passthrough_enabled)
|
if (auto bt = WiiUtils::GetBluetoothRealDevice())
|
||||||
{
|
bt->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true));
|
||||||
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 (SConfig::GetInstance().bEnableDebugging)
|
if (SConfig::GetInstance().bEnableDebugging)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include "Core/NetPlayProto.h"
|
#include "Core/NetPlayProto.h"
|
||||||
#include "Core/NetPlayServer.h"
|
#include "Core/NetPlayServer.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
#include "Core/WiiUtils.h"
|
||||||
|
|
||||||
#include "DiscIO/NANDImporter.h"
|
#include "DiscIO/NANDImporter.h"
|
||||||
|
|
||||||
|
@ -1723,12 +1724,8 @@ void MainWindow::ShowTASInput()
|
||||||
|
|
||||||
void MainWindow::OnConnectWiiRemote(int id)
|
void MainWindow::OnConnectWiiRemote(int id)
|
||||||
{
|
{
|
||||||
const auto ios = IOS::HLE::GetIOS();
|
|
||||||
if (!ios || SConfig::GetInstance().m_bt_passthrough_enabled)
|
|
||||||
return;
|
|
||||||
Core::RunAsCPUThread([&] {
|
Core::RunAsCPUThread([&] {
|
||||||
if (const auto bt = std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
|
if (const auto bt = WiiUtils::GetBluetoothEmuDevice())
|
||||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305")))
|
|
||||||
{
|
{
|
||||||
const auto wm = bt->AccessWiimoteByIndex(id);
|
const auto wm = bt->AccessWiimoteByIndex(id);
|
||||||
wm->Activate(!wm->IsConnected());
|
wm->Activate(!wm->IsConnected());
|
||||||
|
|
|
@ -1023,12 +1023,8 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
|
||||||
m_perform_online_update_for_current_region->setEnabled(tmd.IsValid());
|
m_perform_online_update_for_current_region->setEnabled(tmd.IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ios = IOS::HLE::GetIOS();
|
const auto bt = WiiUtils::GetBluetoothEmuDevice();
|
||||||
const auto bt = ios ? std::static_pointer_cast<IOS::HLE::BluetoothEmuDevice>(
|
const bool enable_wiimotes = emulation_started && bt != nullptr;
|
||||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
|
|
||||||
nullptr;
|
|
||||||
const bool enable_wiimotes =
|
|
||||||
emulation_started && bt && !SConfig::GetInstance().m_bt_passthrough_enabled;
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < m_wii_remotes.size(); i++)
|
for (std::size_t i = 0; i < m_wii_remotes.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue