mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 15:49:25 +01:00
Qt: Implement "Connect Wii Remotes" menu
This commit is contained in:
parent
c66156148d
commit
aae5c950f0
@ -209,8 +209,8 @@ void HotkeyScheduler::Run()
|
||||
if (IsHotkey(HK_BALANCEBOARD_CONNECT))
|
||||
wiimote_id = 4;
|
||||
|
||||
// TODO Implement Wiimote connecting / disconnecting (Separate PR)
|
||||
// if (wiimote_id > -1)
|
||||
if (wiimote_id > -1)
|
||||
emit ConnectWiiRemote(wiimote_id);
|
||||
}
|
||||
|
||||
// Graphics
|
||||
|
@ -31,6 +31,7 @@ signals:
|
||||
void StartRecording();
|
||||
void ExportRecording();
|
||||
void ToggleReadOnlyMode();
|
||||
void ConnectWiiRemote(int id);
|
||||
|
||||
private:
|
||||
void Run();
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
||||
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
@ -238,6 +240,7 @@ void MainWindow::ConnectMenuBar()
|
||||
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
|
||||
connect(m_menu_bar, &MenuBar::StartNetPlay, this, &MainWindow::ShowNetPlaySetupDialog);
|
||||
connect(m_menu_bar, &MenuBar::ShowFIFOPlayer, this, &MainWindow::ShowFIFOPlayer);
|
||||
connect(m_menu_bar, &MenuBar::ConnectWiiRemote, this, &MainWindow::OnConnectWiiRemote);
|
||||
|
||||
// Movie
|
||||
connect(m_menu_bar, &MenuBar::PlayRecording, this, &MainWindow::OnPlayRecording);
|
||||
@ -282,6 +285,8 @@ void MainWindow::ConnectHotkeys()
|
||||
&MainWindow::OnStartRecording);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ExportRecording, this,
|
||||
&MainWindow::OnExportRecording);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ConnectWiiRemote, this,
|
||||
&MainWindow::OnConnectWiiRemote);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ToggleReadOnlyMode, [this] {
|
||||
bool read_only = !Movie::IsReadOnly();
|
||||
Movie::SetReadOnly(read_only);
|
||||
@ -1047,3 +1052,16 @@ void MainWindow::OnExportRecording()
|
||||
|
||||
Movie::SaveRecording(dtm_file.toStdString());
|
||||
}
|
||||
|
||||
void MainWindow::OnConnectWiiRemote(int id)
|
||||
{
|
||||
const auto ios = IOS::HLE::GetIOS();
|
||||
if (!ios || SConfig::GetInstance().m_bt_passthrough_enabled)
|
||||
return;
|
||||
Core::RunAsCPUThread([&] {
|
||||
const auto bt = std::static_pointer_cast<IOS::HLE::Device::BluetoothEmu>(
|
||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305"));
|
||||
const bool is_connected = bt && bt->AccessWiiMote(id | 0x100)->IsConnected();
|
||||
Wiimote::Connect(id, !is_connected);
|
||||
});
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ private:
|
||||
|
||||
void OnBootGameCubeIPL(DiscIO::Region region);
|
||||
void OnImportNANDBackup();
|
||||
void OnConnectWiiRemote(int id);
|
||||
|
||||
void OnPlayRecording();
|
||||
void OnStartRecording();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Core/HW/Wiimote.h"
|
||||
#include "Core/IOS/ES/ES.h"
|
||||
#include "Core/IOS/IOS.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/State.h"
|
||||
#include "Core/TitleDatabase.h"
|
||||
@ -156,6 +157,24 @@ void MenuBar::AddToolsMenu()
|
||||
[this] { emit PerformOnlineUpdate("KOR"); });
|
||||
AddAction(m_perform_online_update_menu, tr("United States"), this,
|
||||
[this] { emit PerformOnlineUpdate("USA"); });
|
||||
|
||||
QMenu* menu = new QMenu(tr("Connect Wii Remotes"));
|
||||
|
||||
tools_menu->addSeparator();
|
||||
tools_menu->addMenu(menu);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
m_wii_remotes[i] = AddAction(menu, tr("Connect Wii Remote %1").arg(i + 1), this,
|
||||
[this, i] { emit ConnectWiiRemote(i); });
|
||||
m_wii_remotes[i]->setCheckable(true);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
m_wii_remotes[4] =
|
||||
AddAction(menu, tr("Connect Balance Board"), this, [this] { emit ConnectWiiRemote(4); });
|
||||
m_wii_remotes[4]->setCheckable(true);
|
||||
}
|
||||
|
||||
void MenuBar::AddEmulationMenu()
|
||||
@ -541,6 +560,20 @@ void MenuBar::UpdateToolsMenu(bool emulation_started)
|
||||
action->setEnabled(!tmd.IsValid());
|
||||
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::Device::BluetoothEmu>(
|
||||
ios->GetDeviceByName("/dev/usb/oh1/57e/305")) :
|
||||
nullptr;
|
||||
bool enable_wiimotes =
|
||||
emulation_started && bt && !SConfig::GetInstance().m_bt_passthrough_enabled;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
m_wii_remotes[i]->setEnabled(enable_wiimotes);
|
||||
if (enable_wiimotes)
|
||||
m_wii_remotes[i]->setChecked(bt->AccessWiiMote(0x0100 + i)->IsConnected());
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBar::InstallWAD()
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
#include <QMenu>
|
||||
@ -64,6 +65,7 @@ signals:
|
||||
void BootGameCubeIPL(DiscIO::Region region);
|
||||
void ShowFIFOPlayer();
|
||||
void ShowAboutDialog();
|
||||
void ConnectWiiRemote(int id);
|
||||
|
||||
// Options
|
||||
void Configure();
|
||||
@ -135,6 +137,7 @@ private:
|
||||
QAction* m_import_backup;
|
||||
QAction* m_check_nand;
|
||||
QAction* m_extract_certificates;
|
||||
std::array<QAction*, 5> m_wii_remotes;
|
||||
|
||||
// Emulation
|
||||
QAction* m_play_action;
|
||||
|
Loading…
x
Reference in New Issue
Block a user