From 5413b47844742c079d37d85c9b240473800f5289 Mon Sep 17 00:00:00 2001 From: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Date: Tue, 30 Jul 2024 00:23:58 +0200 Subject: [PATCH] android: Implement Expand to Display Cutout option --- .../citra_emu/activities/EmulationActivity.kt | 14 +++++++++++--- .../features/settings/model/BooleanSetting.kt | 1 + .../settings/ui/SettingsFragmentPresenter.kt | 9 +++++++++ src/android/app/src/main/jni/default_ini.h | 4 ++++ src/android/app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/android/app/src/main/java/org/citra/citra_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/citra/citra_emu/activities/EmulationActivity.kt index 8d9bf24e3..4cdad060f 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/activities/EmulationActivity.kt @@ -192,9 +192,17 @@ class EmulationActivity : AppCompatActivity() { } private fun enableFullscreenImmersive() { - // TODO: Remove this once we properly account for display insets in the input overlay - window.attributes.layoutInDisplayCutoutMode = - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER + val attributes = window.attributes + + attributes.layoutInDisplayCutoutMode = + if (BooleanSetting.EXPAND_TO_CUTOUT_AREA.boolean) { + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + } else { + // TODO: Remove this once we properly account for display insets in the input overlay + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER + } + + window.attributes = attributes WindowCompat.setDecorFitsSystemWindows(window, false) diff --git a/src/android/app/src/main/java/org/citra/citra_emu/features/settings/model/BooleanSetting.kt b/src/android/app/src/main/java/org/citra/citra_emu/features/settings/model/BooleanSetting.kt index 4e5481d7c..33295729b 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/features/settings/model/BooleanSetting.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/features/settings/model/BooleanSetting.kt @@ -9,6 +9,7 @@ enum class BooleanSetting( override val section: String, override val defaultValue: Boolean ) : AbstractBooleanSetting { + EXPAND_TO_CUTOUT_AREA("expand_to_cutout_area", Settings.SECTION_LAYOUT, false), SPIRV_SHADER_GEN("spirv_shader_gen", Settings.SECTION_RENDERER, true), ASYNC_SHADERS("async_shader_compilation", Settings.SECTION_RENDERER, false), PLUGIN_LOADER("plugin_loader", Settings.SECTION_SYSTEM, false), diff --git a/src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsFragmentPresenter.kt index 31401567f..b25092d0e 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsFragmentPresenter.kt @@ -215,6 +215,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) private fun addGeneralSettings(sl: ArrayList) { settingsActivity.setToolbarTitle(settingsActivity.getString(R.string.preferences_general)) sl.apply { + add( + SwitchSetting( + BooleanSetting.EXPAND_TO_CUTOUT_AREA, + R.string.expand_to_cutout_area, + R.string.expand_to_cutout_area_description, + BooleanSetting.EXPAND_TO_CUTOUT_AREA.key, + BooleanSetting.EXPAND_TO_CUTOUT_AREA.defaultValue + ) + ) add( SwitchSetting( IntSetting.USE_FRAME_LIMIT, diff --git a/src/android/app/src/main/jni/default_ini.h b/src/android/app/src/main/jni/default_ini.h index 5c802856e..bd3658e54 100644 --- a/src/android/app/src/main/jni/default_ini.h +++ b/src/android/app/src/main/jni/default_ini.h @@ -251,6 +251,10 @@ custom_portrait_bottom_height = # 0 (default): Top Screen is prominent, 1: Bottom Screen is prominent swap_screen = +# Expands the display area to include the cutout (or notch) area +# 0 (default): Off, 1: On +expand_to_cutout_area = + # Screen placement settings when using Cardboard VR (render3d = 4) # 30 - 100: Screen size as a percentage of the viewport. 85 (default) cardboard_screen_size = diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 5495a2a23..54620b146 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -238,6 +238,8 @@ Enable asynchronous GPU emulation Uses a separate thread to emulate the GPU asynchronously. When enabled, performance will be improved. Limit Speed + Expand to Cutout Area + Expands the display area to include the cutout (or notch) area. When enabled, emulation speed will be limited to a specified percentage of normal speed. Limit Speed Percent Specifies the percentage to limit emulation speed. With the default of 100% emulation will be limited to normal speed. Values higher or lower will increase or decrease the speed limit.