mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-12-16 12:08:49 +00:00
direction kept with axis mapping
This commit is contained in:
parent
e0b8e8440a
commit
6f339a2253
@ -338,6 +338,7 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
preferences.getInt(InputBindingSetting.getInputAxisButtonKey(axis), -1)
|
preferences.getInt(InputBindingSetting.getInputAxisButtonKey(axis), -1)
|
||||||
val guestOrientation =
|
val guestOrientation =
|
||||||
preferences.getInt(InputBindingSetting.getInputAxisOrientationKey(axis), -1)
|
preferences.getInt(InputBindingSetting.getInputAxisOrientationKey(axis), -1)
|
||||||
|
val inverted = preferences.getBoolean(InputBindingSetting.getInputAxisInvertedKey(axis),false);
|
||||||
if (nextMapping == -1 || guestOrientation == -1) {
|
if (nextMapping == -1 || guestOrientation == -1) {
|
||||||
// Axis is unmapped
|
// Axis is unmapped
|
||||||
continue
|
continue
|
||||||
@ -346,6 +347,8 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
// Skip joystick wobble
|
// Skip joystick wobble
|
||||||
value = 0f
|
value = 0f
|
||||||
}
|
}
|
||||||
|
if (inverted) value = -value;
|
||||||
|
|
||||||
when (nextMapping) {
|
when (nextMapping) {
|
||||||
NativeLibrary.ButtonType.STICK_LEFT -> {
|
NativeLibrary.ButtonType.STICK_LEFT -> {
|
||||||
axisValuesCirclePad[guestOrientation] = value
|
axisValuesCirclePad[guestOrientation] = value
|
||||||
|
|||||||
@ -167,6 +167,7 @@ class InputBindingSetting(
|
|||||||
.remove(oldKey) // Used for button mapping
|
.remove(oldKey) // Used for button mapping
|
||||||
.remove(oldKey + "_GuestOrientation") // Used for axis orientation
|
.remove(oldKey + "_GuestOrientation") // Used for axis orientation
|
||||||
.remove(oldKey + "_GuestButton") // Used for axis button
|
.remove(oldKey + "_GuestButton") // Used for axis button
|
||||||
|
.remove(oldKey + "_Inverted") // used for axis inversion
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +201,7 @@ class InputBindingSetting(
|
|||||||
/**
|
/**
|
||||||
* Helper function to write a gamepad axis mapping for the setting.
|
* 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
|
// Cleanup old mapping
|
||||||
removeOldMapping()
|
removeOldMapping()
|
||||||
|
|
||||||
@ -208,6 +209,7 @@ class InputBindingSetting(
|
|||||||
preferences.edit()
|
preferences.edit()
|
||||||
.putInt(getInputAxisOrientationKey(axis), if (isHorizontalOrientation()) 0 else 1)
|
.putInt(getInputAxisOrientationKey(axis), if (isHorizontalOrientation()) 0 else 1)
|
||||||
.putInt(getInputAxisButtonKey(axis), value)
|
.putInt(getInputAxisButtonKey(axis), value)
|
||||||
|
.putBoolean(getInputAxisInvertedKey(axis),inverted)
|
||||||
// Write next reverse mapping for future cleanup
|
// Write next reverse mapping for future cleanup
|
||||||
.putString(reverseKey, getInputAxisKey(axis))
|
.putString(reverseKey, getInputAxisKey(axis))
|
||||||
.apply()
|
.apply()
|
||||||
@ -251,8 +253,8 @@ class InputBindingSetting(
|
|||||||
} else {
|
} else {
|
||||||
buttonCode
|
buttonCode
|
||||||
}
|
}
|
||||||
writeAxisMapping(motionRange.axis, button)
|
writeAxisMapping(motionRange.axis, button, axisDir == '-')
|
||||||
val uiString = "${device.name}: Axis ${motionRange.axis}"
|
val uiString = "${device.name}: Axis ${motionRange.axis}" + axisDir
|
||||||
value = uiString
|
value = uiString
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,6 +309,11 @@ class InputBindingSetting(
|
|||||||
*/
|
*/
|
||||||
fun getInputAxisButtonKey(axis: Int): String = "${getInputAxisKey(axis)}_GuestButton"
|
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.
|
* Helper function to get the settings key for an gamepad axis orientation.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -133,8 +133,8 @@
|
|||||||
<string name="input_dialog_description">Press or move an input.</string>
|
<string name="input_dialog_description">Press or move an input.</string>
|
||||||
<string name="input_binding">Input Binding</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">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_vertical_axis">Move your joystick down</string>
|
||||||
<string name="input_binding_description_horizontal_axis">Move your joystick left or right.</string>
|
<string name="input_binding_description_horizontal_axis">Move your joystick right</string>
|
||||||
<string name="button_a" translatable="false">A</string>
|
<string name="button_a" translatable="false">A</string>
|
||||||
<string name="button_b" translatable="false">B</string>
|
<string name="button_b" translatable="false">B</string>
|
||||||
<string name="button_select" translatable="false">SELECT</string>
|
<string name="button_select" translatable="false">SELECT</string>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user