summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-09-17 23:27:31 +0200
committerCharles Lombardo <clombardo169@gmail.com>2023-09-19 06:31:43 +0200
commit32d65fc8de61407b53eb894dcf26375ea0c982ea (patch)
treec0646a57ba2f4a75a52187bc2eb005e74508e8eb
parentandroid: Export PiP receiver on API 33 and later (diff)
downloadyuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.tar
yuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.tar.gz
yuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.tar.bz2
yuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.tar.lz
yuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.tar.xz
yuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.tar.zst
yuzu-32d65fc8de61407b53eb894dcf26375ea0c982ea.zip
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt22
-rw-r--r--src/android/app/src/main/jni/emu_window/emu_window.cpp14
2 files changed, 11 insertions, 25 deletions
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 3e6c157c7..43d1d2364 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,6 @@ import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
-import android.util.Rational
import android.view.*
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
@@ -287,6 +286,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
+ updateScreenLayout()
if (emulationActivity?.isInPictureInPictureMode == true) {
if (binding.drawerLayout.isOpen) {
binding.drawerLayout.close()
@@ -394,16 +394,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}
private fun updateScreenLayout() {
- binding.surfaceEmulation.setAspectRatio(
- when (IntSetting.RENDERER_ASPECT_RATIO.int) {
- 0 -> Rational(16, 9)
- 1 -> Rational(4, 3)
- 2 -> Rational(21, 9)
- 3 -> Rational(16, 10)
- 4 -> null // Stretch
- else -> Rational(16, 9)
- }
- )
+ binding.surfaceEmulation.setAspectRatio(null)
emulationActivity?.buildPictureInPictureParams()
updateOrientation()
}
@@ -693,7 +684,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
private class EmulationState(private val gamePath: String) {
private var state: State
private var surface: Surface? = null
- private var runWhenSurfaceIsValid = false
init {
// Starting state is stopped.
@@ -751,8 +741,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
// If the surface is set, run now. Otherwise, wait for it to get set.
if (surface != null) {
runWithValidSurface()
- } else {
- runWhenSurfaceIsValid = true
}
}
@@ -760,7 +748,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
@Synchronized
fun newSurface(surface: Surface?) {
this.surface = surface
- if (runWhenSurfaceIsValid) {
+ if (this.surface != null) {
runWithValidSurface()
}
}
@@ -788,10 +776,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}
private fun runWithValidSurface() {
- runWhenSurfaceIsValid = false
+ NativeLibrary.surfaceChanged(surface)
when (state) {
State.STOPPED -> {
- NativeLibrary.surfaceChanged(surface)
val emulationThread = Thread({
Log.debug("[EmulationFragment] Starting emulation thread.")
NativeLibrary.run(gamePath)
@@ -801,7 +788,6 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
State.PAUSED -> {
Log.debug("[EmulationFragment] Resuming emulation.")
- NativeLibrary.surfaceChanged(surface)
NativeLibrary.unpauseEmulation()
}
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 a890c6604..a7e414b81 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
@@ -11,6 +11,12 @@
#include "jni/emu_window/emu_window.h"
void EmuWindow_Android::OnSurfaceChanged(ANativeWindow* surface) {
+ m_window_width = ANativeWindow_getWidth(surface);
+ m_window_height = ANativeWindow_getHeight(surface);
+
+ // Ensures that we emulate with the correct aspect ratio.
+ UpdateCurrentFramebufferLayout(m_window_width, m_window_height);
+
window_info.render_surface = reinterpret_cast<void*>(surface);
}
@@ -62,14 +68,8 @@ EmuWindow_Android::EmuWindow_Android(InputCommon::InputSubsystem* input_subsyste
return;
}
- m_window_width = ANativeWindow_getWidth(surface);
- m_window_height = ANativeWindow_getHeight(surface);
-
- // Ensures that we emulate with the correct aspect ratio.
- UpdateCurrentFramebufferLayout(m_window_width, m_window_height);
-
+ OnSurfaceChanged(surface);
window_info.type = Core::Frontend::WindowSystemType::Android;
- window_info.render_surface = reinterpret_cast<void*>(surface);
m_input_subsystem->Initialize();
}