Skip to content

Commit

Permalink
android: Add button dpad bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenSauce04 authored and Gamer64ytb committed Jul 26, 2024
1 parent fd3bb12 commit bf6691d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,26 @@ class Settings {
KEY_CSTICK_AXIS_VERTICAL,
KEY_CSTICK_AXIS_HORIZONTAL
)
val dPadKeys = listOf(
val dPadAxisKeys = listOf(
KEY_DPAD_AXIS_VERTICAL,
KEY_DPAD_AXIS_HORIZONTAL
)
val dPadButtonKeys = listOf(
KEY_BUTTON_UP,
KEY_BUTTON_DOWN,
KEY_BUTTON_LEFT,
KEY_BUTTON_RIGHT
)
val axisTitles = listOf(
R.string.controller_axis_vertical,
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(
KEY_BUTTON_L,
KEY_BUTTON_R,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
presenter.onSettingsReset()

val controllerKeys = Settings.buttonKeys + Settings.circlePadKeys + Settings.cStickKeys +
Settings.dPadKeys + Settings.triggerKeys
Settings.dPadAxisKeys + Settings.dPadButtonKeys + Settings.triggerKeys
val editor =
PreferenceManager.getDefaultSharedPreferences(CitraApplication.appContext).edit()
controllerKeys.forEach { editor.remove(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,18 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
add(InputBindingSetting(button, Settings.axisTitles[i]))
}

add(HeaderSetting(R.string.controller_dpad))
Settings.dPadKeys.forEachIndexed { i: Int, key: String ->
// TODO: Improve the integration of the two dpad types to be
// less user-facingly hacky
add(HeaderSetting(R.string.controller_dpad_axis))
Settings.dPadAxisKeys.forEachIndexed { i: Int, key: String ->
val button = getInputObject(key)
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))
Settings.triggerKeys.forEachIndexed { i: Int, key: String ->
Expand Down
6 changes: 6 additions & 0 deletions src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@
<string name="controller_triggers">Triggers</string>
<string name="controller_trigger">Trigger</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_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_description">Press or move an input.</string>
<string name="input_binding">Input Binding</string>
Expand Down

0 comments on commit bf6691d

Please sign in to comment.