diff options
| author | 2024-02-13 10:06:30 -0500 | |
|---|---|---|
| committer | 2024-02-13 10:10:59 -0500 | |
| commit | 3c823254ff7cd215e5308e6964715257e9888bda (patch) | |
| tree | 63b5cccdff95a632972066f61627ab742e5399e1 /src/android | |
| parent | android: Expose FSR sharpness slider (diff) | |
| download | yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.gz yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.xz yuzu-3c823254ff7cd215e5308e6964715257e9888bda.zip | |
android: Add screen vertical alignment setting
It's a bit of a hack since I'm moving the view instead of telling the Vulkan surface to bias itself to the top/bottom/center but it works fine for now.
Diffstat (limited to 'src/android')
8 files changed, 90 insertions, 1 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt index 0712f60f5..0165cb2d1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt | |||
| @@ -25,6 +25,7 @@ enum class IntSetting(override val key: String) : AbstractIntSetting { | |||
| 25 | OVERLAY_SCALE("control_scale"), | 25 | OVERLAY_SCALE("control_scale"), |
| 26 | OVERLAY_OPACITY("control_opacity"), | 26 | OVERLAY_OPACITY("control_opacity"), |
| 27 | LOCK_DRAWER("lock_drawer"), | 27 | LOCK_DRAWER("lock_drawer"), |
| 28 | VERTICAL_ALIGNMENT("vertical_alignment"), | ||
| 28 | FSR_SHARPENING_SLIDER("fsr_sharpening_slider"); | 29 | FSR_SHARPENING_SLIDER("fsr_sharpening_slider"); |
| 29 | 30 | ||
| 30 | override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal) | 31 | override fun getInt(needsGlobal: Boolean): Int = NativeConfig.getInt(key, needsGlobal) |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index fee80bb21..862c6c483 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt | |||
| @@ -93,4 +93,15 @@ object Settings { | |||
| 93 | entries.firstOrNull { it.int == int } ?: Unspecified | 93 | entries.firstOrNull { it.int == int } ?: Unspecified |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | |||
| 97 | enum class EmulationVerticalAlignment(val int: Int) { | ||
| 98 | Top(1), | ||
| 99 | Center(0), | ||
| 100 | Bottom(2); | ||
| 101 | |||
| 102 | companion object { | ||
| 103 | fun from(int: Int): EmulationVerticalAlignment = | ||
| 104 | entries.firstOrNull { it.int == int } ?: Center | ||
| 105 | } | ||
| 106 | } | ||
| 96 | } | 107 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt index 3f8194658..21ca97bc1 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt | |||
| @@ -226,6 +226,15 @@ abstract class SettingsItem( | |||
| 226 | ) | 226 | ) |
| 227 | ) | 227 | ) |
| 228 | put( | 228 | put( |
| 229 | SingleChoiceSetting( | ||
| 230 | IntSetting.VERTICAL_ALIGNMENT, | ||
| 231 | R.string.vertical_alignment, | ||
| 232 | 0, | ||
| 233 | R.array.verticalAlignmentEntries, | ||
| 234 | R.array.verticalAlignmentValues | ||
| 235 | ) | ||
| 236 | ) | ||
| 237 | put( | ||
| 229 | SwitchSetting( | 238 | SwitchSetting( |
| 230 | BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE, | 239 | BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE, |
| 231 | R.string.use_disk_shader_cache, | 240 | R.string.use_disk_shader_cache, |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 19d3de6e2..db1a58147 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt | |||
| @@ -148,6 +148,7 @@ class SettingsFragmentPresenter( | |||
| 148 | add(IntSetting.MAX_ANISOTROPY.key) | 148 | add(IntSetting.MAX_ANISOTROPY.key) |
| 149 | add(IntSetting.RENDERER_SCREEN_LAYOUT.key) | 149 | add(IntSetting.RENDERER_SCREEN_LAYOUT.key) |
| 150 | add(IntSetting.RENDERER_ASPECT_RATIO.key) | 150 | add(IntSetting.RENDERER_ASPECT_RATIO.key) |
| 151 | add(IntSetting.VERTICAL_ALIGNMENT.key) | ||
| 151 | add(BooleanSetting.PICTURE_IN_PICTURE.key) | 152 | add(BooleanSetting.PICTURE_IN_PICTURE.key) |
| 152 | add(BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE.key) | 153 | add(BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE.key) |
| 153 | add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key) | 154 | add(BooleanSetting.RENDERER_FORCE_MAX_CLOCK.key) |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 44af896da..6b25cc525 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -15,7 +15,9 @@ import android.os.Handler | |||
| 15 | import android.os.Looper | 15 | import android.os.Looper |
| 16 | import android.os.PowerManager | 16 | import android.os.PowerManager |
| 17 | import android.os.SystemClock | 17 | import android.os.SystemClock |
| 18 | import android.util.Rational | ||
| 18 | import android.view.* | 19 | import android.view.* |
| 20 | import android.widget.FrameLayout | ||
| 19 | import android.widget.TextView | 21 | import android.widget.TextView |
| 20 | import android.widget.Toast | 22 | import android.widget.Toast |
| 21 | import androidx.activity.OnBackPressedCallback | 23 | import androidx.activity.OnBackPressedCallback |
| @@ -24,6 +26,7 @@ import androidx.core.content.res.ResourcesCompat | |||
| 24 | import androidx.core.graphics.Insets | 26 | import androidx.core.graphics.Insets |
| 25 | import androidx.core.view.ViewCompat | 27 | import androidx.core.view.ViewCompat |
| 26 | import androidx.core.view.WindowInsetsCompat | 28 | import androidx.core.view.WindowInsetsCompat |
| 29 | import androidx.core.view.updateLayoutParams | ||
| 27 | import androidx.core.view.updatePadding | 30 | import androidx.core.view.updatePadding |
| 28 | import androidx.drawerlayout.widget.DrawerLayout | 31 | import androidx.drawerlayout.widget.DrawerLayout |
| 29 | import androidx.drawerlayout.widget.DrawerLayout.DrawerListener | 32 | import androidx.drawerlayout.widget.DrawerLayout.DrawerListener |
| @@ -52,6 +55,7 @@ import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting | |||
| 52 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting | 55 | import org.yuzu.yuzu_emu.features.settings.model.IntSetting |
| 53 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 56 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 54 | import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationOrientation | 57 | import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationOrientation |
| 58 | import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationVerticalAlignment | ||
| 55 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile | 59 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile |
| 56 | import org.yuzu.yuzu_emu.model.DriverViewModel | 60 | import org.yuzu.yuzu_emu.model.DriverViewModel |
| 57 | import org.yuzu.yuzu_emu.model.Game | 61 | import org.yuzu.yuzu_emu.model.Game |
| @@ -617,7 +621,46 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 617 | } | 621 | } |
| 618 | 622 | ||
| 619 | private fun updateScreenLayout() { | 623 | private fun updateScreenLayout() { |
| 620 | binding.surfaceEmulation.setAspectRatio(null) | 624 | val verticalAlignment = |
| 625 | EmulationVerticalAlignment.from(IntSetting.VERTICAL_ALIGNMENT.getInt()) | ||
| 626 | val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.getInt()) { | ||
| 627 | 0 -> Rational(16, 9) | ||
| 628 | 1 -> Rational(4, 3) | ||
| 629 | 2 -> Rational(21, 9) | ||
| 630 | 3 -> Rational(16, 10) | ||
| 631 | else -> null // Best fit | ||
| 632 | } | ||
| 633 | when (verticalAlignment) { | ||
| 634 | EmulationVerticalAlignment.Top -> { | ||
| 635 | binding.surfaceEmulation.setAspectRatio(aspectRatio) | ||
| 636 | val params = FrameLayout.LayoutParams( | ||
| 637 | ViewGroup.LayoutParams.MATCH_PARENT, | ||
| 638 | ViewGroup.LayoutParams.WRAP_CONTENT | ||
| 639 | ) | ||
| 640 | params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL | ||
| 641 | binding.surfaceEmulation.layoutParams = params | ||
| 642 | } | ||
| 643 | |||
| 644 | EmulationVerticalAlignment.Center -> { | ||
| 645 | binding.surfaceEmulation.setAspectRatio(null) | ||
| 646 | binding.surfaceEmulation.updateLayoutParams { | ||
| 647 | width = ViewGroup.LayoutParams.MATCH_PARENT | ||
| 648 | height = ViewGroup.LayoutParams.MATCH_PARENT | ||
| 649 | } | ||
| 650 | } | ||
| 651 | |||
| 652 | EmulationVerticalAlignment.Bottom -> { | ||
| 653 | binding.surfaceEmulation.setAspectRatio(aspectRatio) | ||
| 654 | val params = | ||
| 655 | FrameLayout.LayoutParams( | ||
| 656 | ViewGroup.LayoutParams.MATCH_PARENT, | ||
| 657 | ViewGroup.LayoutParams.WRAP_CONTENT | ||
| 658 | ) | ||
| 659 | params.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL | ||
| 660 | binding.surfaceEmulation.layoutParams = params | ||
| 661 | } | ||
| 662 | } | ||
| 663 | emulationState.updateSurface() | ||
| 621 | emulationActivity?.buildPictureInPictureParams() | 664 | emulationActivity?.buildPictureInPictureParams() |
| 622 | updateOrientation() | 665 | updateOrientation() |
| 623 | } | 666 | } |
diff --git a/src/android/app/src/main/jni/android_settings.h b/src/android/app/src/main/jni/android_settings.h index 4a3bc8e53..00baf86a9 100644 --- a/src/android/app/src/main/jni/android_settings.h +++ b/src/android/app/src/main/jni/android_settings.h | |||
| @@ -38,6 +38,13 @@ struct Values { | |||
| 38 | Settings::Specialization::Default, | 38 | Settings::Specialization::Default, |
| 39 | true, | 39 | true, |
| 40 | true}; | 40 | true}; |
| 41 | Settings::Setting<s32> vertical_alignment{linkage, | ||
| 42 | 0, | ||
| 43 | "vertical_alignment", | ||
| 44 | Settings::Category::Android, | ||
| 45 | Settings::Specialization::Default, | ||
| 46 | true, | ||
| 47 | true}; | ||
| 41 | 48 | ||
| 42 | Settings::SwitchableSetting<std::string, false> driver_path{linkage, "", "driver_path", | 49 | Settings::SwitchableSetting<std::string, false> driver_path{linkage, "", "driver_path", |
| 43 | Settings::Category::GpuDriver}; | 50 | Settings::Category::GpuDriver}; |
diff --git a/src/android/app/src/main/res/values/arrays.xml b/src/android/app/src/main/res/values/arrays.xml index 4701913eb..1bd6455b4 100644 --- a/src/android/app/src/main/res/values/arrays.xml +++ b/src/android/app/src/main/res/values/arrays.xml | |||
| @@ -292,4 +292,15 @@ | |||
| 292 | <item>5</item> | 292 | <item>5</item> |
| 293 | </integer-array> | 293 | </integer-array> |
| 294 | 294 | ||
| 295 | <string-array name="verticalAlignmentEntries"> | ||
| 296 | <item>@string/top</item> | ||
| 297 | <item>@string/center</item> | ||
| 298 | <item>@string/bottom</item> | ||
| 299 | </string-array> | ||
| 300 | <integer-array name="verticalAlignmentValues"> | ||
| 301 | <item>1</item> | ||
| 302 | <item>0</item> | ||
| 303 | <item>2</item> | ||
| 304 | </integer-array> | ||
| 305 | |||
| 295 | </resources> | 306 | </resources> |
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index ee89fe4ee..78a4c958a 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -560,6 +560,12 @@ | |||
| 560 | <string name="mute">Mute</string> | 560 | <string name="mute">Mute</string> |
| 561 | <string name="unmute">Unmute</string> | 561 | <string name="unmute">Unmute</string> |
| 562 | 562 | ||
| 563 | <!-- Emulation vertical alignment --> | ||
| 564 | <string name="vertical_alignment">Vertical alignment</string> | ||
| 565 | <string name="top">Top</string> | ||
| 566 | <string name="center">Center</string> | ||
| 567 | <string name="bottom">Bottom</string> | ||
| 568 | |||
| 563 | <!-- Licenses screen strings --> | 569 | <!-- Licenses screen strings --> |
| 564 | <string name="licenses">Licenses</string> | 570 | <string name="licenses">Licenses</string> |
| 565 | <string name="license_fidelityfx_fsr" translatable="false">FidelityFX-FSR</string> | 571 | <string name="license_fidelityfx_fsr" translatable="false">FidelityFX-FSR</string> |