android: Add button dpad bindings

This exists alongside the previous axis dpad bind

This should be changed in the future to be more seamless for end users, but it works for now
This commit is contained in:
OpenSauce04 2024-05-27 22:21:18 +01:00
parent c5472c3a9c
commit cae328570c
4 changed files with 29 additions and 4 deletions

View File

@ -163,14 +163,26 @@ class Settings {
KEY_CSTICK_AXIS_VERTICAL, KEY_CSTICK_AXIS_VERTICAL,
KEY_CSTICK_AXIS_HORIZONTAL KEY_CSTICK_AXIS_HORIZONTAL
) )
val dPadKeys = listOf( val dPadAxisKeys = listOf(
KEY_DPAD_AXIS_VERTICAL, KEY_DPAD_AXIS_VERTICAL,
KEY_DPAD_AXIS_HORIZONTAL KEY_DPAD_AXIS_HORIZONTAL
) )
val dPadButtonKeys = listOf(
KEY_BUTTON_UP,
KEY_BUTTON_DOWN,
KEY_BUTTON_LEFT,
KEY_BUTTON_RIGHT
)
val axisTitles = listOf( val axisTitles = listOf(
R.string.controller_axis_vertical, R.string.controller_axis_vertical,
R.string.controller_axis_horizontal R.string.controller_axis_horizontal
) )
val dpadTitles = listOf(
R.string.direction_up,
R.string.direction_down,
R.string.direction_left,
R.string.direction_right
)
val triggerKeys = listOf( val triggerKeys = listOf(
KEY_BUTTON_L, KEY_BUTTON_L,
KEY_BUTTON_R, KEY_BUTTON_R,

View File

@ -191,7 +191,7 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
presenter.onSettingsReset() presenter.onSettingsReset()
val controllerKeys = Settings.buttonKeys + Settings.circlePadKeys + Settings.cStickKeys + val controllerKeys = Settings.buttonKeys + Settings.circlePadKeys + Settings.cStickKeys +
Settings.dPadKeys + Settings.triggerKeys Settings.dPadAxisKeys + Settings.dPadButtonKeys + Settings.triggerKeys
val editor = val editor =
PreferenceManager.getDefaultSharedPreferences(LimeApplication.appContext).edit() PreferenceManager.getDefaultSharedPreferences(LimeApplication.appContext).edit()
controllerKeys.forEach { editor.remove(it) } controllerKeys.forEach { editor.remove(it) }

View File

@ -609,11 +609,18 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
add(InputBindingSetting(button, Settings.axisTitles[i])) add(InputBindingSetting(button, Settings.axisTitles[i]))
} }
add(HeaderSetting(R.string.controller_dpad)) // TODO: Improve the integration of the two dpad types to be
Settings.dPadKeys.forEachIndexed { i: Int, key: String -> // less user-facingly hacky
add(HeaderSetting(R.string.controller_dpad_axis))
Settings.dPadAxisKeys.forEachIndexed { i: Int, key: String ->
val button = getInputObject(key) val button = getInputObject(key)
add(InputBindingSetting(button, Settings.axisTitles[i])) add(InputBindingSetting(button, Settings.axisTitles[i]))
} }
add(HeaderSetting(R.string.controller_dpad_button))
Settings.dPadButtonKeys.forEachIndexed { i: Int, key: String ->
val button = getInputObject(key)
add(InputBindingSetting(button, Settings.dpadTitles[i]))
}
add(HeaderSetting(R.string.controller_triggers)) add(HeaderSetting(R.string.controller_triggers))
Settings.triggerKeys.forEachIndexed { i: Int, key: String -> Settings.triggerKeys.forEachIndexed { i: Int, key: String ->

View File

@ -108,8 +108,14 @@
<string name="controller_triggers">Triggers</string> <string name="controller_triggers">Triggers</string>
<string name="controller_trigger">Trigger</string> <string name="controller_trigger">Trigger</string>
<string name="controller_dpad">D-Pad</string> <string name="controller_dpad">D-Pad</string>
<string name="controller_dpad_axis">D-Pad (Axis)</string>
<string name="controller_dpad_button">D-Pad (Button)</string>
<string name="controller_axis_vertical">Up/Down Axis</string> <string name="controller_axis_vertical">Up/Down Axis</string>
<string name="controller_axis_horizontal">Left/Right Axis</string> <string name="controller_axis_horizontal">Left/Right Axis</string>
<string name="direction_up">Up</string>
<string name="direction_down">Down</string>
<string name="direction_left">Left</string>
<string name="direction_right">Right</string>
<string name="input_dialog_title">Bind %1$s %2$s</string> <string name="input_dialog_title">Bind %1$s %2$s</string>
<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>