Merge pull request #12215 from JosJuice/android-si-devices

Android: Add more GameCube controller types
This commit is contained in:
Mai
2023-11-28 19:21:29 +01:00
committed by GitHub
21 changed files with 141 additions and 37 deletions

View File

@ -30,10 +30,15 @@ class EmulatedController private constructor(private val pointer: Long) {
external fun saveProfile(path: String)
external fun getProfileName(): String
companion object {
@JvmStatic
external fun getGcPad(controllerIndex: Int): EmulatedController
@JvmStatic
external fun getGcKeyboard(controllerIndex: Int): EmulatedController
@JvmStatic
external fun getWiimote(controllerIndex: Int): EmulatedController

View File

@ -100,15 +100,14 @@ class ProfileDialogPresenter {
.show()
}
private val profileDirectoryName: String
get() = if (menuTag.isGCPadMenu) "GCPad" else if (menuTag.isWiimoteMenu) "Wiimote" else throw UnsupportedOperationException()
private fun getProfileDirectoryPath(stock: Boolean): String =
if (stock) {
private fun getProfileDirectoryPath(stock: Boolean): String {
val profileDirectoryName = menuTag.correspondingEmulatedController.getProfileName()
return if (stock) {
"${DirectoryInitialization.getSysDirectory()}/Profiles/$profileDirectoryName/"
} else {
"${DirectoryInitialization.getUserDirectory()}/Config/Profiles/$profileDirectoryName/"
}
}
private fun getProfilePath(profileName: String, stock: Boolean): String =
getProfileDirectoryPath(stock) + profileName + EXTENSION

View File

@ -2079,34 +2079,49 @@ class SettingsFragmentPresenter(
}
private fun addGcPadSubSettings(sl: ArrayList<SettingsItem>, gcPadNumber: Int, gcPadType: Int) {
if (gcPadType == 6) {
// Emulated
val gcPad = EmulatedController.getGcPad(gcPadNumber)
when (gcPadType) {
6, 8, 9, 10 -> {
// Emulated
val gcPad = EmulatedController.getGcPad(gcPadNumber)
if (!TextUtils.isEmpty(gameId)) {
addControllerPerGameSettings(sl, "Pad", gcPadNumber)
} else {
addControllerMetaSettings(sl, gcPad)
addControllerMappingSettings(sl, gcPad, null)
if (!TextUtils.isEmpty(gameId)) {
addControllerPerGameSettings(sl, gcPad, gcPadNumber)
} else {
addControllerMetaSettings(sl, gcPad)
addControllerMappingSettings(sl, gcPad, null)
}
}
} else if (gcPadType == 12) {
// Adapter
sl.add(
SwitchSetting(
context,
BooleanSetting.getSettingForAdapterRumble(gcPadNumber),
R.string.gc_adapter_rumble,
R.string.gc_adapter_rumble_description
7 -> {
// Emulated keyboard controller
val gcKeyboard = EmulatedController.getGcKeyboard(gcPadNumber)
if (!TextUtils.isEmpty(gameId)) {
addControllerPerGameSettings(sl, gcKeyboard, gcPadNumber)
} else {
sl.add(HeaderSetting(context, R.string.keyboard_controller_warning, 0))
addControllerMetaSettings(sl, gcKeyboard)
addControllerMappingSettings(sl, gcKeyboard, null)
}
}
12 -> {
// Adapter
sl.add(
SwitchSetting(
context,
BooleanSetting.getSettingForAdapterRumble(gcPadNumber),
R.string.gc_adapter_rumble,
R.string.gc_adapter_rumble_description
)
)
)
sl.add(
SwitchSetting(
context,
BooleanSetting.getSettingForSimulateKonga(gcPadNumber),
R.string.gc_adapter_bongos,
R.string.gc_adapter_bongos_description
sl.add(
SwitchSetting(
context,
BooleanSetting.getSettingForSimulateKonga(gcPadNumber),
R.string.gc_adapter_bongos,
R.string.gc_adapter_bongos_description
)
)
)
}
}
}
@ -2114,7 +2129,7 @@ class SettingsFragmentPresenter(
val wiimote = EmulatedController.getWiimote(wiimoteNumber)
if (!TextUtils.isEmpty(gameId)) {
addControllerPerGameSettings(sl, "Wiimote", wiimoteNumber)
addControllerPerGameSettings(sl, wiimote, wiimoteNumber)
} else {
addControllerMetaSettings(sl, wiimote)
@ -2210,11 +2225,11 @@ class SettingsFragmentPresenter(
*/
private fun addControllerPerGameSettings(
sl: ArrayList<SettingsItem>,
profileString: String,
controller: EmulatedController,
controllerNumber: Int
) {
val profiles = ProfileDialogPresenter(menuTag).getProfileNames(false)
val profileKey = profileString + "Profile" + (controllerNumber + 1)
val profileKey = controller.getProfileName() + "Profile" + (controllerNumber + 1)
sl.add(
StringSingleChoiceSetting(
context,

View File

@ -367,11 +367,19 @@
<string-array name="gcpadTypeEntries">
<item>@string/gcpad_disabled</item>
<item>@string/gcpad_emulated</item>
<item>@string/gcpad_keyboard</item>
<item>@string/gcpad_steering_wheel</item>
<item>@string/gcpad_dance_mat</item>
<item>@string/gcpad_taru_konga</item>
<item>@string/gcpad_gc_adapter</item>
</string-array>
<integer-array name="gcpadTypeValues">
<item>0</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>12</item>
</integer-array>

View File

@ -47,6 +47,7 @@
<string name="input_clear">Clear</string>
<string name="input_clear_description">Clear settings for this controller.</string>
<string name="input_reset_warning">Are you sure? Your current controller settings will be deleted.</string>
<string name="keyboard_controller_warning">"You are configuring a \"Keyboard Controller\". This device is exclusively for \"Phantasy Star Online Episode I &amp; II\". If you are unsure, turn back now and configure a \"Standard Controller\".</string>
<string name="old_controller_settings">Your controller settings are from an old version of Dolphin and won\'t work in this version. Press \"Default\" to start over with new settings.</string>
<string name="input_binding">Input Binding</string>
@ -773,13 +774,17 @@ It can efficiently compress both junk data and encrypted Wii data.
<string name="country_unknown">Unknown</string>
<!-- GameCube Gamepad Types -->
<string name="gcpad_disabled">Disabled</string>
<string name="gcpad_emulated">Emulated</string>
<string name="gcpad_disabled">None</string>
<string name="gcpad_emulated">Standard Controller</string>
<string name="gcpad_keyboard">Keyboard Controller</string>
<string name="gcpad_steering_wheel">Steering Wheel</string>
<string name="gcpad_dance_mat">Dance Mat</string>
<string name="gcpad_taru_konga">DK Bongos</string>
<string name="gcpad_gc_adapter">GameCube Adapter</string>
<!-- Wiimote Types -->
<string name="wiimote_disabled">Disabled</string>
<string name="wiimote_emulated">Emulated</string>
<string name="wiimote_disabled">None</string>
<string name="wiimote_emulated">Emulated Wii Remote</string>
<string name="wiimote_real">Real Wii Remote (DolphinBar required)</string>
<!-- Gamepad Controls -->

View File

@ -5,6 +5,7 @@
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
@ -124,6 +125,13 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
ini.Save(path);
}
JNIEXPORT jstring JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileName(
JNIEnv* env, jobject obj)
{
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileName());
}
JNIEXPORT jobject JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getGcPad(
JNIEnv* env, jclass, jint controller_index)
@ -131,6 +139,13 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
return EmulatedControllerToJava(env, Pad::GetConfig()->GetController(controller_index));
}
JNIEXPORT jobject JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getGcKeyboard(
JNIEnv* env, jclass, jint controller_index)
{
return EmulatedControllerToJava(env, Keyboard::GetConfig()->GetController(controller_index));
}
JNIEXPORT jobject JNICALL
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getWiimote(
JNIEnv* env, jclass, jint controller_index)