From 5b6268d26a178f8104c7075daf24df37147a202b Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sat, 5 Sep 2020 09:42:01 -0400 Subject: configure_input: Hook up the motion button and checkbox This allows toggling motion on or off, and allows access to the motion configuration. Also changes the [waiting] text for motion buttons to Shake! as this is how motion is connected to a player. --- src/core/hle/service/hid/controllers/npad.cpp | 2 +- src/core/settings.h | 1 + src/yuzu/configuration/config.cpp | 2 ++ src/yuzu/configuration/configure_input.cpp | 7 +++++++ src/yuzu/configuration/configure_input_player.cpp | 11 +++++------ src/yuzu_cmd/config.cpp | 2 ++ src/yuzu_tester/config.cpp | 1 + 7 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 510fa3071..b3b1a3a8a 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -389,7 +389,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* // Try to read sixaxis sensor states std::array motion_devices; - if (sixaxis_sensors_enabled) { + if (sixaxis_sensors_enabled && Settings::values.motion_enabled) { sixaxis_at_rest = true; for (std::size_t e = 0; e < motion_devices.size(); ++e) { const auto& device = motions[i][e]; diff --git a/src/core/settings.h b/src/core/settings.h index 80f0d95a7..9834f44bb 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -152,6 +152,7 @@ struct Values { bool vibration_enabled; + bool motion_enabled; std::string motion_device; std::string touch_device; TouchscreenInput touchscreen; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 40ca42b75..d2913d613 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -445,6 +445,7 @@ void Config::ReadControlValues() { Settings::values.vibration_enabled = ReadSetting(QStringLiteral("vibration_enabled"), true).toBool(); + Settings::values.motion_enabled = ReadSetting(QStringLiteral("motion_enabled"), true).toBool(); Settings::values.use_docked_mode = ReadSetting(QStringLiteral("use_docked_mode"), false).toBool(); @@ -1091,6 +1092,7 @@ void Config::SaveControlValues() { SaveMotionTouchValues(); WriteSetting(QStringLiteral("vibration_enabled"), Settings::values.vibration_enabled, true); + WriteSetting(QStringLiteral("motion_enabled"), Settings::values.motion_enabled, true); WriteSetting(QStringLiteral("motion_device"), QString::fromStdString(Settings::values.motion_device), QStringLiteral("engine:motion_emu,update_period:100,sensitivity:0.01")); diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index ae3e31762..1c54355d1 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -133,6 +133,10 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem) { CallConfigureDialog(*this, input_subsystem); }); + connect(ui->motionButton, &QPushButton::clicked, [this, input_subsystem] { + CallConfigureDialog(*this, input_subsystem); + }); + connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); }); connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); }); @@ -159,6 +163,7 @@ void ConfigureInput::ApplyConfiguration() { OnDockedModeChanged(pre_docked_mode, Settings::values.use_docked_mode); Settings::values.vibration_enabled = ui->vibrationGroup->isChecked(); + Settings::values.motion_enabled = ui->motionGroup->isChecked(); } void ConfigureInput::changeEvent(QEvent* event) { @@ -179,6 +184,7 @@ void ConfigureInput::LoadConfiguration() { Settings::ControllerType::Handheld); ui->vibrationGroup->setChecked(Settings::values.vibration_enabled); + ui->motionGroup->setChecked(Settings::values.motion_enabled); } void ConfigureInput::LoadPlayerControllerIndices() { @@ -205,6 +211,7 @@ void ConfigureInput::RestoreDefaults() { ui->radioDocked->setChecked(true); ui->radioUndocked->setChecked(false); ui->vibrationGroup->setChecked(true); + ui->motionGroup->setChecked(true); } void ConfigureInput::UpdateDockedState(bool is_handheld) { diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 55ea7ccde..9d7f23459 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -340,11 +340,6 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i motions_param[motion_id].Clear(); motion_map[motion_id]->setText(tr("[not set]")); }); - context_menu.addAction(tr("Restore Default"), [&] { - motions_param[motion_id] = Common::ParamPackage{ - InputCommon::GenerateKeyboardParam(Config::default_motions[motion_id])}; - motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id])); - }); context_menu.exec(motion_map[motion_id]->mapToGlobal(menu_location)); }); } @@ -738,7 +733,11 @@ void ConfigureInputPlayer::UpdateMappingWithDefaults() { void ConfigureInputPlayer::HandleClick( QPushButton* button, std::function new_input_setter, InputCommon::Polling::DeviceType type) { - button->setText(tr("[waiting]")); + if (button == ui->buttonMotionLeft || button == ui->buttonMotionRight) { + button->setText(tr("Shake!")); + } else { + button->setText(tr("[waiting]")); + } button->setFocus(); // The first two input devices are always Any and Keyboard/Mouse. If the user filtered to a diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index e9f1c6500..23448e747 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -290,6 +290,8 @@ void Config::ReadValues() { Settings::values.vibration_enabled = sdl2_config->GetBoolean("ControlsGeneral", "vibration_enabled", true); + Settings::values.motion_enabled = + sdl2_config->GetBoolean("ControlsGeneral", "motion_enabled", true); Settings::values.touchscreen.enabled = sdl2_config->GetBoolean("ControlsGeneral", "touch_enabled", true); Settings::values.touchscreen.device = diff --git a/src/yuzu_tester/config.cpp b/src/yuzu_tester/config.cpp index aaf59129a..bc273fb51 100644 --- a/src/yuzu_tester/config.cpp +++ b/src/yuzu_tester/config.cpp @@ -76,6 +76,7 @@ void Config::ReadValues() { } Settings::values.vibration_enabled = true; + Settings::values.motion_enabled = true; Settings::values.touchscreen.enabled = ""; Settings::values.touchscreen.device = ""; Settings::values.touchscreen.finger = 0; -- cgit v1.2.3