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
commit ac53766058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)

View File

@ -118,6 +118,11 @@ std::string FreeLookController::GetName() const
return std::string("FreeLook") + char('1' + m_index);
}
InputConfig* FreeLookController::GetConfig() const
{
return FreeLook::GetInputConfig();
}
void FreeLookController::LoadDefaults(const ControllerInterface& ciface)
{
EmulatedController::LoadDefaults(ciface);

View File

@ -47,6 +47,7 @@ public:
explicit FreeLookController(unsigned int index);
std::string GetName() const override;
InputConfig* GetConfig() const override;
void LoadDefaults(const ControllerInterface& ciface) override;
ControllerEmu::ControlGroup* GetGroup(FreeLookGroup group) const;

View File

@ -5,6 +5,8 @@
#include <fmt/format.h>
#include "Core/HW/GBAPad.h"
#include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/GCPadStatus.h"
@ -43,6 +45,11 @@ std::string GBAPad::GetName() const
return fmt::format("GBA{}", m_index + 1);
}
InputConfig* GBAPad::GetConfig() const
{
return Pad::GetGBAConfig();
}
ControllerEmu::ControlGroup* GBAPad::GetGroup(GBAPadGroup group) const
{
switch (group)

View File

@ -29,6 +29,8 @@ public:
std::string GetName() const override;
InputConfig* GetConfig() const override;
ControllerEmu::ControlGroup* GetGroup(GBAPadGroup group) const;
void LoadDefaults(const ControllerInterface& ciface) override;

View File

@ -5,6 +5,9 @@
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Core/HW/GCKeyboard.h"
#include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
@ -84,6 +87,11 @@ std::string GCKeyboard::GetName() const
return std::string("GCKeyboard") + char('1' + m_index);
}
InputConfig* GCKeyboard::GetConfig() const
{
return Keyboard::GetConfig();
}
ControllerEmu::ControlGroup* GCKeyboard::GetGroup(KeyboardGroup group)
{
switch (group)

View File

@ -31,6 +31,7 @@ public:
explicit GCKeyboard(unsigned int index);
KeyboardStatus GetInput() const;
std::string GetName() const override;
InputConfig* GetConfig() const override;
ControllerEmu::ControlGroup* GetGroup(KeyboardGroup group);
void LoadDefaults(const ControllerInterface& ciface) override;

View File

@ -8,6 +8,8 @@
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Core/HW/GCPad.h"
#include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/Control/Output.h"
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
@ -15,7 +17,6 @@
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
#include "InputCommon/ControllerEmu/StickGate.h"
#include "InputCommon/GCPadStatus.h"
static const u16 button_bitmasks[] = {
@ -95,6 +96,11 @@ std::string GCPad::GetName() const
return std::string("GCPad") + char('1' + m_index);
}
InputConfig* GCPad::GetConfig() const
{
return Pad::GetConfig();
}
ControllerEmu::ControlGroup* GCPad::GetGroup(PadGroup group)
{
switch (group)

View File

@ -43,6 +43,8 @@ public:
std::string GetName() const override;
InputConfig* GetConfig() const override;
ControllerEmu::ControlGroup* GetGroup(PadGroup group);
void LoadDefaults(const ControllerInterface& ciface) override;

View File

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
#include "Common/Inline.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/Extension/DesiredExtensionState.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
@ -36,6 +37,11 @@ std::string Extension::GetDisplayName() const
return m_display_name;
}
InputConfig* Extension::GetConfig() const
{
return ::Wiimote::GetConfig();
}
None::None() : Extension("None")
{
}

View File

@ -27,6 +27,8 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
InputConfig* GetConfig() const override;
// Used by the wiimote to detect extension changes.
// The normal extensions short this pin so it's always connected,
// but M+ does some tricks with it during activation.

View File

@ -324,6 +324,11 @@ std::string Wiimote::GetName() const
return fmt::format("Wiimote{}", 1 + m_index);
}
InputConfig* Wiimote::GetConfig() const
{
return ::Wiimote::GetConfig();
}
ControllerEmu::ControlGroup* Wiimote::GetWiimoteGroup(WiimoteGroup group) const
{
switch (group)

View File

@ -137,6 +137,9 @@ public:
~Wiimote();
std::string GetName() const override;
InputConfig* GetConfig() const override;
void LoadDefaults(const ControllerInterface& ciface) override;
ControllerEmu::ControlGroup* GetWiimoteGroup(WiimoteGroup group) const;

View File

@ -383,6 +383,11 @@ std::string HotkeyManager::GetName() const
return "Hotkeys";
}
InputConfig* HotkeyManager::GetConfig() const
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyManager::GetInput(HotkeyStatus* kb, bool ignore_focus)
{
const auto lock = GetStateLock();

View File

@ -233,6 +233,7 @@ public:
void GetInput(HotkeyStatus* hk, bool ignore_focus);
std::string GetName() const override;
InputConfig* GetConfig() const override;
ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group) const;
int FindGroupByID(int id) const;
int GetIndexForGroup(int group, int id) const;

View File

@ -19,6 +19,7 @@
#include "InputCommon/ControllerInterface/CoreDevice.h"
class ControllerInterface;
class InputConfig;
constexpr const char* DIRECTION_UP = _trans("Up");
constexpr const char* DIRECTION_DOWN = _trans("Down");
@ -180,6 +181,8 @@ public:
virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() const;
virtual InputConfig* GetConfig() const = 0;
virtual void LoadDefaults(const ControllerInterface& ciface);
virtual void LoadConfig(Common::IniFile::Section* sec, const std::string& base = "");