From dd3c156af45c9899bceae3fad0aa83c8dbd0d917 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 28 Jul 2021 21:57:36 +0200 Subject: [PATCH] early-access version 1938 --- README.md | 2 +- src/common/settings.h | 11 ++- src/input_common/main.cpp | 8 +- src/input_common/mouse/mouse_poller.cpp | 1 + src/input_common/sdl/sdl_impl.cpp | 87 ++++++++++++++----- src/input_common/tas/tas_input.cpp | 23 ++++- src/input_common/tas/tas_input.h | 1 + src/yuzu/configuration/config.cpp | 5 +- src/yuzu/configuration/config.h | 1 + .../configuration/configuration_shared.cpp | 14 --- src/yuzu/configuration/configuration_shared.h | 15 +++- src/yuzu/configuration/configure_cpu.cpp | 17 +--- src/yuzu/configuration/configure_graphics.cpp | 8 +- .../configure_graphics_advanced.cpp | 20 +---- .../configuration/configure_input_player.cpp | 13 +-- src/yuzu/main.cpp | 26 ++++-- src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 4 +- 17 files changed, 155 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index 9e8d205db..8e10e2c32 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1937. +This is the source code for early-access 1938. ## Legal Notice diff --git a/src/common/settings.h b/src/common/settings.h index c03ee9cb4..f1dda4caf 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -42,6 +42,11 @@ enum class CPUAccuracy : u32 { Unsafe = 2, }; +enum class FullscreenMode : u32 { + Borderless = 0, + Exclusive = 1, +}; + /** The BasicSetting class is a simple resource manager. It defines a label and default value * alongside the actual value of the setting for simpler and less-error prone use with frontend * configurations. Setting a default value and label is required, though subclasses may deviate from @@ -322,11 +327,11 @@ struct Values { Setting resolution_factor{1, "resolution_factor"}; // *nix platforms may have issues with the borderless windowed fullscreen mode. // Default to exclusive fullscreen on these platforms for now. - Setting fullscreen_mode{ + Setting fullscreen_mode{ #ifdef _WIN32 - 0, + FullscreenMode::Borderless, #else - 1, + FullscreenMode::Exclusive, #endif "fullscreen_mode"}; Setting aspect_ratio{0, "aspect_ratio"}; diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b99970c34..18d7d8817 100755 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -356,10 +356,10 @@ std::vector> InputSubsystem::GetPollers([ } std::string GenerateKeyboardParam(int key_code) { - Common::ParamPackage param{ - {"engine", "keyboard"}, - {"code", std::to_string(key_code)}, - }; + Common::ParamPackage param; + param.Set("engine", "keyboard"); + param.Set("code", key_code); + param.Set("toggle", false); return param.Serialize(); } diff --git a/src/input_common/mouse/mouse_poller.cpp b/src/input_common/mouse/mouse_poller.cpp index efcdd85d2..090b26972 100755 --- a/src/input_common/mouse/mouse_poller.cpp +++ b/src/input_common/mouse/mouse_poller.cpp @@ -57,6 +57,7 @@ Common::ParamPackage MouseButtonFactory::GetNextInput() const { if (pad.button != MouseInput::MouseButton::Undefined) { params.Set("engine", "mouse"); params.Set("button", static_cast(pad.button)); + params.Set("toggle", false); return params; } } diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 70a0ba09c..5a56ee72f 100755 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -82,6 +82,12 @@ public: state.buttons.insert_or_assign(button, value); } + void PreSetButton(int button) { + if (!state.buttons.contains(button)) { + SetButton(button, false); + } + } + void SetMotion(SDL_ControllerSensorEvent event) { constexpr float gravity_constant = 9.80665f; std::lock_guard lock{mutex}; @@ -155,9 +161,16 @@ public: state.axes.insert_or_assign(axis, value); } - float GetAxis(int axis, float range) const { + void PreSetAxis(int axis) { + if (!state.axes.contains(axis)) { + SetAxis(axis, 0); + } + } + + float GetAxis(int axis, float range, float offset) const { std::lock_guard lock{mutex}; - return static_cast(state.axes.at(axis)) / (32767.0f * range); + const float value = static_cast(state.axes.at(axis)) / 32767.0f; + return (value + offset) * range; } bool RumblePlay(u16 amp_low, u16 amp_high) { @@ -174,9 +187,10 @@ public: return false; } - std::tuple GetAnalog(int axis_x, int axis_y, float range) const { - float x = GetAxis(axis_x, range); - float y = GetAxis(axis_y, range); + std::tuple GetAnalog(int axis_x, int axis_y, float range, float offset_x, + float offset_y) const { + float x = GetAxis(axis_x, range, offset_x); + float y = GetAxis(axis_y, range, offset_y); y = -y; // 3DS uses an y-axis inverse from SDL // Make sure the coordinates are in the unit circle, @@ -483,7 +497,7 @@ public: trigger_if_greater(trigger_if_greater_) {} bool GetStatus() const override { - const float axis_value = joystick->GetAxis(axis, 1.0f); + const float axis_value = joystick->GetAxis(axis, 1.0f, 0.0f); if (trigger_if_greater) { return axis_value > threshold; } @@ -500,12 +514,14 @@ private: class SDLAnalog final : public Input::AnalogDevice { public: explicit SDLAnalog(std::shared_ptr joystick_, int axis_x_, int axis_y_, - bool invert_x_, bool invert_y_, float deadzone_, float range_) + bool invert_x_, bool invert_y_, float deadzone_, float range_, + float offset_x_, float offset_y_) : joystick(std::move(joystick_)), axis_x(axis_x_), axis_y(axis_y_), invert_x(invert_x_), - invert_y(invert_y_), deadzone(deadzone_), range(range_) {} + invert_y(invert_y_), deadzone(deadzone_), range(range_), offset_x(offset_x_), + offset_y(offset_y_) {} std::tuple GetStatus() const override { - auto [x, y] = joystick->GetAnalog(axis_x, axis_y, range); + auto [x, y] = joystick->GetAnalog(axis_x, axis_y, range, offset_x, offset_y); const float r = std::sqrt((x * x) + (y * y)); if (invert_x) { x = -x; @@ -522,8 +538,8 @@ public: } std::tuple GetRawStatus() const override { - const float x = joystick->GetAxis(axis_x, range); - const float y = joystick->GetAxis(axis_y, range); + const float x = joystick->GetAxis(axis_x, 1.0f, offset_x); + const float y = joystick->GetAxis(axis_y, 1.0f, offset_y); return {x, -y}; } @@ -555,6 +571,8 @@ private: const bool invert_y; const float deadzone; const float range; + const float offset_x; + const float offset_y; }; class SDLVibration final : public Input::VibrationDevice { @@ -621,7 +639,7 @@ public: trigger_if_greater(trigger_if_greater_) {} Input::MotionStatus GetStatus() const override { - const float axis_value = joystick->GetAxis(axis, 1.0f); + const float axis_value = joystick->GetAxis(axis, 1.0f, 0.0f); bool trigger = axis_value < threshold; if (trigger_if_greater) { trigger = axis_value > threshold; @@ -720,13 +738,13 @@ public: LOG_ERROR(Input, "Unknown direction {}", direction_name); } // This is necessary so accessing GetAxis with axis won't crash - joystick->SetAxis(axis, 0); + joystick->PreSetAxis(axis); return std::make_unique(joystick, axis, threshold, trigger_if_greater); } const int button = params.Get("button", 0); // This is necessary so accessing GetButton with button won't crash - joystick->SetButton(button, false); + joystick->PreSetButton(button); return std::make_unique(joystick, button, toggle); } @@ -757,13 +775,15 @@ public: const std::string invert_y_value = params.Get("invert_y", "+"); const bool invert_x = invert_x_value == "-"; const bool invert_y = invert_y_value == "-"; + const float offset_x = params.Get("offset_x", 0.0f); + const float offset_y = params.Get("offset_y", 0.0f); auto joystick = state.GetSDLJoystickByGUID(guid, port); // This is necessary so accessing GetAxis with axis_x and axis_y won't crash - joystick->SetAxis(axis_x, 0); - joystick->SetAxis(axis_y, 0); + joystick->PreSetAxis(axis_x); + joystick->PreSetAxis(axis_y); return std::make_unique(joystick, axis_x, axis_y, invert_x, invert_y, deadzone, - range); + range, offset_x, offset_y); } private: @@ -844,13 +864,13 @@ public: LOG_ERROR(Input, "Unknown direction {}", direction_name); } // This is necessary so accessing GetAxis with axis won't crash - joystick->SetAxis(axis, 0); + joystick->PreSetAxis(axis); return std::make_unique(joystick, axis, threshold, trigger_if_greater); } const int button = params.Get("button", 0); // This is necessary so accessing GetButton with button won't crash - joystick->SetButton(button, false); + joystick->PreSetButton(button); return std::make_unique(joystick, button); } @@ -995,6 +1015,7 @@ Common::ParamPackage BuildButtonParamPackageForButton(int port, std::string guid params.Set("port", port); params.Set("guid", std::move(guid)); params.Set("button", button); + params.Set("toggle", false); return params; } @@ -1134,13 +1155,15 @@ Common::ParamPackage BuildParamPackageForBinding(int port, const std::string& gu } Common::ParamPackage BuildParamPackageForAnalog(int port, const std::string& guid, int axis_x, - int axis_y) { + int axis_y, float offset_x, float offset_y) { Common::ParamPackage params; params.Set("engine", "sdl"); params.Set("port", port); params.Set("guid", guid); params.Set("axis_x", axis_x); params.Set("axis_y", axis_y); + params.Set("offset_x", offset_x); + params.Set("offset_y", offset_y); params.Set("invert_x", "+"); params.Set("invert_y", "+"); return params; @@ -1342,24 +1365,39 @@ AnalogMapping SDLState::GetAnalogMappingForDevice(const Common::ParamPackage& pa const auto& binding_left_y = SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTY); if (params.Has("guid2")) { + joystick2->PreSetAxis(binding_left_x.value.axis); + joystick2->PreSetAxis(binding_left_y.value.axis); + const auto left_offset_x = -joystick2->GetAxis(binding_left_x.value.axis, 1.0f, 0); + const auto left_offset_y = -joystick2->GetAxis(binding_left_y.value.axis, 1.0f, 0); mapping.insert_or_assign( Settings::NativeAnalog::LStick, BuildParamPackageForAnalog(joystick2->GetPort(), joystick2->GetGUID(), - binding_left_x.value.axis, binding_left_y.value.axis)); + binding_left_x.value.axis, binding_left_y.value.axis, + left_offset_x, left_offset_y)); } else { + joystick->PreSetAxis(binding_left_x.value.axis); + joystick->PreSetAxis(binding_left_y.value.axis); + const auto left_offset_x = -joystick->GetAxis(binding_left_x.value.axis, 1.0f, 0); + const auto left_offset_y = -joystick->GetAxis(binding_left_y.value.axis, 1.0f, 0); mapping.insert_or_assign( Settings::NativeAnalog::LStick, BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), - binding_left_x.value.axis, binding_left_y.value.axis)); + binding_left_x.value.axis, binding_left_y.value.axis, + left_offset_x, left_offset_y)); } const auto& binding_right_x = SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX); const auto& binding_right_y = SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY); + joystick->PreSetAxis(binding_right_x.value.axis); + joystick->PreSetAxis(binding_right_y.value.axis); + const auto right_offset_x = -joystick->GetAxis(binding_right_x.value.axis, 1.0f, 0); + const auto right_offset_y = -joystick->GetAxis(binding_right_y.value.axis, 1.0f, 0); mapping.insert_or_assign(Settings::NativeAnalog::RStick, BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), binding_right_x.value.axis, - binding_right_y.value.axis)); + binding_right_y.value.axis, right_offset_x, + right_offset_y)); return mapping; } @@ -1563,8 +1601,9 @@ public: } if (const auto joystick = state.GetSDLJoystickBySDLID(event.jaxis.which)) { + // Set offset to zero since the joystick is not on center auto params = BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), - first_axis, axis); + first_axis, axis, 0, 0); first_axis = -1; return params; } diff --git a/src/input_common/tas/tas_input.cpp b/src/input_common/tas/tas_input.cpp index 777e8c7c0..7c1fe2dd7 100755 --- a/src/input_common/tas/tas_input.cpp +++ b/src/input_common/tas/tas_input.cpp @@ -40,12 +40,16 @@ constexpr std::array, 20> text_to_tas_but Tas::Tas() { if (!Settings::values.tas_enable) { + needs_reset = true; return; } LoadTasFiles(); } -Tas::~Tas() = default; +Tas::~Tas() { + SwapToStoredController(); + is_running = false; +}; void Tas::LoadTasFiles() { script_length = 0; @@ -184,6 +188,10 @@ std::string Tas::ButtonsToString(u32 button) const { void Tas::UpdateThread() { if (!Settings::values.tas_enable) { + if (is_running) { + SwapToStoredController(); + is_running = false; + } return; } @@ -294,6 +302,9 @@ std::string Tas::WriteCommandButtons(u32 data) const { } void Tas::StartStop() { + if (!Settings::values.tas_enable) { + return; + } is_running = !is_running; if (is_running) { SwapToTasController(); @@ -330,25 +341,33 @@ void Tas::SwapToTasController() { analogs[i] = analog_mapping[static_cast(i)].Serialize(); } } + is_old_input_saved = true; Settings::values.is_device_reload_pending.store(true); } void Tas::SwapToStoredController() { - if (!Settings::values.tas_swap_controllers) { + if (!is_old_input_saved) { return; } auto& players = Settings::values.players.GetValue(); for (std::size_t index = 0; index < players.size(); index++) { players[index] = player_mappings[index]; } + is_old_input_saved = false; Settings::values.is_device_reload_pending.store(true); } void Tas::Reset() { + if (!Settings::values.tas_enable) { + return; + } needs_reset = true; } bool Tas::Record() { + if (!Settings::values.tas_enable) { + return true; + } is_recording = !is_recording; return is_recording; } diff --git a/src/input_common/tas/tas_input.h b/src/input_common/tas/tas_input.h index c9a0f8f32..401e51fab 100755 --- a/src/input_common/tas/tas_input.h +++ b/src/input_common/tas/tas_input.h @@ -219,6 +219,7 @@ private: size_t script_length{0}; std::array tas_data; + bool is_old_input_saved{false}; bool is_recording{false}; bool is_running{false}; bool needs_reset{false}; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 8779ce54c..8a6d79ebf 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -1356,7 +1356,10 @@ void Config::SaveRendererValues() { static_cast(Settings::values.renderer_backend.GetDefault()), Settings::values.renderer_backend.UsingGlobal()); WriteGlobalSetting(Settings::values.vulkan_device); - WriteGlobalSetting(Settings::values.fullscreen_mode); + WriteSetting(QString::fromStdString(Settings::values.fullscreen_mode.GetLabel()), + static_cast(Settings::values.fullscreen_mode.GetValue(global)), + static_cast(Settings::values.fullscreen_mode.GetDefault()), + Settings::values.fullscreen_mode.UsingGlobal()); WriteGlobalSetting(Settings::values.aspect_ratio); WriteGlobalSetting(Settings::values.max_anisotropy); WriteGlobalSetting(Settings::values.use_speed_limit); diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index a47b5a7da..36e277bda 100755 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -181,5 +181,6 @@ private: // These metatype declarations cannot be in common/settings.h because core is devoid of QT Q_DECLARE_METATYPE(Settings::CPUAccuracy); Q_DECLARE_METATYPE(Settings::GPUAccuracy); +Q_DECLARE_METATYPE(Settings::FullscreenMode); Q_DECLARE_METATYPE(Settings::RendererBackend); Q_DECLARE_METATYPE(Settings::ShaderBackend); diff --git a/src/yuzu/configuration/configuration_shared.cpp b/src/yuzu/configuration/configuration_shared.cpp index 096e42e94..251aab912 100755 --- a/src/yuzu/configuration/configuration_shared.cpp +++ b/src/yuzu/configuration/configuration_shared.cpp @@ -25,20 +25,6 @@ void ConfigurationShared::ApplyPerGameSetting(Settings::Setting* setting, } } -void ConfigurationShared::ApplyPerGameSetting(Settings::Setting* setting, - const QComboBox* combobox) { - if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { - setting->SetValue(combobox->currentIndex()); - } else if (!Settings::IsConfiguringGlobal()) { - if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { - setting->SetGlobal(true); - } else { - setting->SetGlobal(false); - setting->SetValue(combobox->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET); - } - } -} - void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting* setting) { if (setting->UsingGlobal()) { diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index 1e0ef01ca..5423dbc92 100755 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h @@ -28,7 +28,20 @@ enum class CheckState { // ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting void ApplyPerGameSetting(Settings::Setting* setting, const QCheckBox* checkbox, const CheckState& tracker); -void ApplyPerGameSetting(Settings::Setting* setting, const QComboBox* combobox); +template +void ApplyPerGameSetting(Settings::Setting* setting, const QComboBox* combobox) { + if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { + setting->SetValue(static_cast(combobox->currentIndex())); + } else if (!Settings::IsConfiguringGlobal()) { + if (combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { + setting->SetGlobal(true); + } else { + setting->SetGlobal(false); + setting->SetValue(static_cast(combobox->currentIndex() - + ConfigurationShared::USE_GLOBAL_OFFSET)); + } + } +} // Sets a Qt UI element given a Settings::Setting void SetPerGameSetting(QCheckBox* checkbox, const Settings::Setting* setting); diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index 8d7171487..784b6484e 100755 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -65,6 +65,7 @@ void ConfigureCpu::UpdateGroup(int index) { } void ConfigureCpu::ApplyConfiguration() { + ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpu_accuracy, ui->accuracy); ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_unfuse_fma, ui->cpuopt_unsafe_unfuse_fma, cpuopt_unsafe_unfuse_fma); @@ -80,22 +81,6 @@ void ConfigureCpu::ApplyConfiguration() { ConfigurationShared::ApplyPerGameSetting(&Settings::values.cpuopt_unsafe_fastmem_check, ui->cpuopt_unsafe_fastmem_check, cpuopt_unsafe_fastmem_check); - - if (Settings::IsConfiguringGlobal()) { - // Guard if during game and set to game-specific value - if (Settings::values.cpu_accuracy.UsingGlobal()) { - Settings::values.cpu_accuracy.SetValue( - static_cast(ui->accuracy->currentIndex())); - } - } else { - if (ui->accuracy->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { - Settings::values.cpu_accuracy.SetGlobal(true); - } else { - Settings::values.cpu_accuracy.SetGlobal(false); - Settings::values.cpu_accuracy.SetValue(static_cast( - ui->accuracy->currentIndex() - ConfigurationShared::USE_GLOBAL_OFFSET)); - } - } } void ConfigureCpu::changeEvent(QEvent* event) { diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 1bc477c96..37e896258 100755 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -98,7 +98,8 @@ void ConfigureGraphics::SetConfiguration() { if (Settings::IsConfiguringGlobal()) { ui->api->setCurrentIndex(static_cast(Settings::values.renderer_backend.GetValue())); - ui->fullscreen_mode_combobox->setCurrentIndex(Settings::values.fullscreen_mode.GetValue()); + ui->fullscreen_mode_combobox->setCurrentIndex( + static_cast(Settings::values.fullscreen_mode.GetValue())); ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio.GetValue()); } else { ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); @@ -310,8 +311,9 @@ void ConfigureGraphics::SetupPerGameUI() { ConfigurationShared::SetColoredComboBox(ui->aspect_ratio_combobox, ui->ar_label, Settings::values.aspect_ratio.GetValue(true)); - ConfigurationShared::SetColoredComboBox(ui->fullscreen_mode_combobox, ui->fullscreen_mode_label, - Settings::values.fullscreen_mode.GetValue(true)); + ConfigurationShared::SetColoredComboBox( + ui->fullscreen_mode_combobox, ui->fullscreen_mode_label, + static_cast(Settings::values.fullscreen_mode.GetValue(true))); ConfigurationShared::InsertGlobalItem( ui->api, static_cast(Settings::values.renderer_backend.GetValue(true))); } diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 38276feb1..a31b8e192 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -48,11 +48,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { } void ConfigureGraphicsAdvanced::ApplyConfiguration() { - // Subtract 2 if configuring per-game (separator and "use global configuration" take 2 slots) - const auto gpu_accuracy = static_cast( - ui->gpu_accuracy->currentIndex() - - ((Settings::IsConfiguringGlobal()) ? 0 : ConfigurationShared::USE_GLOBAL_OFFSET)); - + ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy); ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, ui->anisotropic_filtering_combobox); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); @@ -63,20 +59,6 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { use_caches_gc); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_fast_gpu_time, ui->use_fast_gpu_time, use_fast_gpu_time); - - if (Settings::IsConfiguringGlobal()) { - // Must guard in case of a during-game configuration when set to be game-specific. - if (Settings::values.gpu_accuracy.UsingGlobal()) { - Settings::values.gpu_accuracy.SetValue(gpu_accuracy); - } - } else { - if (ui->gpu_accuracy->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { - Settings::values.gpu_accuracy.SetGlobal(true); - } else { - Settings::values.gpu_accuracy.SetGlobal(false); - Settings::values.gpu_accuracy.SetValue(gpu_accuracy); - } - } } void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) { diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index d415d9cad..88f4bf388 100755 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -323,11 +323,14 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i buttons_param[button_id].Clear(); button_map[button_id]->setText(tr("[not set]")); }); - context_menu.addAction(tr("Toggle button"), [&] { - const bool toggle_value = !buttons_param[button_id].Get("toggle", false); - buttons_param[button_id].Set("toggle", toggle_value); - button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); - }); + if (buttons_param[button_id].Has("toggle")) { + context_menu.addAction(tr("Toggle button"), [&] { + const bool toggle_value = + !buttons_param[button_id].Get("toggle", false); + buttons_param[button_id].Set("toggle", toggle_value); + button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); + }); + } if (buttons_param[button_id].Has("threshold")) { context_menu.addAction(tr("Set threshold"), [&] { const int button_threshold = static_cast( diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index b134e997c..7fd4b1894 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1037,11 +1037,24 @@ void GMainWindow::InitializeHotkeys() { } }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Start/Stop"), this), - &QShortcut::activated, this, [&] { input_subsystem->GetTas()->StartStop(); }); + &QShortcut::activated, this, [&] { + if (!emulation_running) { + return; + } + input_subsystem->GetTas()->StartStop(); + }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Reset"), this), - &QShortcut::activated, this, [&] { input_subsystem->GetTas()->Reset(); }); + &QShortcut::activated, this, [&] { + if (emulation_running) { + input_subsystem->GetTas()->Reset(); + } + input_subsystem->GetTas()->Reset(); + }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("TAS Record"), this), &QShortcut::activated, this, [&] { + if (!emulation_running) { + return; + } bool is_recording = input_subsystem->GetTas()->Record(); if (!is_recording) { const auto res = QMessageBox::question(this, tr("TAS Recording"), @@ -1502,6 +1515,7 @@ void GMainWindow::ShutdownGame() { } game_list->SetFilterFocus(); tas_label->clear(); + input_subsystem->GetTas()->~Tas(); render_window->removeEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, false); @@ -2536,7 +2550,7 @@ void GMainWindow::ShowFullscreen() { ui.menubar->hide(); statusBar()->hide(); - if (Settings::values.fullscreen_mode.GetValue() == 1) { + if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { showFullScreen(); return; } @@ -2551,7 +2565,7 @@ void GMainWindow::ShowFullscreen() { } else { UISettings::values.renderwindow_geometry = render_window->saveGeometry(); - if (Settings::values.fullscreen_mode.GetValue() == 1) { + if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { render_window->showFullScreen(); return; } @@ -2568,7 +2582,7 @@ void GMainWindow::ShowFullscreen() { void GMainWindow::HideFullscreen() { if (ui.action_Single_Window_Mode->isChecked()) { - if (Settings::values.fullscreen_mode.GetValue() == 1) { + if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { showNormal(); restoreGeometry(UISettings::values.geometry); } else { @@ -2582,7 +2596,7 @@ void GMainWindow::HideFullscreen() { statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); ui.menubar->show(); } else { - if (Settings::values.fullscreen_mode.GetValue() == 1) { + if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Exclusive) { render_window->showNormal(); render_window->restoreGeometry(UISettings::values.renderwindow_geometry); } else { diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 353e51ea7..ea3e0ada4 100755 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -124,7 +124,7 @@ void EmuWindow_SDL2::OnResize() { void EmuWindow_SDL2::Fullscreen() { switch (Settings::values.fullscreen_mode.GetValue()) { - case 1: // Exclusive fullscreen + case Settings::FullscreenMode::Exclusive: // Set window size to render size before entering fullscreen -- SDL does not resize to // display dimensions in this mode. // TODO: Multiply the window size by resolution_factor (for both docked modes) @@ -140,7 +140,7 @@ void EmuWindow_SDL2::Fullscreen() { LOG_ERROR(Frontend, "Fullscreening failed: {}", SDL_GetError()); LOG_INFO(Frontend, "Attempting to use borderless fullscreen..."); [[fallthrough]]; - case 0: // Borderless window + case Settings::FullscreenMode::Borderless: if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) { return; }