mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Android: Get profile name from core
To avoid duplicating information between Kotlin and C++.
This commit is contained in:
parent
b2e016f012
commit
d6c0f8e749
@ -30,6 +30,8 @@ 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
|
||||
|
@ -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
|
||||
|
@ -2076,7 +2076,7 @@ class SettingsFragmentPresenter(
|
||||
val gcPad = EmulatedController.getGcPad(gcPadNumber)
|
||||
|
||||
if (!TextUtils.isEmpty(gameId)) {
|
||||
addControllerPerGameSettings(sl, "Pad", gcPadNumber)
|
||||
addControllerPerGameSettings(sl, gcPad, gcPadNumber)
|
||||
} else {
|
||||
addControllerMetaSettings(sl, gcPad)
|
||||
addControllerMappingSettings(sl, gcPad, null)
|
||||
@ -2106,7 +2106,7 @@ class SettingsFragmentPresenter(
|
||||
val wiimote = EmulatedController.getWiimote(wiimoteNumber)
|
||||
|
||||
if (!TextUtils.isEmpty(gameId)) {
|
||||
addControllerPerGameSettings(sl, "Wiimote", wiimoteNumber)
|
||||
addControllerPerGameSettings(sl, wiimote, wiimoteNumber)
|
||||
} else {
|
||||
addControllerMetaSettings(sl, wiimote)
|
||||
|
||||
@ -2202,11 +2202,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,
|
||||
|
@ -124,6 +124,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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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")
|
||||
{
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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 = "");
|
||||
|
Loading…
Reference in New Issue
Block a user