diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java new file mode 100644 index 0000000000..95aa080429 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControlGroupEnabledSetting.java @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.input.model; + +import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup; +import org.dolphinemu.dolphinemu.features.settings.model.AbstractBooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.Settings; + +public class ControlGroupEnabledSetting implements AbstractBooleanSetting +{ + private final ControlGroup mControlGroup; + + public ControlGroupEnabledSetting(ControlGroup controlGroup) + { + mControlGroup = controlGroup; + } + + @Override + public boolean getBoolean(Settings settings) + { + return mControlGroup.getEnabled(); + } + + @Override + public void setBoolean(Settings settings, boolean newValue) + { + mControlGroup.setEnabled(newValue); + } + + @Override + public boolean isOverridden(Settings settings) + { + return false; + } + + @Override + public boolean isRuntimeEditable() + { + return true; + } + + @Override + public boolean delete(Settings settings) + { + boolean newValue = mControlGroup.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_NO; + mControlGroup.setEnabled(newValue); + + return true; + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java index 0a7681af6d..1bafd4a1f2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/ControlGroup.java @@ -27,6 +27,10 @@ public class ControlGroup public static final int TYPE_IMU_GYROSCOPE = 12; public static final int TYPE_IMU_CURSOR = 13; + public static final int DEFAULT_ENABLED_ALWAYS = 0; + public static final int DEFAULT_ENABLED_YES = 1; + public static final int DEFAULT_ENABLED_NO = 2; + @Keep private final long mPointer; @@ -40,6 +44,12 @@ public class ControlGroup public native int getGroupType(); + public native int getDefaultEnabledValue(); + + public native boolean getEnabled(); + + public native void setEnabled(boolean value); + public native int getControlCount(); public native Control getControl(int i); 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 f731a3426f..8ace1df30b 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 @@ -19,6 +19,7 @@ import org.dolphinemu.dolphinemu.features.input.model.InputMappingBooleanSetting import org.dolphinemu.dolphinemu.features.input.model.InputMappingDoubleSetting; import org.dolphinemu.dolphinemu.features.input.model.InputMappingIntSetting; import org.dolphinemu.dolphinemu.features.input.model.controlleremu.ControlGroup; +import org.dolphinemu.dolphinemu.features.input.model.ControlGroupEnabledSetting; import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController; import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting; import org.dolphinemu.dolphinemu.features.input.model.view.InputMappingControlSetting; @@ -1178,6 +1179,12 @@ public final class SettingsFragmentPresenter sl.add(new HeaderSetting(group.getUiName(), "")); + if (group.getDefaultEnabledValue() != ControlGroup.DEFAULT_ENABLED_ALWAYS) + { + sl.add(new SwitchSetting(mContext, new ControlGroupEnabledSetting(group), R.string.enabled, + 0)); + } + int controlCount = group.getControlCount(); for (int j = 0; j < controlCount; j++) { diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 4fd30b59fb..7099a1e33f 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -585,6 +585,7 @@ It can efficiently compress both junk data and encrypted Wii data. Dolphin does not have permission to access one or more configured paths. Would you like to fix this before starting? + Enabled Total Pitch Total Yaw Vertical Offset diff --git a/Source/Android/jni/Input/ControlGroup.cpp b/Source/Android/jni/Input/ControlGroup.cpp index 0b69145b36..045ab1b519 100644 --- a/Source/Android/jni/Input/ControlGroup.cpp +++ b/Source/Android/jni/Input/ControlGroup.cpp @@ -44,6 +44,27 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_g return static_cast(GetPointer(env, obj)->type); } +JNIEXPORT jint JNICALL +Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getDefaultEnabledValue( + JNIEnv* env, jobject obj) +{ + return static_cast(GetPointer(env, obj)->default_value); +} + +JNIEXPORT jboolean JNICALL +Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getEnabled( + JNIEnv* env, jobject obj) +{ + return static_cast(GetPointer(env, obj)->enabled); +} + +JNIEXPORT void JNICALL +Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_setEnabled( + JNIEnv* env, jobject obj, jboolean value) +{ + GetPointer(env, obj)->enabled = value; +} + JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getControlCount( JNIEnv* env, jobject obj)