From e7530a1cb91d9b49257fbfb75cb000757b212489 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 18 Apr 2022 17:57:29 +0200 Subject: [PATCH] Android: Split Wii Remote settings into submenus Too much stuff on one screen otherwise. This split matches DolphinQt. --- .../features/settings/ui/MenuTag.java | 29 +++++++- .../settings/ui/SettingsFragment.java | 12 +++ .../ui/SettingsFragmentPresenter.java | 74 +++++++++++++++++-- .../app/src/main/res/values/strings.xml | 4 + 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java index 1d4fe28af9..f97a013074 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/MenuTag.java @@ -38,7 +38,19 @@ public enum MenuTag WIIMOTE_EXTENSION_1("wiimote_extension", 0), WIIMOTE_EXTENSION_2("wiimote_extension", 1), WIIMOTE_EXTENSION_3("wiimote_extension", 2), - WIIMOTE_EXTENSION_4("wiimote_extension", 3); + WIIMOTE_EXTENSION_4("wiimote_extension", 3), + WIIMOTE_GENERAL_1("wiimote_general", 0), + WIIMOTE_GENERAL_2("wiimote_general", 1), + WIIMOTE_GENERAL_3("wiimote_general", 2), + WIIMOTE_GENERAL_4("wiimote_general", 3), + WIIMOTE_MOTION_SIMULATION_1("wiimote_motion_simulation", 0), + WIIMOTE_MOTION_SIMULATION_2("wiimote_motion_simulation", 1), + WIIMOTE_MOTION_SIMULATION_3("wiimote_motion_simulation", 2), + WIIMOTE_MOTION_SIMULATION_4("wiimote_motion_simulation", 3), + WIIMOTE_MOTION_INPUT_1("wiimote_motion_input", 0), + WIIMOTE_MOTION_INPUT_2("wiimote_motion_input", 1), + WIIMOTE_MOTION_INPUT_3("wiimote_motion_input", 2), + WIIMOTE_MOTION_INPUT_4("wiimote_motion_input", 3); private String tag; private int subType = -1; @@ -112,6 +124,21 @@ public enum MenuTag return getMenuTag("wiimote_extension", subtype); } + public static MenuTag getWiimoteGeneralMenuTag(int subtype) + { + return getMenuTag("wiimote_general", subtype); + } + + public static MenuTag getWiimoteMotionSimulationMenuTag(int subtype) + { + return getMenuTag("wiimote_motion_simulation", subtype); + } + + public static MenuTag getWiimoteMotionInputMenuTag(int subtype) + { + return getMenuTag("wiimote_motion_input", subtype); + } + private static MenuTag getMenuTag(String tag, int subtype) { for (MenuTag menuTag : MenuTag.values()) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java index bb73093656..11ed282cf4 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java @@ -75,6 +75,18 @@ public final class SettingsFragment extends Fragment implements SettingsFragment titles.put(MenuTag.WIIMOTE_EXTENSION_2, R.string.wiimote_extension_1); titles.put(MenuTag.WIIMOTE_EXTENSION_3, R.string.wiimote_extension_2); titles.put(MenuTag.WIIMOTE_EXTENSION_4, R.string.wiimote_extension_3); + titles.put(MenuTag.WIIMOTE_GENERAL_1, R.string.wiimote_general); + titles.put(MenuTag.WIIMOTE_GENERAL_2, R.string.wiimote_general); + titles.put(MenuTag.WIIMOTE_GENERAL_3, R.string.wiimote_general); + titles.put(MenuTag.WIIMOTE_GENERAL_4, R.string.wiimote_general); + titles.put(MenuTag.WIIMOTE_MOTION_SIMULATION_1, R.string.wiimote_motion_simulation); + titles.put(MenuTag.WIIMOTE_MOTION_SIMULATION_2, R.string.wiimote_motion_simulation); + titles.put(MenuTag.WIIMOTE_MOTION_SIMULATION_3, R.string.wiimote_motion_simulation); + titles.put(MenuTag.WIIMOTE_MOTION_SIMULATION_4, R.string.wiimote_motion_simulation); + titles.put(MenuTag.WIIMOTE_MOTION_INPUT_1, R.string.wiimote_motion_input); + titles.put(MenuTag.WIIMOTE_MOTION_INPUT_2, R.string.wiimote_motion_input); + titles.put(MenuTag.WIIMOTE_MOTION_INPUT_3, R.string.wiimote_motion_input); + titles.put(MenuTag.WIIMOTE_MOTION_INPUT_4, R.string.wiimote_motion_input); } private FragmentSettingsBinding mBinding; diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index fded8e56de..3f60937810 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -10,6 +10,7 @@ import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; +import androidx.collection.ArraySet; import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; @@ -56,8 +57,11 @@ import org.dolphinemu.dolphinemu.utils.ThreadUtil; import org.dolphinemu.dolphinemu.utils.WiiUtils; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; public final class SettingsFragmentPresenter { @@ -248,6 +252,27 @@ public final class SettingsFragmentPresenter addExtensionTypeSettings(sl, mControllerNumber, mControllerType); break; + case WIIMOTE_GENERAL_1: + case WIIMOTE_GENERAL_2: + case WIIMOTE_GENERAL_3: + case WIIMOTE_GENERAL_4: + addWiimoteGeneralSubSettings(sl, mControllerNumber); + break; + + case WIIMOTE_MOTION_SIMULATION_1: + case WIIMOTE_MOTION_SIMULATION_2: + case WIIMOTE_MOTION_SIMULATION_3: + case WIIMOTE_MOTION_SIMULATION_4: + addWiimoteMotionSimulationSubSettings(sl, mControllerNumber); + break; + + case WIIMOTE_MOTION_INPUT_1: + case WIIMOTE_MOTION_INPUT_2: + case WIIMOTE_MOTION_INPUT_3: + case WIIMOTE_MOTION_INPUT_4: + addWiimoteMotionInputSubSettings(sl, mControllerNumber); + break; + default: throw new UnsupportedOperationException("Unimplemented menu"); } @@ -1081,7 +1106,7 @@ public final class SettingsFragmentPresenter { if (gcPadType == 6) // Emulated { - addControllerSettings(sl, EmulatedController.getGcPad(gcPadNumber)); + addControllerSettings(sl, EmulatedController.getGcPad(gcPadNumber), null); } else if (gcPadType == 12) // Adapter { @@ -1094,22 +1119,61 @@ public final class SettingsFragmentPresenter private void addWiimoteSubSettings(ArrayList sl, int wiimoteNumber) { - addControllerSettings(sl, EmulatedController.getWiimote(wiimoteNumber)); + sl.add(new HeaderSetting(mContext, R.string.wiimote, 0)); + sl.add(new SubmenuSetting(mContext, R.string.wiimote_general, + MenuTag.getWiimoteGeneralMenuTag(wiimoteNumber))); + sl.add(new SubmenuSetting(mContext, R.string.wiimote_motion_simulation, + MenuTag.getWiimoteMotionSimulationMenuTag(wiimoteNumber))); + sl.add(new SubmenuSetting(mContext, R.string.wiimote_motion_input, + MenuTag.getWiimoteMotionInputMenuTag(wiimoteNumber))); + + addControllerSettings(sl, EmulatedController.getWiimote(wiimoteNumber), + Collections.singleton(ControlGroup.TYPE_ATTACHMENTS)); } private void addExtensionTypeSettings(ArrayList sl, int wiimoteNumber, int extensionType) { addControllerSettings(sl, - EmulatedController.getWiimoteAttachment(wiimoteNumber, extensionType)); + EmulatedController.getWiimoteAttachment(wiimoteNumber, extensionType), null); } - private void addControllerSettings(ArrayList sl, EmulatedController controller) + private void addWiimoteGeneralSubSettings(ArrayList sl, int wiimoteNumber) + { + addControllerSettings(sl, EmulatedController.getWiimote(wiimoteNumber), + new ArraySet<>(Arrays.asList(ControlGroup.TYPE_BUTTONS, ControlGroup.TYPE_OTHER))); + } + + private void addWiimoteMotionSimulationSubSettings(ArrayList sl, int wiimoteNumber) + { + addControllerSettings(sl, EmulatedController.getWiimote(wiimoteNumber), + new ArraySet<>(Arrays.asList(ControlGroup.TYPE_FORCE, ControlGroup.TYPE_TILT, + ControlGroup.TYPE_CURSOR, ControlGroup.TYPE_SHAKE))); + } + + private void addWiimoteMotionInputSubSettings(ArrayList sl, int wiimoteNumber) + { + addControllerSettings(sl, EmulatedController.getWiimote(wiimoteNumber), + new ArraySet<>(Arrays.asList(ControlGroup.TYPE_IMU_ACCELEROMETER, + ControlGroup.TYPE_IMU_GYROSCOPE, ControlGroup.TYPE_IMU_CURSOR))); + } + + /** + * @param sl The list to place controller settings into. + * @param controller The controller to add settings for. + * @param groupTypeFilter If this is non-null, only groups whose types match this are considered. + */ + private void addControllerSettings(ArrayList sl, EmulatedController controller, + Set groupTypeFilter) { int groupCount = controller.getGroupCount(); for (int i = 0; i < groupCount; i++) { ControlGroup group = controller.getGroup(i); + int groupType = group.getGroupType(); + if (groupTypeFilter != null && !groupTypeFilter.contains(groupType)) + continue; + sl.add(new HeaderSetting(group.getUiName(), "")); int controlCount = group.getControlCount(); @@ -1118,7 +1182,7 @@ public final class SettingsFragmentPresenter sl.add(new InputMappingControlSetting(group.getControl(j), controller)); } - if (group.getGroupType() == ControlGroup.TYPE_ATTACHMENTS) + if (groupType == ControlGroup.TYPE_ATTACHMENTS) { NumericSetting attachmentSetting = group.getAttachmentSetting(); sl.add(new SingleChoiceSetting(mContext, new InputMappingIntSetting(attachmentSetting), diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index a1c7a32f95..ea3942cdcb 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -21,6 +21,10 @@ Wii Remote Extension 3 Wii Remote Extension 4 + Wii Remote + General and Options + Motion Simulation + Motion Input Extension Input Binding