diff --git a/README.md b/README.md index c85033cc7..3d5a1e1c3 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1883. +This is the source code for early-access 1884. ## Legal Notice diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 38667351a..66268ea0f 100755 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -103,7 +103,7 @@ float Volume() { if (values.audio_muted) { return 0.0f; } - return values.volume.GetValue(); + return values.volume.GetValue() / 100.0f; } void RestoreGlobalState(bool is_powered_on) { diff --git a/src/common/settings.h b/src/common/settings.h index 3b748db0b..c5ba3d337 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -284,7 +284,7 @@ struct Values { BasicSetting sink_id{"auto", "output_engine"}; BasicSetting audio_muted{false, "audio_muted"}; Setting enable_audio_stretching{true, "enable_audio_stretching"}; - Setting volume{1.0f, "volume"}; + Setting volume{100, "volume"}; // Core Setting use_multi_core{true, "use_multi_core"}; @@ -345,9 +345,9 @@ struct Values { Setting use_fast_gpu_time{true, "use_fast_gpu_time"}; Setting use_caches_gc{false, "use_caches_gc"}; - Setting bg_red{0.0f, "bg_red"}; - Setting bg_green{0.0f, "bg_green"}; - Setting bg_blue{0.0f, "bg_blue"}; + Setting bg_red{0, "bg_red"}; + Setting bg_green{0, "bg_green"}; + Setting bg_blue{0, "bg_blue"}; // System Setting> rng_seed{std::optional(), "rng_seed"}; @@ -377,7 +377,7 @@ struct Values { "udp_input_servers"}; BasicSetting mouse_panning{false, "mouse_panning"}; - BasicSetting mouse_panning_sensitivity{1.0f, "mouse_panning_sensitivity"}; + BasicSetting mouse_panning_sensitivity{1, "mouse_panning_sensitivity"}; BasicSetting mouse_enabled{false, "mouse_enabled"}; std::string mouse_device; MouseButtonsRaw mouse_buttons; diff --git a/src/input_common/mouse/mouse_poller.cpp b/src/input_common/mouse/mouse_poller.cpp index 45b3d7340..1e84eaddd 100755 --- a/src/input_common/mouse/mouse_poller.cpp +++ b/src/input_common/mouse/mouse_poller.cpp @@ -84,7 +84,7 @@ public: std::lock_guard lock{mutex}; const auto axis_value = static_cast(mouse_input->GetMouseState(button).axis.at(axis)); - const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue(); + const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.15f; return axis_value * sensitivity / (100.0f * range); } diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 68672a92b..c150165cf 100755 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -115,6 +115,41 @@ public: return state.buttons.at(button); } + bool ToggleButton(int button) { + std::lock_guard lock{mutex}; + + if (!state.toggle_buttons.contains(button) || !state.lock_buttons.contains(button)) { + state.toggle_buttons.insert_or_assign(button, false); + state.lock_buttons.insert_or_assign(button, false); + } + + const bool button_state = state.toggle_buttons.at(button); + const bool button_lock = state.lock_buttons.at(button); + + if (button_lock) { + return button_state; + } + + state.lock_buttons.insert_or_assign(button, true); + + if (button_state) { + state.toggle_buttons.insert_or_assign(button, false); + } else { + state.toggle_buttons.insert_or_assign(button, true); + } + + return !button_state; + } + + bool UnlockButton(int button) { + std::lock_guard lock{mutex}; + if (!state.toggle_buttons.contains(button)) { + return false; + } + state.lock_buttons.insert_or_assign(button, false); + return state.toggle_buttons.at(button); + } + void SetAxis(int axis, Sint16 value) { std::lock_guard lock{mutex}; state.axes.insert_or_assign(axis, value); @@ -241,6 +276,8 @@ public: private: struct State { std::unordered_map buttons; + std::unordered_map toggle_buttons{}; + std::unordered_map lock_buttons{}; std::unordered_map axes; std::unordered_map hats; } state; @@ -402,16 +439,25 @@ void SDLState::CloseJoysticks() { class SDLButton final : public Input::ButtonDevice { public: - explicit SDLButton(std::shared_ptr joystick_, int button_) - : joystick(std::move(joystick_)), button(button_) {} + explicit SDLButton(std::shared_ptr joystick_, int button_, bool toggle_) + : joystick(std::move(joystick_)), button(button_), toggle(toggle_) {} bool GetStatus() const override { - return joystick->GetButton(button); + const bool button_state = joystick->GetButton(button); + if (!toggle) { + return button_state; + } + + if (button_state) { + return joystick->ToggleButton(button); + } + return joystick->UnlockButton(button); } private: std::shared_ptr joystick; int button; + bool toggle; }; class SDLDirectionButton final : public Input::ButtonDevice { @@ -635,6 +681,7 @@ public: std::unique_ptr Create(const Common::ParamPackage& params) override { const std::string guid = params.Get("guid", "0"); const int port = params.Get("port", 0); + const auto toggle = params.Get("toggle", false); auto joystick = state.GetSDLJoystickByGUID(guid, port); @@ -660,7 +707,8 @@ public: if (params.Has("axis")) { const int axis = params.Get("axis", 0); - const float threshold = params.Get("threshold", 0.5f); + // Convert range from (0.0, 1.0) to (-1.0, 1.0) + const float threshold = (params.Get("threshold", 0.5f) - 0.5f) * 2.0f; const std::string direction_name = params.Get("direction", ""); bool trigger_if_greater; if (direction_name == "+") { @@ -679,7 +727,7 @@ public: const int button = params.Get("button", 0); // This is necessary so accessing GetButton with button won't crash joystick->SetButton(button, false); - return std::make_unique(joystick, button); + return std::make_unique(joystick, button, toggle); } private: @@ -933,12 +981,11 @@ Common::ParamPackage BuildAnalogParamPackageForButton(int port, std::string guid params.Set("port", port); params.Set("guid", std::move(guid)); params.Set("axis", axis); + params.Set("threshold", "0.5"); if (value > 0) { params.Set("direction", "+"); - params.Set("threshold", "0.5"); } else { params.Set("direction", "-"); - params.Set("threshold", "-0.5"); } return params; } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index cf7f996ab..80a9c55fe 100755 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -250,9 +250,6 @@ void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color } void RendererOpenGL::InitOpenGLObjects() { - glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(), - Settings::values.bg_blue.GetValue(), 0.0f); - // Create shader programs present_vertex = CreateProgram(HostShaders::OPENGL_PRESENT_VERT, GL_VERTEX_SHADER); present_fragment = CreateProgram(HostShaders::OPENGL_PRESENT_FRAG, GL_FRAGMENT_SHADER); @@ -333,8 +330,9 @@ void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { if (renderer_settings.set_background_color) { // Update background color before drawing - glClearColor(Settings::values.bg_red.GetValue(), Settings::values.bg_green.GetValue(), - Settings::values.bg_blue.GetValue(), 0.0f); + glClearColor(Settings::values.bg_red.GetValue() / 255.0f, + Settings::values.bg_green.GetValue() / 255.0f, + Settings::values.bg_blue.GetValue() / 255.0f, 1.0f); } // Set projection matrix const std::array ortho_matrix = diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 31054cf14..516f428e7 100755 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp @@ -221,8 +221,11 @@ VkSemaphore VKBlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, bool }); } scheduler.Record([this, image_index, size = swapchain.GetSize()](vk::CommandBuffer cmdbuf) { + const f32 bg_red = Settings::values.bg_red.GetValue() / 255.0f; + const f32 bg_green = Settings::values.bg_green.GetValue() / 255.0f; + const f32 bg_blue = Settings::values.bg_blue.GetValue() / 255.0f; const VkClearValue clear_color{ - .color = {.float32 = {0.0f, 0.0f, 0.0f, 0.0f}}, + .color = {.float32 = {bg_red, bg_green, bg_blue, 1.0f}}, }; const VkRenderPassBeginInfo renderpass_bi{ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index ab7204802..52b3ed02e 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -311,16 +311,6 @@ void Config::WriteBasicSetting(const Settings::BasicSetting& settin qt_config->setValue(name, QString::fromStdString(value)); } -// Explicit float definition: use a double as Qt doesn't write legible floats to config files -template <> -void Config::WriteBasicSetting(const Settings::BasicSetting& setting) { - const QString name = QString::fromStdString(setting.GetLabel()); - const double value = setting.GetValue(); - qt_config->setValue(name + QStringLiteral("/default"), - setting.GetValue() == setting.GetDefault()); - qt_config->setValue(name, value); -} - template void Config::WriteBasicSetting(const Settings::BasicSetting& setting) { const QString name = QString::fromStdString(setting.GetLabel()); @@ -329,21 +319,6 @@ void Config::WriteBasicSetting(const Settings::BasicSetting& setting) { qt_config->setValue(name, value); } -// Explicit float definition: use a double as Qt doesn't write legible floats to config files -template <> -void Config::WriteGlobalSetting(const Settings::Setting& setting) { - const QString name = QString::fromStdString(setting.GetLabel()); - const double value = setting.GetValue(global); - if (!global) { - qt_config->setValue(name + QStringLiteral("/use_global"), setting.UsingGlobal()); - } - if (global || !setting.UsingGlobal()) { - qt_config->setValue(name + QStringLiteral("/default"), - setting.GetValue(global) == setting.GetDefault()); - qt_config->setValue(name, value); - } -} - template void Config::WriteGlobalSetting(const Settings::Setting& setting) { const QString name = QString::fromStdString(setting.GetLabel()); diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 5aba1a3b2..1d84bf4ed 100755 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -47,7 +47,8 @@ void ConfigureAudio::SetConfiguration() { SetAudioDeviceFromDeviceID(); - ui->volume_slider->setValue(Settings::values.volume.GetValue() * ui->volume_slider->maximum()); + const auto volume_value = static_cast(Settings::values.volume.GetValue()); + ui->volume_slider->setValue(volume_value); ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching.GetValue()); @@ -112,18 +113,16 @@ void ConfigureAudio::ApplyConfiguration() { // Guard if during game and set to game-specific value if (Settings::values.volume.UsingGlobal()) { - Settings::values.volume.SetValue( - static_cast(ui->volume_slider->sliderPosition()) / - ui->volume_slider->maximum()); + const auto volume = static_cast(ui->volume_slider->value()); + Settings::values.volume.SetValue(volume); } } else { if (ui->volume_combo_box->currentIndex() == 0) { Settings::values.volume.SetGlobal(true); } else { Settings::values.volume.SetGlobal(false); - Settings::values.volume.SetValue( - static_cast(ui->volume_slider->sliderPosition()) / - ui->volume_slider->maximum()); + const auto volume = static_cast(ui->volume_slider->value()); + Settings::values.volume.SetValue(volume); } } } diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 7097e4c2d..fef211707 100755 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -119,10 +119,9 @@ void ConfigureGraphics::SetConfiguration() { ui->bg_button->setEnabled(!Settings::values.bg_red.UsingGlobal()); ConfigurationShared::SetHighlight(ui->bg_layout, !Settings::values.bg_red.UsingGlobal()); } - - UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red.GetValue(), - Settings::values.bg_green.GetValue(), - Settings::values.bg_blue.GetValue())); + UpdateBackgroundColorButton(QColor::fromRgb(Settings::values.bg_red.GetValue(), + Settings::values.bg_green.GetValue(), + Settings::values.bg_blue.GetValue())); UpdateAPILayout(); } @@ -154,9 +153,9 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.vulkan_device.SetValue(vulkan_device); } if (Settings::values.bg_red.UsingGlobal()) { - Settings::values.bg_red.SetValue(static_cast(bg_color.redF())); - Settings::values.bg_green.SetValue(static_cast(bg_color.greenF())); - Settings::values.bg_blue.SetValue(static_cast(bg_color.blueF())); + Settings::values.bg_red.SetValue(static_cast(bg_color.red())); + Settings::values.bg_green.SetValue(static_cast(bg_color.green())); + Settings::values.bg_blue.SetValue(static_cast(bg_color.blue())); } } else { if (ui->api->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { @@ -188,9 +187,9 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.bg_red.SetGlobal(false); Settings::values.bg_green.SetGlobal(false); Settings::values.bg_blue.SetGlobal(false); - Settings::values.bg_red.SetValue(static_cast(bg_color.redF())); - Settings::values.bg_green.SetValue(static_cast(bg_color.greenF())); - Settings::values.bg_blue.SetValue(static_cast(bg_color.blueF())); + Settings::values.bg_red.SetValue(static_cast(bg_color.red())); + Settings::values.bg_green.SetValue(static_cast(bg_color.green())); + Settings::values.bg_blue.SetValue(static_cast(bg_color.blue())); } } } diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index 173130d8d..d3ef5bd06 100755 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui @@ -2573,27 +2573,24 @@ - + Mouse sensitivity Qt::AlignCenter - - 2 + + % - 0.100000000000000 + 1 - 16.000000000000000 - - - 0.010000000000000 + 100 - 1.000000000000000 + 100 diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index d5d624b96..5b37b914b 100755 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -149,8 +149,9 @@ QString ButtonToText(const Common::ParamPackage& param) { if (param.Has("button")) { const QString button_str = QString::fromStdString(param.Get("button", "")); + const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : ""); - return QObject::tr("Button %1").arg(button_str); + return QObject::tr("%1Button %2").arg(toggle, button_str); } if (param.Has("motion")) { @@ -313,6 +314,16 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i 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( + buttons_param[button_id].Get("threshold", 0.5f) * 100.0f); + const int new_threshold = QInputDialog::getInt( + this, tr("Set threshold"), tr("Choose a value between 0% and 100%"), + button_threshold, 0, 100); + buttons_param[button_id].Set("threshold", new_threshold / 100.0f); + }); + } context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); }); diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 8079f8100..5fb800cce 100755 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -241,18 +241,16 @@ static const std::array keyboard_mods{ SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI, }; -template <> -void Config::ReadSetting(const std::string& group, Settings::BasicSetting& setting) { - setting = sdl2_config->GetReal(group, setting.GetLabel(), setting.GetDefault()); -} template <> void Config::ReadSetting(const std::string& group, Settings::BasicSetting& setting) { setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault()); } + template <> void Config::ReadSetting(const std::string& group, Settings::BasicSetting& setting) { setting = sdl2_config->GetBoolean(group, setting.GetLabel(), setting.GetDefault()); } + template void Config::ReadSetting(const std::string& group, Settings::BasicSetting& setting) { setting = static_cast(sdl2_config->GetInteger(group, setting.GetLabel(), diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 76d983247..a654fbdd9 100755 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -241,7 +241,7 @@ use_vsync = use_caches_gc = # The clear color for the renderer. What shows up on the sides of the bottom screen. -# Must be in range of 0.0-1.0. Defaults to 1.0 for all. +# Must be in range of 0-255. Defaults to 0 for all. bg_red = bg_blue = bg_green = @@ -290,7 +290,7 @@ enable_audio_stretching = output_device = # Output volume. -# 1.0 (default): 100%, 0.0; mute +# 100 (default): 100%, 0; mute volume = [Data Storage]