From 0cc974af92faa015598d614f6bec7d128d714774 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 24 Feb 2024 21:13:44 +0100 Subject: [PATCH] early-access version 4166 --- README.md | 2 +- .../set/setting_formats/system_settings.cpp | 4 ++ .../service/set/system_settings_server.cpp | 5 ++- src/input_common/drivers/android.cpp | 41 +++++++++++++------ src/input_common/drivers/android.h | 10 +++++ src/input_common/drivers/sdl_driver.h | 5 --- src/input_common/input_engine.h | 5 +++ .../renderer_vulkan/vk_rasterizer.cpp | 4 +- 8 files changed, 54 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 7c0cf163c..d097f9fe2 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4165. +This is the source code for early-access 4166. ## Legal Notice diff --git a/src/core/hle/service/set/setting_formats/system_settings.cpp b/src/core/hle/service/set/setting_formats/system_settings.cpp index 7231ff78e..caa30c2d5 100755 --- a/src/core/hle/service/set/setting_formats/system_settings.cpp +++ b/src/core/hle/service/set/setting_formats/system_settings.cpp @@ -52,6 +52,10 @@ SystemSettings DefaultSystemSettings() { settings.battery_percentage_flag = true; settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0; settings.vibration_master_volume = 1.0f; + settings.touch_screen_mode = TouchScreenMode::Standard; + settings.nfc_enable_flag = true; + settings.bluetooth_enable_flag = true; + settings.wireless_lan_enable_flag = true; const auto language_code = available_language_codes[static_cast(::Settings::values.language_index.GetValue())]; diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp index 45def67db..6a7ea83fd 100755 --- a/src/core/hle/service/set/system_settings_server.cpp +++ b/src/core/hle/service/set/system_settings_server.cpp @@ -26,7 +26,7 @@ namespace Service::Set { namespace { -constexpr u32 SETTINGS_VERSION{3u}; +constexpr u32 SETTINGS_VERSION{4u}; constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't'); struct SettingsHeader { u64 magic; @@ -307,6 +307,9 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_) SetupSettings(); + m_system_settings.region_code = + static_cast(Settings::values.region_index.GetValue()); + // TODO: Remove this when starter applet is fully functional EulaVersion eula_version{ .version = 0x10000, diff --git a/src/input_common/drivers/android.cpp b/src/input_common/drivers/android.cpp index e859cc538..d40fa66ae 100755 --- a/src/input_common/drivers/android.cpp +++ b/src/input_common/drivers/android.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "common/android/android_common.h" #include "common/android/id_cache.h" @@ -10,7 +11,18 @@ namespace InputCommon { -Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) {} +Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) { + vibration_thread = std::jthread([this](std::stop_token token) { + Common::SetCurrentThreadName("Android_Vibration"); + auto env = Common::Android::GetEnvForThread(); + using namespace std::chrono_literals; + while (!token.stop_requested()) { + SendVibrations(env, token); + } + }); +} + +Android::~Android() = default; void Android::RegisterController(jobject j_input_device) { auto env = Common::Android::GetEnvForThread(); @@ -57,17 +69,11 @@ void Android::SetMotionState(std::string guid, size_t port, u64 delta_timestamp, Common::Input::DriverResult Android::SetVibration( [[maybe_unused]] const PadIdentifier& identifier, [[maybe_unused]] const Common::Input::VibrationStatus& vibration) { - auto device = input_devices.find(identifier); - if (device != input_devices.end()) { - Common::Android::RunJNIOnFiber([&](JNIEnv* env) { - float average_intensity = - static_cast((vibration.high_amplitude + vibration.low_amplitude) / 2.0); - env->CallVoidMethod(device->second, Common::Android::GetYuzuDeviceVibrate(), - average_intensity); - }); - return Common::Input::DriverResult::Success; - } - return Common::Input::DriverResult::NotSupported; + vibration_queue.Push(VibrationRequest{ + .identifier = identifier, + .vibration = vibration, + }); + return Common::Input::DriverResult::Success; } bool Android::IsVibrationEnabled([[maybe_unused]] const PadIdentifier& identifier) { @@ -347,4 +353,15 @@ PadIdentifier Android::GetIdentifier(const std::string& guid, size_t port) const }; } +void Android::SendVibrations(JNIEnv* env, std::stop_token token) { + VibrationRequest request = vibration_queue.PopWait(token); + auto device = input_devices.find(request.identifier); + if (device != input_devices.end()) { + float average_intensity = static_cast( + (request.vibration.high_amplitude + request.vibration.low_amplitude) / 2.0); + env->CallVoidMethod(device->second, Common::Android::GetYuzuDeviceVibrate(), + average_intensity); + } +} + } // namespace InputCommon diff --git a/src/input_common/drivers/android.h b/src/input_common/drivers/android.h index 8a386c1b1..03e2b2c98 100755 --- a/src/input_common/drivers/android.h +++ b/src/input_common/drivers/android.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include "input_common/input_engine.h" @@ -16,6 +17,8 @@ class Android final : public InputEngine { public: explicit Android(std::string input_engine_); + ~Android() override; + /** * Registers controller number to accept new inputs. * @param j_input_device YuzuInputDevice object from the Android frontend to register. @@ -89,6 +92,9 @@ private: /// Returns the correct identifier corresponding to the player index PadIdentifier GetIdentifier(const std::string& guid, size_t port) const; + /// Takes all vibrations from the queue and sends the command to the controller + void SendVibrations(JNIEnv* env, std::stop_token token); + static constexpr s32 AXIS_X = 0; static constexpr s32 AXIS_Y = 1; static constexpr s32 AXIS_Z = 11; @@ -133,6 +139,10 @@ private: redmagic_vid, backbone_labs_vid, xbox_vid}; const std::vector flipped_xy_vids{sony_vid, razer_vid, redmagic_vid, backbone_labs_vid, xbox_vid}; + + /// Queue of vibration request to controllers + Common::SPSCQueue vibration_queue; + std::jthread vibration_thread; }; } // namespace InputCommon diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index d1cc8c34b..a77e42e74 100755 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h @@ -69,11 +69,6 @@ public: bool IsVibrationEnabled(const PadIdentifier& identifier) override; private: - struct VibrationRequest { - PadIdentifier identifier; - Common::Input::VibrationStatus vibration; - }; - void InitJoystick(int joystick_index); void CloseJoystick(SDL_Joystick* sdl_joystick); diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 706a675c0..7ac351010 100755 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h @@ -46,6 +46,11 @@ enum class EngineInputType { Nfc, }; +struct VibrationRequest { + PadIdentifier identifier; + Common::Input::VibrationStatus vibration; +}; + namespace std { // Hash used to create lists from PadIdentifier data template <> diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 90b91f0be..b11cf9acd 100755 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -125,11 +125,9 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3 return value < 0 ? std::min(converted_value - acumm, -1) : std::max(converted_value + acumm, 1); }; - const bool lower_left = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft; - const s32 y_adj = lower_left ? scale_up(regs.surface_clip.height - (src.max_y - src.min_y)) : 0; if (src.enable) { scissor.offset.x = scale_up(static_cast(src.min_x)); - scissor.offset.y = scale_up(static_cast(src.min_y)) + y_adj; + scissor.offset.y = scale_up(static_cast(src.min_y)); scissor.extent.width = scale_up(src.max_x - src.min_x); scissor.extent.height = scale_up(src.max_y - src.min_y); } else {