From ce7fdf3dce44860e79a24172d6bfb86e1c63e622 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 17 Jul 2021 23:35:12 +0200 Subject: [PATCH] early-access version 1885 --- README.md | 2 +- src/common/settings.h | 2 +- .../service/am/applets/applet_controller.cpp | 21 ++++++++- .../service/am/applets/applet_controller.h | 13 +++++- src/input_common/mouse/mouse_poller.cpp | 2 +- .../backend/glsl/emit_glsl_floating_point.cpp | 10 ++--- .../spirv/emit_spirv_context_get_set.cpp | 2 +- src/video_core/renderer_opengl/gl_device.cpp | 23 ++++------ .../renderer_opengl/renderer_opengl.cpp | 2 +- src/yuzu/bootmanager.cpp | 15 +++++-- .../configuration/configure_input_player.cpp | 34 ++++++++++++++ .../configuration/configure_input_player.ui | 44 +++++++++++++++++++ 12 files changed, 139 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 3d5a1e1c3..45cb9c52c 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1884. +This is the source code for early-access 1885. ## Legal Notice diff --git a/src/common/settings.h b/src/common/settings.h index c5ba3d337..32dfb1d9f 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -377,7 +377,7 @@ struct Values { "udp_input_servers"}; BasicSetting mouse_panning{false, "mouse_panning"}; - BasicSetting mouse_panning_sensitivity{1, "mouse_panning_sensitivity"}; + BasicSetting mouse_panning_sensitivity{10, "mouse_panning_sensitivity"}; BasicSetting mouse_enabled{false, "mouse_enabled"}; std::string mouse_device; MouseButtonsRaw mouse_buttons; diff --git a/src/core/hle/service/am/applets/applet_controller.cpp b/src/core/hle/service/am/applets/applet_controller.cpp index 12682effe..2721679c1 100755 --- a/src/core/hle/service/am/applets/applet_controller.cpp +++ b/src/core/hle/service/am/applets/applet_controller.cpp @@ -87,6 +87,10 @@ void Controller::Initialize() { case sizeof(ControllerUpdateFirmwareArg): controller_private_arg.mode = ControllerSupportMode::ShowControllerFirmwareUpdate; break; + case sizeof(ControllerKeyRemappingArg): + controller_private_arg.mode = + ControllerSupportMode::ShowControllerKeyRemappingForSystem; + break; default: UNIMPLEMENTED_MSG("Unknown ControllerPrivateArg mode={} with arg_size={}", controller_private_arg.mode, controller_private_arg.arg_size); @@ -99,7 +103,9 @@ void Controller::Initialize() { // This is always 0 (Application) except with ShowControllerFirmwareUpdateForSystem. if (controller_private_arg.caller >= ControllerSupportCaller::MaxControllerSupportCaller) { if (controller_private_arg.flag_1 && - controller_private_arg.mode == ControllerSupportMode::ShowControllerFirmwareUpdate) { + (controller_private_arg.mode == ControllerSupportMode::ShowControllerFirmwareUpdate || + controller_private_arg.mode == + ControllerSupportMode::ShowControllerKeyRemappingForSystem)) { controller_private_arg.caller = ControllerSupportCaller::System; } else { controller_private_arg.caller = ControllerSupportCaller::Application; @@ -121,6 +127,7 @@ void Controller::Initialize() { std::memcpy(&controller_user_arg_old, user_arg.data(), user_arg.size()); break; case ControllerAppletVersion::Version7: + case ControllerAppletVersion::Version8: ASSERT(user_arg.size() == sizeof(ControllerSupportArgNew)); std::memcpy(&controller_user_arg_new, user_arg.data(), user_arg.size()); break; @@ -143,6 +150,16 @@ void Controller::Initialize() { std::memcpy(&controller_update_arg, update_arg.data(), update_arg.size()); break; } + case ControllerSupportMode::ShowControllerKeyRemappingForSystem: { + const auto remapping_arg_storage = broker.PopNormalDataToApplet(); + ASSERT(remapping_arg_storage != nullptr); + + const auto& remapping_arg = remapping_arg_storage->GetData(); + ASSERT(remapping_arg.size() == sizeof(ControllerKeyRemappingArg)); + + std::memcpy(&controller_key_remapping_arg, remapping_arg.data(), remapping_arg.size()); + break; + } default: { UNIMPLEMENTED_MSG("Unimplemented ControllerSupportMode={}", controller_private_arg.mode); break; @@ -179,6 +196,7 @@ void Controller::Execute() { std::vector(controller_user_arg_old.explain_text.begin(), controller_user_arg_old.explain_text.end())); case ControllerAppletVersion::Version7: + case ControllerAppletVersion::Version8: default: return ConvertToFrontendParameters( controller_private_arg, controller_user_arg_new.header, @@ -210,6 +228,7 @@ void Controller::Execute() { } case ControllerSupportMode::ShowControllerStrapGuide: case ControllerSupportMode::ShowControllerFirmwareUpdate: + case ControllerSupportMode::ShowControllerKeyRemappingForSystem: UNIMPLEMENTED_MSG("ControllerSupportMode={} is not implemented", controller_private_arg.mode); ConfigurationComplete(); diff --git a/src/core/hle/service/am/applets/applet_controller.h b/src/core/hle/service/am/applets/applet_controller.h index 20617e91f..9706dee26 100755 --- a/src/core/hle/service/am/applets/applet_controller.h +++ b/src/core/hle/service/am/applets/applet_controller.h @@ -25,13 +25,15 @@ enum class ControllerAppletVersion : u32_le { Version3 = 0x3, // 1.0.0 - 2.3.0 Version4 = 0x4, // 3.0.0 - 5.1.0 Version5 = 0x5, // 6.0.0 - 7.0.1 - Version7 = 0x7, // 8.0.0+ + Version7 = 0x7, // 8.0.0 - 10.2.0 + Version8 = 0x8, // 11.0.0+ }; enum class ControllerSupportMode : u8 { ShowControllerSupport, ShowControllerStrapGuide, ShowControllerFirmwareUpdate, + ShowControllerKeyRemappingForSystem, MaxControllerSupportMode, }; @@ -95,6 +97,14 @@ struct ControllerUpdateFirmwareArg { static_assert(sizeof(ControllerUpdateFirmwareArg) == 0x4, "ControllerUpdateFirmwareArg has incorrect size."); +struct ControllerKeyRemappingArg { + u64 unknown{}; + u32 unknown_2{}; + INSERT_PADDING_WORDS(1); +}; +static_assert(sizeof(ControllerKeyRemappingArg) == 0x10, + "ControllerKeyRemappingArg has incorrect size."); + struct ControllerSupportResultInfo { s8 player_count{}; INSERT_PADDING_BYTES(3); @@ -128,6 +138,7 @@ private: ControllerSupportArgOld controller_user_arg_old; ControllerSupportArgNew controller_user_arg_new; ControllerUpdateFirmwareArg controller_update_arg; + ControllerKeyRemappingArg controller_key_remapping_arg; bool complete{false}; ResultCode status{ResultSuccess}; bool is_single_mode{false}; diff --git a/src/input_common/mouse/mouse_poller.cpp b/src/input_common/mouse/mouse_poller.cpp index 1e84eaddd..efcdd85d2 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() * 0.15f; + const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.10f; return axis_value * sensitivity / (100.0f * range); } diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp index 2edcf592e..d423bfb1b 100755 --- a/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_floating_point.cpp @@ -13,12 +13,10 @@ namespace Shader::Backend::GLSL { namespace { void Compare(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs, std::string_view op, bool ordered) { - ctx.AddU1("{}={}{}{}", inst, lhs, op, rhs, lhs, rhs); - if (ordered) { - ctx.Add("&&!isnan({})&&!isnan({});", lhs, rhs); - } else { - ctx.Add("||isnan({})||isnan({});", lhs, rhs); - } + const auto nan_op{ordered ? "&&!" : "||"}; + ctx.AddU1("{}={}{}{}" + "{}isnan({}){}isnan({});", + inst, lhs, op, rhs, nan_op, lhs, nan_op, rhs); } bool IsPrecise(const IR::Inst& inst) { diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 756de0a27..fb8c02a77 100755 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -300,7 +300,7 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { const std::optional type{AttrTypes(ctx, index)}; if (!type) { // Attribute is disabled - return ctx.Const(0.0f); + return ctx.Const(element == 3 ? 1.0f : 0.0f); } if (!ctx.runtime_info.previous_stage_stores.Generic(index, element)) { // Varying component is not written diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp index 563b291cd..6afe6c1e1 100755 --- a/src/video_core/renderer_opengl/gl_device.cpp +++ b/src/video_core/renderer_opengl/gl_device.cpp @@ -172,16 +172,14 @@ Device::Device() { // uniform buffers as "push constants" has_fast_buffer_sub_data = is_nvidia && !disable_fast_buffer_sub_data; - use_assembly_shaders = - Settings::values.shader_backend.GetValue() == Settings::ShaderBackend::GLASM && - GLAD_GL_NV_gpu_program5 && GLAD_GL_NV_compute_program5 && GLAD_GL_NV_transform_feedback && - GLAD_GL_NV_transform_feedback2; - - shader_backend = (Settings::values.shader_backend.GetValue() == - Settings::ShaderBackend::GLASM) == use_assembly_shaders - ? Settings::values.shader_backend.GetValue() - : Settings::ShaderBackend::GLSL; - + shader_backend = Settings::values.shader_backend.GetValue(); + use_assembly_shaders = shader_backend == Settings::ShaderBackend::GLASM && + GLAD_GL_NV_gpu_program5 && GLAD_GL_NV_compute_program5 && + GLAD_GL_NV_transform_feedback && GLAD_GL_NV_transform_feedback2; + if (shader_backend == Settings::ShaderBackend::GLASM && !use_assembly_shaders) { + LOG_ERROR(Render_OpenGL, "Assembly shaders enabled but not supported"); + shader_backend = Settings::ShaderBackend::GLSL; + } // Completely disable async shaders for now, as it causes graphical glitches use_asynchronous_shaders = false; // Blocks AMD and Intel OpenGL drivers on Windows from using asynchronous shader compilation. @@ -194,11 +192,6 @@ Device::Device() { LOG_INFO(Render_OpenGL, "Renderer_PreciseBug: {}", has_precise_bug); LOG_INFO(Render_OpenGL, "Renderer_BrokenTextureViewFormats: {}", has_broken_texture_view_formats); - - if (shader_backend == Settings::ShaderBackend::GLASM && !use_assembly_shaders) { - LOG_ERROR(Render_OpenGL, "Assembly shaders enabled but not supported"); - } - if (Settings::values.use_asynchronous_shaders.GetValue() && !use_asynchronous_shaders) { LOG_WARNING(Render_OpenGL, "Asynchronous shader compilation enabled but not supported"); } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 80a9c55fe..165319dee 100755 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -145,7 +145,7 @@ RendererOpenGL::RendererOpenGL(Core::TelemetrySession& telemetry_session_, GLint max_attribs{}; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_attribs); for (GLint attrib = 0; attrib < max_attribs; ++attrib) { - glVertexAttrib4f(attrib, 0.0f, 0.0f, 0.0f, 0.0f); + glVertexAttrib4f(attrib, 0.0f, 0.0f, 0.0f, 1.0f); } // Enable seamless cubemaps when per texture parameters are not available if (!GLAD_GL_ARB_seamless_cubemap_per_texture && !GLAD_GL_AMD_seamless_cubemap_per_texture) { diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 92e95510b..25b658b2a 100755 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -412,8 +412,9 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) { if (event->source() == Qt::MouseEventSynthesizedBySystem) { return; } - - auto pos = event->pos(); + // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse + // coordinates and map them to the current render area + const auto pos = mapFromGlobal(QCursor::pos()); const auto [x, y] = ScaleTouch(pos); const auto button = QtButtonToMouseButton(event->button()); input_subsystem->GetMouse()->PressButton(x, y, button); @@ -430,7 +431,9 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { if (event->source() == Qt::MouseEventSynthesizedBySystem) { return; } - auto pos = event->pos(); + // Qt sometimes returns the parent coordinates. To avoid this we read the global mouse + // coordinates and map them to the current render area + const auto pos = mapFromGlobal(QCursor::pos()); const auto [x, y] = ScaleTouch(pos); const int center_x = width() / 2; const int center_y = height() / 2; @@ -565,6 +568,12 @@ std::unique_ptr GRenderWindow::CreateSharedCont bool GRenderWindow::InitRenderTarget() { ReleaseRenderTarget(); + { + // Create a dummy render widget so that Qt + // places the render window at the correct position. + const RenderWidget dummy_widget{this}; + } + first_frame = false; switch (Settings::values.renderer_backend.GetValue()) { diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 5b37b914b..6b9bd05f1 100755 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -322,8 +322,16 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i 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); + + if (button_id == Settings::NativeButton::ZL) { + ui->sliderZLThreshold->setValue(new_threshold); + } + if (button_id == Settings::NativeButton::ZR) { + ui->sliderZRThreshold->setValue(new_threshold); + } }); } + context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); ui->controllerFrame->SetPlayerInput(player_index, buttons_param, analogs_param); }); @@ -352,6 +360,20 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i }); } + connect(ui->sliderZLThreshold, &QSlider::valueChanged, [=, this] { + if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) { + const auto slider_value = ui->sliderZLThreshold->value(); + buttons_param[Settings::NativeButton::ZL].Set("threshold", slider_value / 100.0f); + } + }); + + connect(ui->sliderZRThreshold, &QSlider::valueChanged, [=, this] { + if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) { + const auto slider_value = ui->sliderZRThreshold->value(); + buttons_param[Settings::NativeButton::ZR].Set("threshold", slider_value / 100.0f); + } + }); + for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) { for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) { auto* const analog_button = analog_map_buttons[analog_id][sub_button_id]; @@ -860,6 +882,18 @@ void ConfigureInputPlayer::UpdateUI() { button_map[button]->setText(ButtonToText(buttons_param[button])); } + if (buttons_param[Settings::NativeButton::ZL].Has("threshold")) { + const int button_threshold = static_cast( + buttons_param[Settings::NativeButton::ZL].Get("threshold", 0.5f) * 100.0f); + ui->sliderZLThreshold->setValue(button_threshold); + } + + if (buttons_param[Settings::NativeButton::ZR].Has("threshold")) { + const int button_threshold = static_cast( + buttons_param[Settings::NativeButton::ZR].Get("threshold", 0.5f) * 100.0f); + ui->sliderZRThreshold->setValue(button_threshold); + } + for (int motion_id = 0; motion_id < Settings::NativeMotion::NumMotions; ++motion_id) { motion_map[motion_id]->setText(ButtonToText(motions_param[motion_id])); } diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui index e76aa484f..e7433912b 100755 --- a/src/yuzu/configuration/configure_input_player.ui +++ b/src/yuzu/configuration/configure_input_player.ui @@ -1334,6 +1334,12 @@ + + + 0 + 0 + + ZL @@ -1378,6 +1384,22 @@ + + + + + 70 + 15 + + + + 100 + + + Qt::Horizontal + + + @@ -1759,6 +1781,12 @@ + + + 0 + 0 + + ZR @@ -1803,6 +1831,22 @@ + + + + + 70 + 15 + + + + 100 + + + Qt::Horizontal + + +