From e6199780a5ef9761541100cbe4efbadda78a5bd8 Mon Sep 17 00:00:00 2001 From: OpenSauce Date: Sun, 30 Mar 2025 14:59:46 +0100 Subject: [PATCH] android: Implement Expand to Display Cutout option (#597) * android: Implement Expand to Display Cutout option * Removed irrelevant comment * Moved Expand to Cutout Area setting to Layout section --------- Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> --- .../citra_emu/activities/EmulationActivity.kt | 15 +++++++++++---- .../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(+), 4 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..1ab511ad6 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 @@ -1,4 +1,4 @@ -// Copyright Citra Emulator Project / Lime3DS Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -192,9 +192,16 @@ 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 { + 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 25d32b1ee..26b97453e 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 293d33bd3..66a29b187 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 @@ -1038,6 +1038,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) IntSetting.ORIENTATION_OPTION.defaultValue ) ) + 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( SingleChoiceSetting( IntSetting.SCREEN_LAYOUT, diff --git a/src/android/app/src/main/jni/default_ini.h b/src/android/app/src/main/jni/default_ini.h index f57493960..bc7f8d894 100644 --- a/src/android/app/src/main/jni/default_ini.h +++ b/src/android/app/src/main/jni/default_ini.h @@ -256,6 +256,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 7febc210e..225995808 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -242,6 +242,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.