From 70404689ef42506fafe57483ca089737a422fc14 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sun, 18 Feb 2024 20:28:12 +0100 Subject: [PATCH] early-access version 4148 --- README.md | 2 +- .../yuzu_emu/activities/EmulationActivity.kt | 10 ++++++++-- .../org/yuzu/yuzu_emu/ui/main/MainActivity.kt | 3 ++- .../src/main/jni/emu_window/emu_window.cpp | 16 ++++++++++++++++ .../app/src/main/jni/emu_window/emu_window.h | 4 ++++ src/android/app/src/main/jni/native_input.cpp | 8 +++----- src/core/file_sys/control_metadata.h | 4 ++-- .../am/service/application_functions.cpp | 19 ++++++++++++++++++- .../am/service/application_functions.h | 1 + .../hle/service/filesystem/fsp/fsp_srv.cpp | 9 ++++++++- src/core/hle/service/filesystem/fsp/fsp_srv.h | 1 + src/core/hle/service/ns/develop_interface.cpp | 2 -- src/core/hle/service/nvnflinger/display.h | 4 ++++ .../service/nvnflinger/surface_flinger.cpp | 7 ++++--- .../hle/service/nvnflinger/surface_flinger.h | 2 +- src/core/hle/service/vi/container.cpp | 5 +++-- src/core/hle/service/vi/container.h | 2 +- src/input_common/drivers/android.h | 7 ++++--- 18 files changed, 81 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d587ac6c8..fc7dcd41b 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4146. +This is the source code for early-access 4148. ## Legal Notice diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index 0b70fccec..c962558a7 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt @@ -80,8 +80,14 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { super.onCreate(savedInstanceState) InputHandler.updateControllerData() - val playerOne = NativeConfig.getInputSettings(true)[0] - if (!playerOne.hasMapping() && InputHandler.androidControllers.isNotEmpty()) { + val players = NativeConfig.getInputSettings(true) + var hasConfiguredControllers = false + players.forEach { + if (it.hasMapping()) { + hasConfiguredControllers = true + } + } + if (!hasConfiguredControllers && InputHandler.androidControllers.isNotEmpty()) { var params: ParamPackage? = null for (controller in InputHandler.registeredControllers) { if (controller.get("port", -1) == 0) { diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt index d16f8a931..757463a0b 100755 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainActivity.kt @@ -498,7 +498,8 @@ class MainActivity : AppCompatActivity(), ThemeProvider { this@MainActivity, titleId = R.string.content_install_notice, descriptionId = R.string.content_install_notice_description, - positiveAction = { homeViewModel.setContentToInstall(documents) } + positiveAction = { homeViewModel.setContentToInstall(documents) }, + negativeAction = {} ) } }.show(supportFragmentManager, ProgressDialogFragment.TAG) diff --git a/src/android/app/src/main/jni/emu_window/emu_window.cpp b/src/android/app/src/main/jni/emu_window/emu_window.cpp index 2768a01c9..06db55369 100755 --- a/src/android/app/src/main/jni/emu_window/emu_window.cpp +++ b/src/android/app/src/main/jni/emu_window/emu_window.cpp @@ -23,6 +23,22 @@ void EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) { window_info.render_surface = reinterpret_cast(surface); } +void EmuWindow_Android::OnTouchPressed(int id, float x, float y) { + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchPressed(touch_x, + touch_y, id); +} + +void EmuWindow_Android::OnTouchMoved(int id, float x, float y) { + const auto [touch_x, touch_y] = MapToTouchScreen(x, y); + EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchMoved(touch_x, + touch_y, id); +} + +void EmuWindow_Android::OnTouchReleased(int id) { + EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchReleased(id); +} + void EmuWindow_Android::OnFrameDisplayed() { if (!m_first_frame) { Common::Android::RunJNIOnFiber( diff --git a/src/android/app/src/main/jni/emu_window/emu_window.h b/src/android/app/src/main/jni/emu_window/emu_window.h index 34704ae95..d7b5fc6da 100755 --- a/src/android/app/src/main/jni/emu_window/emu_window.h +++ b/src/android/app/src/main/jni/emu_window/emu_window.h @@ -38,6 +38,10 @@ public: void OnSurfaceChanged(ANativeWindow* surface); void OnFrameDisplayed() override; + void OnTouchPressed(int id, float x, float y); + void OnTouchMoved(int id, float x, float y); + void OnTouchReleased(int id); + std::unique_ptr CreateSharedContext() const override { return {std::make_unique(m_driver_library)}; } diff --git a/src/android/app/src/main/jni/native_input.cpp b/src/android/app/src/main/jni/native_input.cpp index ddf2f297b..37a65f2b8 100755 --- a/src/android/app/src/main/jni/native_input.cpp +++ b/src/android/app/src/main/jni/native_input.cpp @@ -190,8 +190,7 @@ void Java_org_yuzu_yuzu_1emu_features_input_NativeInput_onTouchPressed(JNIEnv* e jint j_id, jfloat j_x_axis, jfloat j_y_axis) { if (EmulationSession::GetInstance().IsRunning()) { - EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchPressed( - j_id, j_x_axis, j_y_axis); + EmulationSession::GetInstance().Window().OnTouchPressed(j_id, j_x_axis, j_y_axis); } } @@ -199,15 +198,14 @@ void Java_org_yuzu_yuzu_1emu_features_input_NativeInput_onTouchMoved(JNIEnv* env jint j_id, jfloat j_x_axis, jfloat j_y_axis) { if (EmulationSession::GetInstance().IsRunning()) { - EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchMoved( - j_id, j_x_axis, j_y_axis); + EmulationSession::GetInstance().Window().OnTouchMoved(j_id, j_x_axis, j_y_axis); } } void Java_org_yuzu_yuzu_1emu_features_input_NativeInput_onTouchReleased(JNIEnv* env, jobject j_obj, jint j_id) { if (EmulationSession::GetInstance().IsRunning()) { - EmulationSession::GetInstance().GetInputSubsystem().GetTouchScreen()->TouchReleased(j_id); + EmulationSession::GetInstance().Window().OnTouchReleased(j_id); } } diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index c9e6adb42..c0462b513 100755 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h @@ -64,8 +64,8 @@ struct RawNACP { u64_le cache_storage_size; u64_le cache_storage_journal_size; u64_le cache_storage_data_and_journal_max_size; - u64_le cache_storage_max_index; - INSERT_PADDING_BYTES(0xE70); + u16_le cache_storage_max_index; + INSERT_PADDING_BYTES(0xE76); }; static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size."); diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index 07a7152fe..cb53b07e0 100755 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp @@ -15,6 +15,7 @@ #include "core/hle/service/cmif_serialization.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/save_data_controller.h" +#include "core/hle/service/glue/glue_manager.h" #include "core/hle/service/ns/application_manager_interface.h" #include "core/hle/service/ns/service_getter_interface.h" #include "core/hle/service/sm/sm.h" @@ -41,7 +42,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_ {26, D<&IApplicationFunctions::GetSaveDataSize>, "GetSaveDataSize"}, {27, D<&IApplicationFunctions::CreateCacheStorage>, "CreateCacheStorage"}, {28, D<&IApplicationFunctions::GetSaveDataSizeMax>, "GetSaveDataSizeMax"}, - {29, nullptr, "GetCacheStorageMax"}, + {29, D<&IApplicationFunctions::GetCacheStorageMax>, "GetCacheStorageMax"}, {30, D<&IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed>, "BeginBlockingHomeButtonShortAndLongPressed"}, {31, D<&IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed>, "EndBlockingHomeButtonShortAndLongPressed"}, {32, D<&IApplicationFunctions::BeginBlockingHomeButton>, "BeginBlockingHomeButton"}, @@ -270,6 +271,22 @@ Result IApplicationFunctions::GetSaveDataSizeMax(Out out_max_normal_size, R_SUCCEED(); } +Result IApplicationFunctions::GetCacheStorageMax(Out out_cache_storage_index_max, + Out out_max_journal_size) { + LOG_DEBUG(Service_AM, "called"); + + std::vector nacp; + R_TRY(system.GetARPManager().GetControlProperty(&nacp, m_applet->program_id)); + + auto raw_nacp = std::make_unique(); + std::memcpy(raw_nacp.get(), nacp.data(), std::min(sizeof(*raw_nacp), nacp.size())); + + *out_cache_storage_index_max = static_cast(raw_nacp->cache_storage_max_index); + *out_max_journal_size = static_cast(raw_nacp->cache_storage_data_and_journal_max_size); + + R_SUCCEED(); +} + Result IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(s64 unused) { LOG_WARNING(Service_AM, "(STUBBED) called"); diff --git a/src/core/hle/service/am/service/application_functions.h b/src/core/hle/service/am/service/application_functions.h index 3548202f8..10025a152 100755 --- a/src/core/hle/service/am/service/application_functions.h +++ b/src/core/hle/service/am/service/application_functions.h @@ -40,6 +40,7 @@ private: Result CreateCacheStorage(Out out_target_media, Out out_required_size, u16 index, u64 normal_size, u64 journal_size); Result GetSaveDataSizeMax(Out out_max_normal_size, Out out_max_journal_size); + Result GetCacheStorageMax(Out out_cache_storage_index_max, Out out_max_journal_size); Result BeginBlockingHomeButtonShortAndLongPressed(s64 unused); Result EndBlockingHomeButtonShortAndLongPressed(); Result BeginBlockingHomeButton(s64 timeout_ns); diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp index 63c2d3a58..2d49f30c8 100755 --- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp @@ -336,7 +336,7 @@ FSP_SRV::FSP_SRV(Core::System& system_) {1012, nullptr, "GetFsStackUsage"}, {1013, nullptr, "UnsetSaveDataRootPath"}, {1014, nullptr, "OutputMultiProgramTagAccessLog"}, - {1016, nullptr, "FlushAccessLogOnSdCard"}, + {1016, &FSP_SRV::FlushAccessLogOnSdCard, "FlushAccessLogOnSdCard"}, {1017, nullptr, "OutputApplicationInfoAccessLog"}, {1018, nullptr, "SetDebugOption"}, {1019, nullptr, "UnsetDebugOption"}, @@ -706,6 +706,13 @@ void FSP_SRV::GetProgramIndexForAccessLog(HLERequestContext& ctx) { rb.Push(access_log_program_index); } +void FSP_SRV::FlushAccessLogOnSdCard(HLERequestContext& ctx) { + LOG_DEBUG(Service_FS, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void FSP_SRV::GetCacheStorageSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto index{rp.Pop()}; diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.h b/src/core/hle/service/filesystem/fsp/fsp_srv.h index 26980af99..59406e6f9 100755 --- a/src/core/hle/service/filesystem/fsp/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp/fsp_srv.h @@ -58,6 +58,7 @@ private: void SetGlobalAccessLogMode(HLERequestContext& ctx); void GetGlobalAccessLogMode(HLERequestContext& ctx); void OutputAccessLogToSdCard(HLERequestContext& ctx); + void FlushAccessLogOnSdCard(HLERequestContext& ctx); void GetProgramIndexForAccessLog(HLERequestContext& ctx); void OpenMultiCommitManager(HLERequestContext& ctx); void GetCacheStorageSize(HLERequestContext& ctx); diff --git a/src/core/hle/service/ns/develop_interface.cpp b/src/core/hle/service/ns/develop_interface.cpp index 221cd74ac..880bdbebb 100755 --- a/src/core/hle/service/ns/develop_interface.cpp +++ b/src/core/hle/service/ns/develop_interface.cpp @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#pragma once - #include "core/hle/service/ns/develop_interface.h" namespace Service::NS { diff --git a/src/core/hle/service/nvnflinger/display.h b/src/core/hle/service/nvnflinger/display.h index 8a1956fe0..f27cbf144 100755 --- a/src/core/hle/service/nvnflinger/display.h +++ b/src/core/hle/service/nvnflinger/display.h @@ -44,6 +44,10 @@ struct Display { return nullptr; } + bool HasLayers() { + return !stack.layers.empty(); + } + u64 id; LayerStack stack; }; diff --git a/src/core/hle/service/nvnflinger/surface_flinger.cpp b/src/core/hle/service/nvnflinger/surface_flinger.cpp index 0e9714a03..41a705717 100755 --- a/src/core/hle/service/nvnflinger/surface_flinger.cpp +++ b/src/core/hle/service/nvnflinger/surface_flinger.cpp @@ -33,16 +33,17 @@ void SurfaceFlinger::RemoveDisplay(u64 display_id) { std::erase_if(m_displays, [&](auto& display) { return display.id == display_id; }); } -void SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, +bool SurfaceFlinger::ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id) { auto* const display = this->FindDisplay(display_id); - if (!display) { - return; + if (!display || !display->HasLayers()) { + return false; } *out_swap_interval = m_composer.ComposeLocked(out_compose_speed_scale, *display, *nvdrv->GetDevice(disp_fd)); + return true; } void SurfaceFlinger::AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id) { diff --git a/src/core/hle/service/nvnflinger/surface_flinger.h b/src/core/hle/service/nvnflinger/surface_flinger.h index a2e661430..d8c53fbda 100755 --- a/src/core/hle/service/nvnflinger/surface_flinger.h +++ b/src/core/hle/service/nvnflinger/surface_flinger.h @@ -34,7 +34,7 @@ public: void AddDisplay(u64 display_id); void RemoveDisplay(u64 display_id); - void ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); + bool ComposeDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); void AddLayerToDisplayStack(u64 display_id, s32 consumer_binder_id); void RemoveLayerFromDisplayStack(u64 display_id, s32 consumer_binder_id); diff --git a/src/core/hle/service/vi/container.cpp b/src/core/hle/service/vi/container.cpp index 2d6b9cbfe..310a207f1 100755 --- a/src/core/hle/service/vi/container.cpp +++ b/src/core/hle/service/vi/container.cpp @@ -218,10 +218,11 @@ void Container::DestroyBufferQueueLocked(Layer* layer) { layer->GetProducerBinderId()); } -void Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, +bool Container::ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id) { std::scoped_lock lk{m_lock}; - m_surface_flinger->ComposeDisplay(out_swap_interval, out_compose_speed_scale, display_id); + return m_surface_flinger->ComposeDisplay(out_swap_interval, out_compose_speed_scale, + display_id); } } // namespace Service::VI diff --git a/src/core/hle/service/vi/container.h b/src/core/hle/service/vi/container.h index 155c4c629..cd0d2ca86 100755 --- a/src/core/hle/service/vi/container.h +++ b/src/core/hle/service/vi/container.h @@ -76,7 +76,7 @@ private: void DestroyBufferQueueLocked(Layer* layer); public: - void ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); + bool ComposeOnDisplay(s32* out_swap_interval, f32* out_compose_speed_scale, u64 display_id); private: std::mutex m_lock{}; diff --git a/src/input_common/drivers/android.h b/src/input_common/drivers/android.h index ac60e3598..8a386c1b1 100755 --- a/src/input_common/drivers/android.h +++ b/src/input_common/drivers/android.h @@ -128,10 +128,11 @@ private: const std::string razer_vid{"1532"}; const std::string redmagic_vid{"3537"}; const std::string backbone_labs_vid{"358a"}; - const std::vector flipped_ab_vids{sony_vid, nintendo_vid, razer_vid, redmagic_vid, - backbone_labs_vid}; + const std::string xbox_vid{"045e"}; + const std::vector flipped_ab_vids{sony_vid, nintendo_vid, razer_vid, + redmagic_vid, backbone_labs_vid, xbox_vid}; const std::vector flipped_xy_vids{sony_vid, razer_vid, redmagic_vid, - backbone_labs_vid}; + backbone_labs_vid, xbox_vid}; }; } // namespace InputCommon