summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2023-05-10 07:44:00 +0200
committerbunnei <bunneidev@gmail.com>2023-06-03 09:06:01 +0200
commitaa957df0dcd01afeac41afe7a7246f57b61acedc (patch)
treecc7bcc8a71f9b0b1d231f48f29054a00ea8f15cb
parentandroid: vulkan_device: Skip BGR565 emulation on S8gen2. (diff)
downloadyuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.tar
yuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.tar.gz
yuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.tar.bz2
yuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.tar.lz
yuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.tar.xz
yuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.tar.zst
yuzu-aa957df0dcd01afeac41afe7a7246f57b61acedc.zip
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
index 1301583a0..4a0f88f52 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
@@ -13,9 +13,12 @@ import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.os.Bundle
-import android.view.*
+import android.view.InputDevice
import android.view.KeyEvent
import android.view.MotionEvent
+import android.view.Surface
+import android.view.View
+import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
@@ -49,6 +52,7 @@ open class EmulationActivity : AppCompatActivity(), SensorEventListener {
private val gyro = FloatArray(3)
private val accel = FloatArray(3)
private var motionTimestamp: Long = 0
+ private var flipMotionOrientation: Boolean = false
private lateinit var game: Game
@@ -173,15 +177,33 @@ open class EmulationActivity : AppCompatActivity(), SensorEventListener {
}
override fun onSensorChanged(event: SensorEvent) {
+ val rotation = this.display?.rotation
+ if (rotation == Surface.ROTATION_90) {
+ flipMotionOrientation = true
+ }
+ if (rotation == Surface.ROTATION_270) {
+ flipMotionOrientation = false
+ }
+
if (event.sensor.type == Sensor.TYPE_ACCELEROMETER) {
- accel[0] = -event.values[1] / SensorManager.GRAVITY_EARTH
- accel[1] = event.values[0] / SensorManager.GRAVITY_EARTH
+ if (flipMotionOrientation) {
+ accel[0] = event.values[1] / SensorManager.GRAVITY_EARTH
+ accel[1] = -event.values[0] / SensorManager.GRAVITY_EARTH
+ } else {
+ accel[0] = -event.values[1] / SensorManager.GRAVITY_EARTH
+ accel[1] = event.values[0] / SensorManager.GRAVITY_EARTH
+ }
accel[2] = -event.values[2] / SensorManager.GRAVITY_EARTH
}
if (event.sensor.type == Sensor.TYPE_GYROSCOPE) {
// Investigate why sensor value is off by 6x
- gyro[0] = event.values[1] / 6.0f
- gyro[1] = -event.values[0] / 6.0f
+ if (flipMotionOrientation) {
+ gyro[0] = -event.values[1] / 6.0f
+ gyro[1] = event.values[0] / 6.0f
+ } else {
+ gyro[0] = event.values[1] / 6.0f
+ gyro[1] = -event.values[0] / 6.0f
+ }
gyro[2] = event.values[2] / 6.0f
}