mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Implement enabling/disabling control groups
All this code for just a single checkbox... Ah well, it has to be done
This commit is contained in:
parent
a78dca5fb0
commit
2113bf5e3a
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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++)
|
||||
{
|
||||
|
@ -585,6 +585,7 @@ It can efficiently compress both junk data and encrypted Wii data.
|
||||
<string name="unavailable_paths">Dolphin does not have permission to access one or more configured paths. Would you like to fix this before starting?</string>
|
||||
|
||||
<!-- Misc -->
|
||||
<string name="enabled">Enabled</string>
|
||||
<string name="pitch">Total Pitch</string>
|
||||
<string name="yaw">Total Yaw</string>
|
||||
<string name="vertical_offset">Vertical Offset</string>
|
||||
|
@ -44,6 +44,27 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_g
|
||||
return static_cast<jint>(GetPointer(env, obj)->type);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getDefaultEnabledValue(
|
||||
JNIEnv* env, jobject obj)
|
||||
{
|
||||
return static_cast<jint>(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<jboolean>(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)
|
||||
|
Loading…
Reference in New Issue
Block a user