Skip to content

Commit

Permalink
Android: Add more GameCube controller types
Browse files Browse the repository at this point in the history
For all your PSO needs.
  • Loading branch information
JosJuice committed Oct 1, 2023
1 parent d6c0f8e commit d811c12
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 28 deletions.
Expand Up @@ -36,6 +36,9 @@ class EmulatedController private constructor(private val pointer: Long) {
@JvmStatic
external fun getGcPad(controllerIndex: Int): EmulatedController

@JvmStatic
external fun getGcKeyboard(controllerIndex: Int): EmulatedController

@JvmStatic
external fun getWiimote(controllerIndex: Int): EmulatedController

Expand Down
Expand Up @@ -2071,34 +2071,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, gcPad, 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
)
)
)
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Source/Android/app/src/main/res/values/arrays.xml
Expand Up @@ -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>

Expand Down
13 changes: 9 additions & 4 deletions Source/Android/app/src/main/res/values/strings.xml
Expand Up @@ -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>
Expand Down Expand Up @@ -772,13 +773,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 -->
Expand Down
8 changes: 8 additions & 0 deletions Source/Android/jni/Input/EmulatedController.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -138,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)
Expand Down

0 comments on commit d811c12

Please sign in to comment.