forked from MeloNX/MeloNX
android - add option to swap button layouts to nintendo style
This commit is contained in:
parent
de58a53085
commit
316c0ffca2
@ -2,6 +2,7 @@ package org.ryujinx.android
|
|||||||
|
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import org.ryujinx.android.viewmodels.QuickSettings
|
||||||
|
|
||||||
class PhysicalControllerManager(val activity: MainActivity) {
|
class PhysicalControllerManager(val activity: MainActivity) {
|
||||||
private var controllerId: Int = -1
|
private var controllerId: Int = -1
|
||||||
@ -54,11 +55,12 @@ class PhysicalControllerManager(val activity: MainActivity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getGamePadButtonInputId(keycode: Int): GamePadButtonInputId {
|
private fun getGamePadButtonInputId(keycode: Int): GamePadButtonInputId {
|
||||||
|
val quickSettings = QuickSettings(activity)
|
||||||
return when (keycode) {
|
return when (keycode) {
|
||||||
KeyEvent.KEYCODE_BUTTON_A -> GamePadButtonInputId.B
|
KeyEvent.KEYCODE_BUTTON_A -> if (!quickSettings.useSwitchLayout) GamePadButtonInputId.A else GamePadButtonInputId.B
|
||||||
KeyEvent.KEYCODE_BUTTON_B -> GamePadButtonInputId.A
|
KeyEvent.KEYCODE_BUTTON_B -> if (!quickSettings.useSwitchLayout) GamePadButtonInputId.B else GamePadButtonInputId.A
|
||||||
KeyEvent.KEYCODE_BUTTON_X -> GamePadButtonInputId.X
|
KeyEvent.KEYCODE_BUTTON_X -> if (!quickSettings.useSwitchLayout) GamePadButtonInputId.X else GamePadButtonInputId.Y
|
||||||
KeyEvent.KEYCODE_BUTTON_Y -> GamePadButtonInputId.Y
|
KeyEvent.KEYCODE_BUTTON_Y -> if (!quickSettings.useSwitchLayout) GamePadButtonInputId.Y else GamePadButtonInputId.X
|
||||||
KeyEvent.KEYCODE_BUTTON_L1 -> GamePadButtonInputId.LeftShoulder
|
KeyEvent.KEYCODE_BUTTON_L1 -> GamePadButtonInputId.LeftShoulder
|
||||||
KeyEvent.KEYCODE_BUTTON_L2 -> GamePadButtonInputId.LeftTrigger
|
KeyEvent.KEYCODE_BUTTON_L2 -> GamePadButtonInputId.LeftTrigger
|
||||||
KeyEvent.KEYCODE_BUTTON_R1 -> GamePadButtonInputId.RightShoulder
|
KeyEvent.KEYCODE_BUTTON_R1 -> GamePadButtonInputId.RightShoulder
|
||||||
|
@ -16,6 +16,7 @@ class QuickSettings(val activity: Activity) {
|
|||||||
var enableTextureRecompression: Boolean
|
var enableTextureRecompression: Boolean
|
||||||
var resScale : Float
|
var resScale : Float
|
||||||
var isGrid : Boolean
|
var isGrid : Boolean
|
||||||
|
var useSwitchLayout : Boolean
|
||||||
|
|
||||||
// Logs
|
// Logs
|
||||||
var enableDebugLogs: Boolean
|
var enableDebugLogs: Boolean
|
||||||
@ -41,6 +42,7 @@ class QuickSettings(val activity: Activity) {
|
|||||||
resScale = sharedPref.getFloat("resScale", 1f)
|
resScale = sharedPref.getFloat("resScale", 1f)
|
||||||
useVirtualController = sharedPref.getBoolean("useVirtualController", true)
|
useVirtualController = sharedPref.getBoolean("useVirtualController", true)
|
||||||
isGrid = sharedPref.getBoolean("isGrid", true)
|
isGrid = sharedPref.getBoolean("isGrid", true)
|
||||||
|
useSwitchLayout = sharedPref.getBoolean("useSwitchLayout", true)
|
||||||
|
|
||||||
enableDebugLogs = sharedPref.getBoolean("enableDebugLogs", false)
|
enableDebugLogs = sharedPref.getBoolean("enableDebugLogs", false)
|
||||||
enableStubLogs = sharedPref.getBoolean("enableStubLogs", false)
|
enableStubLogs = sharedPref.getBoolean("enableStubLogs", false)
|
||||||
@ -66,6 +68,7 @@ class QuickSettings(val activity: Activity) {
|
|||||||
editor.putFloat("resScale", resScale)
|
editor.putFloat("resScale", resScale)
|
||||||
editor.putBoolean("useVirtualController", useVirtualController)
|
editor.putBoolean("useVirtualController", useVirtualController)
|
||||||
editor.putBoolean("isGrid", isGrid)
|
editor.putBoolean("isGrid", isGrid)
|
||||||
|
editor.putBoolean("useSwitchLayout", useSwitchLayout)
|
||||||
|
|
||||||
editor.putBoolean("enableDebugLogs", enableDebugLogs)
|
editor.putBoolean("enableDebugLogs", enableDebugLogs)
|
||||||
editor.putBoolean("enableStubLogs", enableStubLogs)
|
editor.putBoolean("enableStubLogs", enableStubLogs)
|
||||||
|
@ -54,6 +54,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
|||||||
resScale: MutableState<Float>,
|
resScale: MutableState<Float>,
|
||||||
useVirtualController: MutableState<Boolean>,
|
useVirtualController: MutableState<Boolean>,
|
||||||
isGrid: MutableState<Boolean>,
|
isGrid: MutableState<Boolean>,
|
||||||
|
useSwitchLayout: MutableState<Boolean>,
|
||||||
enableDebugLogs: MutableState<Boolean>,
|
enableDebugLogs: MutableState<Boolean>,
|
||||||
enableStubLogs: MutableState<Boolean>,
|
enableStubLogs: MutableState<Boolean>,
|
||||||
enableInfoLogs: MutableState<Boolean>,
|
enableInfoLogs: MutableState<Boolean>,
|
||||||
@ -76,6 +77,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
|||||||
resScale.value = sharedPref.getFloat("resScale", 1f)
|
resScale.value = sharedPref.getFloat("resScale", 1f)
|
||||||
useVirtualController.value = sharedPref.getBoolean("useVirtualController", true)
|
useVirtualController.value = sharedPref.getBoolean("useVirtualController", true)
|
||||||
isGrid.value = sharedPref.getBoolean("isGrid", true)
|
isGrid.value = sharedPref.getBoolean("isGrid", true)
|
||||||
|
useSwitchLayout.value = sharedPref.getBoolean("useSwitchLayout", true)
|
||||||
|
|
||||||
enableDebugLogs.value = sharedPref.getBoolean("enableDebugLogs", false)
|
enableDebugLogs.value = sharedPref.getBoolean("enableDebugLogs", false)
|
||||||
enableStubLogs.value = sharedPref.getBoolean("enableStubLogs", false)
|
enableStubLogs.value = sharedPref.getBoolean("enableStubLogs", false)
|
||||||
@ -99,6 +101,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
|||||||
resScale: MutableState<Float>,
|
resScale: MutableState<Float>,
|
||||||
useVirtualController: MutableState<Boolean>,
|
useVirtualController: MutableState<Boolean>,
|
||||||
isGrid: MutableState<Boolean>,
|
isGrid: MutableState<Boolean>,
|
||||||
|
useSwitchLayout: MutableState<Boolean>,
|
||||||
enableDebugLogs: MutableState<Boolean>,
|
enableDebugLogs: MutableState<Boolean>,
|
||||||
enableStubLogs: MutableState<Boolean>,
|
enableStubLogs: MutableState<Boolean>,
|
||||||
enableInfoLogs: MutableState<Boolean>,
|
enableInfoLogs: MutableState<Boolean>,
|
||||||
@ -121,7 +124,7 @@ class SettingsViewModel(var navController: NavHostController, val activity: Main
|
|||||||
editor.putFloat("resScale", resScale.value)
|
editor.putFloat("resScale", resScale.value)
|
||||||
editor.putBoolean("useVirtualController", useVirtualController.value)
|
editor.putBoolean("useVirtualController", useVirtualController.value)
|
||||||
editor.putBoolean("isGrid", isGrid.value)
|
editor.putBoolean("isGrid", isGrid.value)
|
||||||
|
editor.putBoolean("useSwitchLayout", useSwitchLayout.value)
|
||||||
|
|
||||||
editor.putBoolean("enableDebugLogs", enableDebugLogs.value)
|
editor.putBoolean("enableDebugLogs", enableDebugLogs.value)
|
||||||
editor.putBoolean("enableStubLogs", enableStubLogs.value)
|
editor.putBoolean("enableStubLogs", enableStubLogs.value)
|
||||||
|
@ -120,6 +120,7 @@ class SettingViews {
|
|||||||
mutableStateOf(mainViewModel.firmwareVersion)
|
mutableStateOf(mainViewModel.firmwareVersion)
|
||||||
}
|
}
|
||||||
val isGrid = remember { mutableStateOf(true) }
|
val isGrid = remember { mutableStateOf(true) }
|
||||||
|
val useSwitchLayout = remember { mutableStateOf(true) }
|
||||||
|
|
||||||
val enableDebugLogs = remember { mutableStateOf(true) }
|
val enableDebugLogs = remember { mutableStateOf(true) }
|
||||||
val enableStubLogs = remember { mutableStateOf(true) }
|
val enableStubLogs = remember { mutableStateOf(true) }
|
||||||
@ -140,6 +141,7 @@ class SettingViews {
|
|||||||
resScale,
|
resScale,
|
||||||
useVirtualController,
|
useVirtualController,
|
||||||
isGrid,
|
isGrid,
|
||||||
|
useSwitchLayout,
|
||||||
enableDebugLogs,
|
enableDebugLogs,
|
||||||
enableStubLogs,
|
enableStubLogs,
|
||||||
enableInfoLogs,
|
enableInfoLogs,
|
||||||
@ -171,6 +173,7 @@ class SettingViews {
|
|||||||
resScale,
|
resScale,
|
||||||
useVirtualController,
|
useVirtualController,
|
||||||
isGrid,
|
isGrid,
|
||||||
|
useSwitchLayout,
|
||||||
enableDebugLogs,
|
enableDebugLogs,
|
||||||
enableStubLogs,
|
enableStubLogs,
|
||||||
enableInfoLogs,
|
enableInfoLogs,
|
||||||
@ -854,6 +857,21 @@ class SettingViews {
|
|||||||
useVirtualController.value = !useVirtualController.value
|
useVirtualController.value = !useVirtualController.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(8.dp),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Use Switch Controller Layout",
|
||||||
|
modifier = Modifier.align(Alignment.CenterVertically)
|
||||||
|
)
|
||||||
|
Switch(checked = useSwitchLayout.value, onCheckedChange = {
|
||||||
|
useSwitchLayout.value = !useSwitchLayout.value
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExpandableView(onCardArrowClick = { }, title = "Log") {
|
ExpandableView(onCardArrowClick = { }, title = "Log") {
|
||||||
@ -1004,6 +1022,7 @@ class SettingViews {
|
|||||||
resScale,
|
resScale,
|
||||||
useVirtualController,
|
useVirtualController,
|
||||||
isGrid,
|
isGrid,
|
||||||
|
useSwitchLayout,
|
||||||
enableDebugLogs,
|
enableDebugLogs,
|
||||||
enableStubLogs,
|
enableStubLogs,
|
||||||
enableInfoLogs,
|
enableInfoLogs,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user