diff --git a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp index 2c510fb394..67dee9216d 100644 --- a/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/EmuSubroutines.cpp @@ -604,7 +604,7 @@ ExtensionNumber Wiimote::GetActiveExtensionNumber() const bool Wiimote::IsMotionPlusAttached() const { - return m_is_motion_plus_attached; + return m_motion_plus_setting.GetValue(); } } // namespace WiimoteEmu diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp index 85512c8a2b..2317b06f25 100644 --- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.cpp @@ -15,6 +15,7 @@ #include "DolphinQt/Config/Mapping/MappingWindow.h" #include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h" +#include "DolphinQt/Settings.h" #include "InputCommon/ControllerEmu/ControlGroup/Attachments.h" #include "InputCommon/InputConfig.h" @@ -88,6 +89,8 @@ void WiimoteEmuGeneral::OnAttachmentChanged(int extension) GetParent()->ShowExtensionMotionTabs(extension == WiimoteEmu::ExtensionNumber::NUNCHUK); m_extension_widget->ChangeExtensionType(extension); + + Settings::Instance().UpdateWiimoteExtension(GetPort(), extension); } void WiimoteEmuGeneral::OnAttachmentSelected(int extension) @@ -110,6 +113,7 @@ void WiimoteEmuGeneral::ConfigChanged() m_extension_combo_dynamic_indicator->setVisible( !ce_extension->GetSelectionSetting().IsSimpleValue()); + OnMotionPlusUpdate(); } void WiimoteEmuGeneral::Update() @@ -128,9 +132,18 @@ void WiimoteEmuGeneral::LoadSettings() void WiimoteEmuGeneral::SaveSettings() { Wiimote::GetConfig()->SaveConfig(); + OnMotionPlusUpdate(); } InputConfig* WiimoteEmuGeneral::GetConfig() { return Wiimote::GetConfig(); } + +void WiimoteEmuGeneral::OnMotionPlusUpdate() +{ + const int port = GetPort(); + const WiimoteEmu::Wiimote* const wiimote = + static_cast(Wiimote::GetConfig()->GetController(port)); + Settings::Instance().UpdateWiimoteMotionPlus(port, wiimote->IsMotionPlusAttached()); +} diff --git a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h index b3bd5d06e1..4465810f54 100644 --- a/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h +++ b/Source/Core/DolphinQt/Config/Mapping/WiimoteEmuGeneral.h @@ -27,6 +27,7 @@ private: void OnAttachmentChanged(int index); // Selection chosen by user. void OnAttachmentSelected(int index); + void OnMotionPlusUpdate(); void ConfigChanged(); void Update(); diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 93ad16a59e..606503e980 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -519,6 +519,15 @@ void MainWindow::CreateComponents() &MemoryWidget::SetAddress); connect(m_cheats_manager, &CheatsManager::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress); connect(m_cheats_manager, &CheatsManager::RequestWatch, request_watch); + + connect(&Settings::Instance(), &Settings::UpdateWiimoteExtension, + [this](const int controller_number, const int extension_index) { + m_wii_tas_input_windows[controller_number]->UpdateExtension(extension_index); + }); + connect(&Settings::Instance(), &Settings::UpdateWiimoteMotionPlus, + [this](const int controller_number, const bool attached) { + m_wii_tas_input_windows[controller_number]->UpdateMotionPlus(attached); + }); } void MainWindow::ConnectMenuBar() diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h index ad7be608c3..2b2fdde182 100644 --- a/Source/Core/DolphinQt/Settings.h +++ b/Source/Core/DolphinQt/Settings.h @@ -224,6 +224,8 @@ signals: void USBKeyboardConnectionChanged(bool connected); void EnableGfxModsChanged(bool enabled); void HardcoreStateChanged(); + void UpdateWiimoteExtension(int controller_number, int extension_index); + void UpdateWiimoteMotionPlus(int controller_number, bool attached); private: Settings(); diff --git a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp index b48b3d5040..c254a2057b 100644 --- a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp +++ b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp @@ -347,7 +347,6 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow( layout->addWidget(m_settings_box); setLayout(layout); - UpdateExt(); } WiimoteEmu::Wiimote* WiiTASInputWindow::GetWiimote() @@ -367,6 +366,28 @@ WiimoteEmu::Extension* WiiTASInputWindow::GetExtension() GetAttachments()->GetAttachmentList()[m_active_extension].get()); } +void WiiTASInputWindow::UpdateExtension(const int extension) +{ + const auto new_extension = static_cast(extension); + if (new_extension == m_active_extension) + return; + + m_active_extension = new_extension; + + UpdateControlVisibility(); + UpdateInputOverrideFunction(); +} + +void WiiTASInputWindow::UpdateMotionPlus(const bool attached) +{ + if (attached == m_is_motion_plus_attached) + return; + + m_is_motion_plus_attached = attached; + + UpdateControlVisibility(); +} + void WiiTASInputWindow::LoadExtensionAndMotionPlus() { if (Core::IsRunning(Core::System::GetInstance())) @@ -393,9 +414,12 @@ void WiiTASInputWindow::LoadExtensionAndMotionPlus() m_is_motion_plus_attached = true; ini.GetIfExists(section_name, "Extension/Attach MotionPlus", &m_is_motion_plus_attached); } + + UpdateControlVisibility(); + UpdateInputOverrideFunction(); } -void WiiTASInputWindow::UpdateExt() +void WiiTASInputWindow::UpdateControlVisibility() { if (m_active_extension == WiimoteEmu::ExtensionNumber::NUNCHUK) { @@ -454,17 +478,30 @@ void WiiTASInputWindow::UpdateExt() m_nunchuk_buttons_box->hide(); m_classic_buttons_box->hide(); } + + // Without this, switching between attachments can leave the Stick/IR widgets excessively large + adjustSize(); + resize(sizeHint()); } -void WiiTASInputWindow::hideEvent(QHideEvent* event) +void WiiTASInputWindow::hideEvent(QHideEvent* const event) { GetWiimote()->ClearInputOverrideFunction(); GetExtension()->ClearInputOverrideFunction(); + + TASInputWindow::hideEvent(event); } -void WiiTASInputWindow::showEvent(QShowEvent* event) +void WiiTASInputWindow::showEvent(QShowEvent* const event) { - WiimoteEmu::Wiimote* wiimote = GetWiimote(); + LoadExtensionAndMotionPlus(); + + TASInputWindow::showEvent(event); +} + +void WiiTASInputWindow::UpdateInputOverrideFunction() +{ + WiimoteEmu::Wiimote* const wiimote = GetWiimote(); if (m_active_extension != WiimoteEmu::ExtensionNumber::CLASSIC) wiimote->SetInputOverrideFunction(m_wiimote_overrider.GetInputOverrideFunction()); diff --git a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h index c47ffde55b..2380afe617 100644 --- a/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h +++ b/Source/Core/DolphinQt/TAS/WiiTASInputWindow.h @@ -34,13 +34,17 @@ public: void hideEvent(QHideEvent* event) override; void showEvent(QShowEvent* event) override; + void UpdateExtension(int extension); + void UpdateMotionPlus(bool attached); + private: WiimoteEmu::Wiimote* GetWiimote(); ControllerEmu::Attachments* GetAttachments(); WiimoteEmu::Extension* GetExtension(); - void UpdateExt(); void LoadExtensionAndMotionPlus(); + void UpdateControlVisibility(); + void UpdateInputOverrideFunction(); WiimoteEmu::ExtensionNumber m_active_extension; bool m_is_motion_plus_attached;