Android: Add extension selection
This commit is contained in:
parent
1c26a85e35
commit
0dd8bbbbbb
|
@ -0,0 +1,48 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.input.model;
|
||||
|
||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractIntSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
|
||||
public class InputMappingIntSetting implements AbstractIntSetting
|
||||
{
|
||||
private final NumericSetting mNumericSetting;
|
||||
|
||||
public InputMappingIntSetting(NumericSetting numericSetting)
|
||||
{
|
||||
mNumericSetting = numericSetting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(Settings settings)
|
||||
{
|
||||
return mNumericSetting.getIntValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(Settings settings, int newValue)
|
||||
{
|
||||
mNumericSetting.setIntValue(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOverridden(Settings settings)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRuntimeEditable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(Settings settings)
|
||||
{
|
||||
mNumericSetting.setIntValue(mNumericSetting.getIntDefaultValue());
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,21 @@ import androidx.annotation.Keep;
|
|||
*/
|
||||
public class ControlGroup
|
||||
{
|
||||
public static final int TYPE_OTHER = 0;
|
||||
public static final int TYPE_STICK = 1;
|
||||
public static final int TYPE_MIXED_TRIGGERS = 2;
|
||||
public static final int TYPE_BUTTONS = 3;
|
||||
public static final int TYPE_FORCE = 4;
|
||||
public static final int TYPE_ATTACHMENTS = 5;
|
||||
public static final int TYPE_TILT = 6;
|
||||
public static final int TYPE_CURSOR = 7;
|
||||
public static final int TYPE_TRIGGERS = 8;
|
||||
public static final int TYPE_SLIDER = 9;
|
||||
public static final int TYPE_SHAKE = 10;
|
||||
public static final int TYPE_IMU_ACCELEROMETER = 11;
|
||||
public static final int TYPE_IMU_GYROSCOPE = 12;
|
||||
public static final int TYPE_IMU_CURSOR = 13;
|
||||
|
||||
@Keep
|
||||
private final long mPointer;
|
||||
|
||||
|
@ -23,6 +38,8 @@ public class ControlGroup
|
|||
|
||||
public native String getUiName();
|
||||
|
||||
public native int getGroupType();
|
||||
|
||||
public native int getControlCount();
|
||||
|
||||
public native Control getControl(int i);
|
||||
|
@ -30,4 +47,10 @@ public class ControlGroup
|
|||
public native int getNumericSettingCount();
|
||||
|
||||
public native NumericSetting getNumericSetting(int i);
|
||||
|
||||
/**
|
||||
* If getGroupType returns TYPE_ATTACHMENTS, this returns the attachment selection setting.
|
||||
* Otherwise, undefined behavior!
|
||||
*/
|
||||
public native NumericSetting getAttachmentSetting();
|
||||
}
|
||||
|
|
|
@ -47,6 +47,21 @@ public class NumericSetting
|
|||
|
||||
public native ControlReference getControlReference();
|
||||
|
||||
/**
|
||||
* If the type is TYPE_INT, gets the current value. Otherwise, undefined behavior!
|
||||
*/
|
||||
public native int getIntValue();
|
||||
|
||||
/**
|
||||
* If the type is TYPE_INT, sets the current value. Otherwise, undefined behavior!
|
||||
*/
|
||||
public native void setIntValue(int value);
|
||||
|
||||
/**
|
||||
* If the type is TYPE_INT, gets the default value. Otherwise, undefined behavior!
|
||||
*/
|
||||
public native int getIntDefaultValue();
|
||||
|
||||
/**
|
||||
* If the type is TYPE_DOUBLE, gets the current value. Otherwise, undefined behavior!
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.dolphinemu.dolphinemu.R;
|
|||
import org.dolphinemu.dolphinemu.activities.UserDataActivity;
|
||||
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.controlleremu.EmulatedController;
|
||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
|
||||
|
@ -1117,6 +1118,15 @@ public final class SettingsFragmentPresenter
|
|||
sl.add(new InputMappingControlSetting(group.getControl(j), controller));
|
||||
}
|
||||
|
||||
if (group.getGroupType() == ControlGroup.TYPE_ATTACHMENTS)
|
||||
{
|
||||
NumericSetting attachmentSetting = group.getAttachmentSetting();
|
||||
sl.add(new SingleChoiceSetting(mContext, new InputMappingIntSetting(attachmentSetting),
|
||||
R.string.wiimote_extensions, 0, R.array.wiimoteExtensionsEntries,
|
||||
R.array.wiimoteExtensionsValues,
|
||||
MenuTag.getWiimoteExtensionMenuTag(mControllerNumber)));
|
||||
}
|
||||
|
||||
int numericSettingCount = group.getNumericSettingCount();
|
||||
for (int j = 0; j < numericSettingCount; j++)
|
||||
{
|
||||
|
|
|
@ -210,14 +210,14 @@
|
|||
<item>@string/extension_drums</item>
|
||||
<item>@string/extension_turntable</item>
|
||||
</string-array>
|
||||
<string-array name="wiimoteExtensionsValues">
|
||||
<item>None</item>
|
||||
<item>Nunchuk</item>
|
||||
<item>Classic</item>
|
||||
<item>Guitar</item>
|
||||
<item>Drums</item>
|
||||
<item>Turntable</item>
|
||||
</string-array>
|
||||
<integer-array name="wiimoteExtensionsValues">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Texture Cache Accuracy Preference -->
|
||||
<string-array name="textureCacheAccuracyEntries">
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <jni.h>
|
||||
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||
#include "jni/AndroidCommon/IDCache.h"
|
||||
|
@ -36,6 +37,13 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_g
|
|||
return ToJString(env, Common::GetStringT(GetPointer(env, obj)->ui_name.c_str()));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getGroupType(
|
||||
JNIEnv* env, jobject obj)
|
||||
{
|
||||
return static_cast<jint>(GetPointer(env, obj)->type);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getControlCount(
|
||||
JNIEnv* env, jobject obj)
|
||||
|
@ -63,4 +71,12 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_g
|
|||
{
|
||||
return NumericSettingToJava(env, GetPointer(env, obj)->numeric_settings[i].get());
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_ControlGroup_getAttachmentSetting(
|
||||
JNIEnv* env, jobject obj)
|
||||
{
|
||||
auto* group = reinterpret_cast<ControllerEmu::Attachments*>(GetPointer(env, obj));
|
||||
return NumericSettingToJava(env, &group->GetSelectionSetting());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,27 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_NumericSetting
|
|||
return ControlReferenceToJava(env, &GetPointer(env, obj)->GetInputReference());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_NumericSetting_getIntValue(
|
||||
JNIEnv* env, jobject obj)
|
||||
{
|
||||
return GetPointer<int>(env, obj)->GetValue();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_NumericSetting_setIntValue(
|
||||
JNIEnv* env, jobject obj, jint value)
|
||||
{
|
||||
GetPointer<int>(env, obj)->SetValue(value);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_NumericSetting_getIntDefaultValue(
|
||||
JNIEnv* env, jobject obj)
|
||||
{
|
||||
return GetPointer<int>(env, obj)->GetDefaultValue();
|
||||
}
|
||||
|
||||
JNIEXPORT jdouble JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_NumericSetting_getDoubleValue(
|
||||
JNIEnv* env, jobject obj)
|
||||
|
|
Loading…
Reference in New Issue