From 6cc21a56d96ce2ace61369dbff77ebbe682b2b05 Mon Sep 17 00:00:00 2001 From: bunnei Date: Mon, 23 Jan 2023 16:44:05 -0800 Subject: [PATCH] android: Frontend: Fix rendering aspect ratio & add a setting for it. --- .../settings/ui/SettingsFragmentPresenter.java | 2 ++ .../features/settings/utils/SettingsFile.java | 1 + src/android/app/src/main/jni/default_ini.h | 2 +- .../app/src/main/jni/emu_window/emu_window.cpp | 3 +++ src/android/app/src/main/res/values/arrays.xml | 16 ++++++++++++++++ src/android/app/src/main/res/values/strings.xml | 1 + src/yuzu_cmd/default_ini.h | 2 +- 7 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java index c84467c162..b6176e5044 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.java @@ -159,11 +159,13 @@ public final class SettingsFragmentPresenter { Setting rendererBackend = rendererSection.getSetting(SettingsFile.KEY_RENDERER_BACKEND); Setting rendererAccuracy = rendererSection.getSetting(SettingsFile.KEY_RENDERER_ACCURACY); Setting rendererReolution = rendererSection.getSetting(SettingsFile.KEY_RENDERER_RESOLUTION); + Setting rendererAspectRation = rendererSection.getSetting(SettingsFile.KEY_RENDERER_ASPECT_RATIO); Setting rendererAsynchronousShaders = rendererSection.getSetting(SettingsFile.KEY_RENDERER_ASYNCHRONOUS_SHADERS); sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_BACKEND, Settings.SECTION_RENDERER, R.string.renderer_api, 0, R.array.rendererApiNames, R.array.rendererApiValues, 0, rendererBackend)); sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_ACCURACY, Settings.SECTION_RENDERER, R.string.renderer_accuracy, 0, R.array.rendererAccuracyNames, R.array.rendererAccuracyValues, 1, rendererAccuracy)); sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_RESOLUTION, Settings.SECTION_RENDERER, R.string.renderer_resolution, 0, R.array.rendererResolutionNames, R.array.rendererResolutionValues, 2, rendererReolution)); + sl.add(new SingleChoiceSetting(SettingsFile.KEY_RENDERER_ASPECT_RATIO, Settings.SECTION_RENDERER, R.string.renderer_aspect_ratio, 0, R.array.rendererAspectRatioNames, R.array.rendererAspectRatioValues, 0, rendererAspectRation)); sl.add(new CheckBoxSetting(SettingsFile.KEY_RENDERER_ASYNCHRONOUS_SHADERS, Settings.SECTION_RENDERER, R.string.renderer_asynchronous_shaders, R.string.renderer_asynchronous_shaders_description, false, rendererAsynchronousShaders)); } diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java index 6526f91396..392c2e62d8 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/utils/SettingsFile.java @@ -44,6 +44,7 @@ public final class SettingsFile { public static final String KEY_RENDERER_BACKEND = "backend"; // Renderer public static final String KEY_RENDERER_RESOLUTION = "resolution_setup"; + public static final String KEY_RENDERER_ASPECT_RATIO = "aspect_ratio"; public static final String KEY_RENDERER_ACCURACY = "gpu_accuracy"; public static final String KEY_RENDERER_ASYNCHRONOUS_SHADERS = "use_asynchronous_shaders"; public static final String KEY_RENDERER_USE_SPEED_LIMIT = "use_speed_limit"; diff --git a/src/android/app/src/main/jni/default_ini.h b/src/android/app/src/main/jni/default_ini.h index 60db951c80..eecda4756b 100644 --- a/src/android/app/src/main/jni/default_ini.h +++ b/src/android/app/src/main/jni/default_ini.h @@ -294,7 +294,7 @@ anti_aliasing = fullscreen_mode = # Aspect ratio -# 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window +# 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Force 16:10, 4: Stretch to Window aspect_ratio = # Anisotropic filtering 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 9062c0ae39..cef2960370 100644 --- a/src/android/app/src/main/jni/emu_window/emu_window.cpp +++ b/src/android/app/src/main/jni/emu_window/emu_window.cpp @@ -46,6 +46,9 @@ EmuWindow_Android::EmuWindow_Android(InputCommon::InputSubsystem* input_subsyste window_width = ANativeWindow_getWidth(surface_); window_height = ANativeWindow_getHeight(surface_); + // Ensures that we emulate with the correct aspect ratio. + UpdateCurrentFramebufferLayout(window_width, window_height); + host_window = surface_; window_info.type = Core::Frontend::WindowSystemType::Android; window_info.render_surface = reinterpret_cast(host_window); diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index bf9922be8f..53c4765b1a 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml @@ -140,6 +140,22 @@ 5 + + Default (16:9) + Force 4:3 + Force 21:9 + Force 16:10 + Stretch to Window + + + + 0 + 1 + 2 + 3 + 4 + + Auto Accurate diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 239fde48d4..cc84f700e6 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -28,6 +28,7 @@ API Accuracy level Resolution + Aspect Ratio Use asynchronous shaders Compiles shaders asynchronously, which will reduce stutter but may introduce glitches. diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 644a30e597..911d461e40 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -318,7 +318,7 @@ anti_aliasing = fullscreen_mode = # Aspect ratio -# 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window +# 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Force 16:10, 4: Stretch to Window aspect_ratio = # Anisotropic filtering