This commit is contained in:
David Griswold 2025-12-10 13:13:29 +03:00 committed by GitHub
commit 8988590eb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

View File

@ -342,6 +342,7 @@ class EmulationActivity : AppCompatActivity() {
preferences.getInt(InputBindingSetting.getInputAxisButtonKey(axis), -1)
val guestOrientation =
preferences.getInt(InputBindingSetting.getInputAxisOrientationKey(axis), -1)
val inverted = preferences.getBoolean(InputBindingSetting.getInputAxisInvertedKey(axis),false);
if (nextMapping == -1 || guestOrientation == -1) {
// Axis is unmapped
continue
@ -350,6 +351,8 @@ class EmulationActivity : AppCompatActivity() {
// Skip joystick wobble
value = 0f
}
if (inverted) value = -value;
when (nextMapping) {
NativeLibrary.ButtonType.STICK_LEFT -> {
axisValuesCirclePad[guestOrientation] = value

View File

@ -169,6 +169,7 @@ class InputBindingSetting(
.remove(oldKey) // Used for button mapping
.remove(oldKey + "_GuestOrientation") // Used for axis orientation
.remove(oldKey + "_GuestButton") // Used for axis button
.remove(oldKey + "_Inverted") // used for axis inversion
.apply()
}
}
@ -202,7 +203,7 @@ class InputBindingSetting(
/**
* Helper function to write a gamepad axis mapping for the setting.
*/
private fun writeAxisMapping(axis: Int, value: Int) {
private fun writeAxisMapping(axis: Int, value: Int, inverted: Boolean) {
// Cleanup old mapping
removeOldMapping()
@ -210,6 +211,7 @@ class InputBindingSetting(
preferences.edit()
.putInt(getInputAxisOrientationKey(axis), if (isHorizontalOrientation()) 0 else 1)
.putInt(getInputAxisButtonKey(axis), value)
.putBoolean(getInputAxisInvertedKey(axis),inverted)
// Write next reverse mapping for future cleanup
.putString(reverseKey, getInputAxisKey(axis))
.apply()
@ -253,8 +255,8 @@ class InputBindingSetting(
} else {
buttonCode
}
writeAxisMapping(motionRange.axis, button)
val uiString = "${device.name}: Axis ${motionRange.axis}"
writeAxisMapping(motionRange.axis, button, axisDir == '-')
val uiString = "${device.name}: Axis ${motionRange.axis}" + axisDir
value = uiString
}
@ -309,6 +311,11 @@ class InputBindingSetting(
*/
fun getInputAxisButtonKey(axis: Int): String = "${getInputAxisKey(axis)}_GuestButton"
/**
* Helper function to get the settings key for an whether a gamepad axis is inverted.
*/
fun getInputAxisInvertedKey(axis: Int): String = "${getInputAxisKey(axis)}_Inverted"
/**
* Helper function to get the settings key for an gamepad axis orientation.
*/

View File

@ -133,8 +133,8 @@
<string name="input_dialog_description">Press or move an input.</string>
<string name="input_binding">Input Binding</string>
<string name="input_binding_description">Press or move an input to bind it to %1$s.</string>
<string name="input_binding_description_vertical_axis">Move your joystick up or down.</string>
<string name="input_binding_description_horizontal_axis">Move your joystick left or right.</string>
<string name="input_binding_description_vertical_axis">Move your joystick down</string>
<string name="input_binding_description_horizontal_axis">Move your joystick right</string>
<string name="button_a" translatable="false">A</string>
<string name="button_b" translatable="false">B</string>
<string name="button_select" translatable="false">SELECT</string>