From cae328570c3d4adec266fa9bdf8625ff5e15d7c6 Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Mon, 27 May 2024 22:21:18 +0100 Subject: [PATCH] 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 --- .../android/features/settings/model/Settings.kt | 14 +++++++++++++- .../features/settings/ui/SettingsActivity.kt | 2 +- .../settings/ui/SettingsFragmentPresenter.kt | 11 +++++++++-- src/android/app/src/main/res/values/strings.xml | 6 ++++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt index 2ec43818f..eead17ecf 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/model/Settings.kt @@ -163,14 +163,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, diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsActivity.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsActivity.kt index efb586cb7..d386ac44b 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsActivity.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsActivity.kt @@ -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(LimeApplication.appContext).edit() controllerKeys.forEach { editor.remove(it) } diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt index f85881ee1..8bf9dc43d 100644 --- a/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/io/github/lime3ds/android/features/settings/ui/SettingsFragmentPresenter.kt @@ -609,11 +609,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 -> diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index a5a78145a..fa4b77a92 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -108,8 +108,14 @@ Triggers Trigger D-Pad + D-Pad (Axis) + D-Pad (Button) Up/Down Axis Left/Right Axis + Up + Down + Left + Right Bind %1$s %2$s Press or move an input. Input Binding