diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | 5 | ||||
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ControllerMappingHelper.kt | 70 |
2 files changed, 0 insertions, 75 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 e96a2059b..7464647c4 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 | |||
| @@ -45,7 +45,6 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting | |||
| 45 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 45 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 46 | import org.yuzu.yuzu_emu.model.EmulationViewModel | 46 | import org.yuzu.yuzu_emu.model.EmulationViewModel |
| 47 | import org.yuzu.yuzu_emu.model.Game | 47 | import org.yuzu.yuzu_emu.model.Game |
| 48 | import org.yuzu.yuzu_emu.utils.ControllerMappingHelper | ||
| 49 | import org.yuzu.yuzu_emu.utils.ForegroundService | 48 | import org.yuzu.yuzu_emu.utils.ForegroundService |
| 50 | import org.yuzu.yuzu_emu.utils.InputHandler | 49 | import org.yuzu.yuzu_emu.utils.InputHandler |
| 51 | import org.yuzu.yuzu_emu.utils.MemoryUtil | 50 | import org.yuzu.yuzu_emu.utils.MemoryUtil |
| @@ -57,8 +56,6 @@ import kotlin.math.roundToInt | |||
| 57 | class EmulationActivity : AppCompatActivity(), SensorEventListener { | 56 | class EmulationActivity : AppCompatActivity(), SensorEventListener { |
| 58 | private lateinit var binding: ActivityEmulationBinding | 57 | private lateinit var binding: ActivityEmulationBinding |
| 59 | 58 | ||
| 60 | private var controllerMappingHelper: ControllerMappingHelper? = null | ||
| 61 | |||
| 62 | var isActivityRecreated = false | 59 | var isActivityRecreated = false |
| 63 | private lateinit var nfcReader: NfcReader | 60 | private lateinit var nfcReader: NfcReader |
| 64 | private lateinit var inputHandler: InputHandler | 61 | private lateinit var inputHandler: InputHandler |
| @@ -95,8 +92,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 95 | 92 | ||
| 96 | isActivityRecreated = savedInstanceState != null | 93 | isActivityRecreated = savedInstanceState != null |
| 97 | 94 | ||
| 98 | controllerMappingHelper = ControllerMappingHelper() | ||
| 99 | |||
| 100 | // Set these options now so that the SurfaceView the game renders into is the right size. | 95 | // Set these options now so that the SurfaceView the game renders into is the right size. |
| 101 | enableFullscreenImmersive() | 96 | enableFullscreenImmersive() |
| 102 | 97 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ControllerMappingHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ControllerMappingHelper.kt deleted file mode 100644 index eeefcdf20..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/ControllerMappingHelper.kt +++ /dev/null | |||
| @@ -1,70 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | package org.yuzu.yuzu_emu.utils | ||
| 5 | |||
| 6 | import android.view.InputDevice | ||
| 7 | import android.view.KeyEvent | ||
| 8 | import android.view.MotionEvent | ||
| 9 | |||
| 10 | /** | ||
| 11 | * Some controllers have incorrect mappings. This class has special-case fixes for them. | ||
| 12 | */ | ||
| 13 | class ControllerMappingHelper { | ||
| 14 | /** | ||
| 15 | * Some controllers report extra button presses that can be ignored. | ||
| 16 | */ | ||
| 17 | fun shouldKeyBeIgnored(inputDevice: InputDevice, keyCode: Int): Boolean { | ||
| 18 | return if (isDualShock4(inputDevice)) { | ||
| 19 | // The two analog triggers generate analog motion events as well as a keycode. | ||
| 20 | // We always prefer to use the analog values, so throw away the button press | ||
| 21 | keyCode == KeyEvent.KEYCODE_BUTTON_L2 || keyCode == KeyEvent.KEYCODE_BUTTON_R2 | ||
| 22 | } else { | ||
| 23 | false | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Scale an axis to be zero-centered with a proper range. | ||
| 29 | */ | ||
| 30 | fun scaleAxis(inputDevice: InputDevice, axis: Int, value: Float): Float { | ||
| 31 | if (isDualShock4(inputDevice)) { | ||
| 32 | // Android doesn't have correct mappings for this controller's triggers. It reports them | ||
| 33 | // as RX & RY, centered at -1.0, and with a range of [-1.0, 1.0] | ||
| 34 | // Scale them to properly zero-centered with a range of [0.0, 1.0]. | ||
| 35 | if (axis == MotionEvent.AXIS_RX || axis == MotionEvent.AXIS_RY) { | ||
| 36 | return (value + 1) / 2.0f | ||
| 37 | } | ||
| 38 | } else if (isXboxOneWireless(inputDevice)) { | ||
| 39 | // Same as the DualShock 4, the mappings are missing. | ||
| 40 | if (axis == MotionEvent.AXIS_Z || axis == MotionEvent.AXIS_RZ) { | ||
| 41 | return (value + 1) / 2.0f | ||
| 42 | } | ||
| 43 | if (axis == MotionEvent.AXIS_GENERIC_1) { | ||
| 44 | // This axis is stuck at ~.5. Ignore it. | ||
| 45 | return 0.0f | ||
| 46 | } | ||
| 47 | } else if (isMogaPro2Hid(inputDevice)) { | ||
| 48 | // This controller has a broken axis that reports a constant value. Ignore it. | ||
| 49 | if (axis == MotionEvent.AXIS_GENERIC_1) { | ||
| 50 | return 0.0f | ||
| 51 | } | ||
| 52 | } | ||
| 53 | return value | ||
| 54 | } | ||
| 55 | |||
| 56 | // Sony DualShock 4 controller | ||
| 57 | private fun isDualShock4(inputDevice: InputDevice): Boolean { | ||
| 58 | return inputDevice.vendorId == 0x54c && inputDevice.productId == 0x9cc | ||
| 59 | } | ||
| 60 | |||
| 61 | // Microsoft Xbox One controller | ||
| 62 | private fun isXboxOneWireless(inputDevice: InputDevice): Boolean { | ||
| 63 | return inputDevice.vendorId == 0x45e && inputDevice.productId == 0x2e0 | ||
| 64 | } | ||
| 65 | |||
| 66 | // Moga Pro 2 HID | ||
| 67 | private fun isMogaPro2Hid(inputDevice: InputDevice): Boolean { | ||
| 68 | return inputDevice.vendorId == 0x20d6 && inputDevice.productId == 0x6271 | ||
| 69 | } | ||
| 70 | } | ||