configure_input_simple: Properly signal docked mode change

This commit is contained in:
Zach Hilman 2018-12-04 22:01:01 -05:00
parent 233a804196
commit c07059e7fd
3 changed files with 31 additions and 33 deletions

View file

@ -20,6 +20,33 @@
#include "yuzu/configuration/configure_input_player.h" #include "yuzu/configuration/configure_input_player.h"
#include "yuzu/configuration/configure_mouse_advanced.h" #include "yuzu/configuration/configure_mouse_advanced.h"
void OnDockedModeChanged(bool last_state, bool new_state) {
if (last_state == new_state) {
return;
}
Core::System& system{Core::System::GetInstance()};
if (!system.IsPoweredOn()) {
return;
}
Service::SM::ServiceManager& sm = system.ServiceManager();
// Message queue is shared between these services, we just need to signal an operation
// change to one and it will handle both automatically
auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
bool has_signalled = false;
if (applet_oe != nullptr) {
applet_oe->GetMessageQueue()->OperationModeChanged();
has_signalled = true;
}
if (applet_ae != nullptr && !has_signalled) {
applet_ae->GetMessageQueue()->OperationModeChanged();
}
}
namespace { namespace {
template <typename Dialog, typename... Args> template <typename Dialog, typename... Args>
void CallConfigureDialog(ConfigureInput& parent, Args&&... args) { void CallConfigureDialog(ConfigureInput& parent, Args&&... args) {
@ -90,37 +117,6 @@ ConfigureInput::ConfigureInput(QWidget* parent)
ConfigureInput::~ConfigureInput() = default; ConfigureInput::~ConfigureInput() = default;
void ConfigureInput::OnDockedModeChanged(bool last_state, bool new_state) {
if (ui->use_docked_mode->isChecked() && ui->handheld_connected->isChecked()) {
ui->handheld_connected->setChecked(false);
}
if (last_state == new_state) {
return;
}
Core::System& system{Core::System::GetInstance()};
if (!system.IsPoweredOn()) {
return;
}
Service::SM::ServiceManager& sm = system.ServiceManager();
// Message queue is shared between these services, we just need to signal an operation
// change to one and it will handle both automatically
auto applet_oe = sm.GetService<Service::AM::AppletOE>("appletOE");
auto applet_ae = sm.GetService<Service::AM::AppletAE>("appletAE");
bool has_signalled = false;
if (applet_oe != nullptr) {
applet_oe->GetMessageQueue()->OperationModeChanged();
has_signalled = true;
}
if (applet_ae != nullptr && !has_signalled) {
applet_ae->GetMessageQueue()->OperationModeChanged();
}
}
void ConfigureInput::applyConfiguration() { void ConfigureInput::applyConfiguration() {
for (std::size_t i = 0; i < players_controller.size(); ++i) { for (std::size_t i = 0; i < players_controller.size(); ++i) {
const auto controller_type_index = players_controller[i]->currentIndex(); const auto controller_type_index = players_controller[i]->currentIndex();

View file

@ -20,6 +20,8 @@ namespace Ui {
class ConfigureInput; class ConfigureInput;
} }
void OnDockedModeChanged(bool last_state, bool new_state);
class ConfigureInput : public QDialog { class ConfigureInput : public QDialog {
Q_OBJECT Q_OBJECT
@ -33,8 +35,6 @@ public:
private: private:
void updateUIEnabled(); void updateUIEnabled();
void OnDockedModeChanged(bool last_state, bool new_state);
/// Load configuration settings. /// Load configuration settings.
void loadConfiguration(); void loadConfiguration();
/// Restore all buttons to their default values. /// Restore all buttons to their default values.

View file

@ -132,7 +132,9 @@ void ConfigureInputSimple::loadConfiguration() {
} }
void ConfigureInputSimple::OnSelectProfile(int index) { void ConfigureInputSimple::OnSelectProfile(int index) {
const auto old_docked = Settings::values.use_docked_mode;
ApplyInputProfileConfiguration(index); ApplyInputProfileConfiguration(index);
OnDockedModeChanged(old_docked, Settings::values.use_docked_mode);
} }
void ConfigureInputSimple::OnConfigure() { void ConfigureInputSimple::OnConfigure() {