summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authort895 <clombardo169@gmail.com>2024-02-13 16:06:30 +0100
committert895 <clombardo169@gmail.com>2024-02-13 16:10:59 +0100
commit3c823254ff7cd215e5308e6964715257e9888bda (patch)
tree63b5cccdff95a632972066f61627ab742e5399e1 /src
parentandroid: Expose FSR sharpness slider (diff)
downloadyuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar
yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.gz
yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.bz2
yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.lz
yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.xz
yuzu-3c823254ff7cd215e5308e6964715257e9888bda.tar.zst
yuzu-3c823254ff7cd215e5308e6964715257e9888bda.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/IntSetting.kt1
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt11
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SettingsItem.kt9
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt1
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt45
-rw-r--r--src/android/app/src/main/jni/android_settings.h7
-rw-r--r--src/android/app/src/main/res/values/arrays.xml11
-rw-r--r--src/android/app/src/main/res/values/strings.xml6
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 {
OVERLAY_SCALE("control_scale"),
OVERLAY_OPACITY("control_opacity"),
LOCK_DRAWER("lock_drawer"),
+ VERTICAL_ALIGNMENT("vertical_alignment"),
FSR_SHARPENING_SLIDER("fsr_sharpening_slider");
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 {
entries.firstOrNull { it.int == int } ?: Unspecified
}
}
+
+ enum class EmulationVerticalAlignment(val int: Int) {
+ Top(1),
+ Center(0),
+ Bottom(2);
+
+ companion object {
+ fun from(int: Int): EmulationVerticalAlignment =
+ entries.firstOrNull { it.int == int } ?: Center
+ }
+ }
}
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(
)
)
put(
+ SingleChoiceSetting(
+ IntSetting.VERTICAL_ALIGNMENT,
+ R.string.vertical_alignment,
+ 0,
+ R.array.verticalAlignmentEntries,
+ R.array.verticalAlignmentValues
+ )
+ )
+ put(
SwitchSetting(
BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE,
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(
add(IntSetting.MAX_ANISOTROPY.key)
add(IntSetting.RENDERER_SCREEN_LAYOUT.key)
add(IntSetting.RENDERER_ASPECT_RATIO.key)
+ add(IntSetting.VERTICAL_ALIGNMENT.key)
add(BooleanSetting.PICTURE_IN_PICTURE.key)
add(BooleanSetting.RENDERER_USE_DISK_SHADER_CACHE.key)
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
import android.os.Looper
import android.os.PowerManager
import android.os.SystemClock
+import android.util.Rational
import android.view.*
+import android.widget.FrameLayout
import android.widget.TextView
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
@@ -24,6 +26,7 @@ import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.Insets
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
+import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.drawerlayout.widget.DrawerLayout
import androidx.drawerlayout.widget.DrawerLayout.DrawerListener
@@ -52,6 +55,7 @@ import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
import org.yuzu.yuzu_emu.features.settings.model.IntSetting
import org.yuzu.yuzu_emu.features.settings.model.Settings
import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationOrientation
+import org.yuzu.yuzu_emu.features.settings.model.Settings.EmulationVerticalAlignment
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
import org.yuzu.yuzu_emu.model.DriverViewModel
import org.yuzu.yuzu_emu.model.Game
@@ -617,7 +621,46 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}
private fun updateScreenLayout() {
- binding.surfaceEmulation.setAspectRatio(null)
+ val verticalAlignment =
+ EmulationVerticalAlignment.from(IntSetting.VERTICAL_ALIGNMENT.getInt())
+ val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.getInt()) {
+ 0 -> Rational(16, 9)
+ 1 -> Rational(4, 3)
+ 2 -> Rational(21, 9)
+ 3 -> Rational(16, 10)
+ else -> null // Best fit
+ }
+ when (verticalAlignment) {
+ EmulationVerticalAlignment.Top -> {
+ binding.surfaceEmulation.setAspectRatio(aspectRatio)
+ val params = FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ params.gravity = Gravity.TOP or Gravity.CENTER_HORIZONTAL
+ binding.surfaceEmulation.layoutParams = params
+ }
+
+ EmulationVerticalAlignment.Center -> {
+ binding.surfaceEmulation.setAspectRatio(null)
+ binding.surfaceEmulation.updateLayoutParams {
+ width = ViewGroup.LayoutParams.MATCH_PARENT
+ height = ViewGroup.LayoutParams.MATCH_PARENT
+ }
+ }
+
+ EmulationVerticalAlignment.Bottom -> {
+ binding.surfaceEmulation.setAspectRatio(aspectRatio)
+ val params =
+ FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
+ params.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL
+ binding.surfaceEmulation.layoutParams = params
+ }
+ }
+ emulationState.updateSurface()
emulationActivity?.buildPictureInPictureParams()
updateOrientation()
}
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 {
Settings::Specialization::Default,
true,
true};
+ Settings::Setting<s32> vertical_alignment{linkage,
+ 0,
+ "vertical_alignment",
+ Settings::Category::Android,
+ Settings::Specialization::Default,
+ true,
+ true};
Settings::SwitchableSetting<std::string, false> driver_path{linkage, "", "driver_path",
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 @@
<item>5</item>
</integer-array>
+ <string-array name="verticalAlignmentEntries">
+ <item>@string/top</item>
+ <item>@string/center</item>
+ <item>@string/bottom</item>
+ </string-array>
+ <integer-array name="verticalAlignmentValues">
+ <item>1</item>
+ <item>0</item>
+ <item>2</item>
+ </integer-array>
+
</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 @@
<string name="mute">Mute</string>
<string name="unmute">Unmute</string>
+ <!-- Emulation vertical alignment -->
+ <string name="vertical_alignment">Vertical alignment</string>
+ <string name="top">Top</string>
+ <string name="center">Center</string>
+ <string name="bottom">Bottom</string>
+
<!-- Licenses screen strings -->
<string name="licenses">Licenses</string>
<string name="license_fidelityfx_fsr" translatable="false">FidelityFX-FSR</string>