mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Merge branch 'dolphin-emu:master' into master
This commit is contained in:
commit
a800e8a381
@ -30,7 +30,11 @@ class EmulatedController private constructor(private val pointer: Long) {
|
|||||||
|
|
||||||
external fun saveProfile(path: String)
|
external fun saveProfile(path: String)
|
||||||
|
|
||||||
external fun getProfileName(): String
|
external fun getProfileKey(): String
|
||||||
|
|
||||||
|
external fun getUserProfileDirectoryPath(): String
|
||||||
|
|
||||||
|
external fun getSysProfileDirectoryPath(): String
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -101,11 +101,11 @@ class ProfileDialogPresenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getProfileDirectoryPath(stock: Boolean): String {
|
private fun getProfileDirectoryPath(stock: Boolean): String {
|
||||||
val profileDirectoryName = menuTag.correspondingEmulatedController.getProfileName()
|
val controller = menuTag.correspondingEmulatedController
|
||||||
return if (stock) {
|
return if (stock) {
|
||||||
"${DirectoryInitialization.getSysDirectory()}/Profiles/$profileDirectoryName/"
|
controller.getSysProfileDirectoryPath()
|
||||||
} else {
|
} else {
|
||||||
"${DirectoryInitialization.getUserDirectory()}/Config/Profiles/$profileDirectoryName/"
|
controller.getUserProfileDirectoryPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2237,7 +2237,7 @@ class SettingsFragmentPresenter(
|
|||||||
controllerNumber: Int
|
controllerNumber: Int
|
||||||
) {
|
) {
|
||||||
val profiles = ProfileDialogPresenter(menuTag).getProfileNames(false)
|
val profiles = ProfileDialogPresenter(menuTag).getProfileNames(false)
|
||||||
val profileKey = controller.getProfileName() + "Profile" + (controllerNumber + 1)
|
val profileKey = controller.getProfileKey() + "Profile" + (controllerNumber + 1)
|
||||||
sl.add(
|
sl.add(
|
||||||
StringSingleChoiceSetting(
|
StringSingleChoiceSetting(
|
||||||
context,
|
context,
|
||||||
|
@ -126,10 +126,26 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileName(
|
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileKey(
|
||||||
JNIEnv* env, jobject obj)
|
JNIEnv* env, jobject obj)
|
||||||
{
|
{
|
||||||
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileName());
|
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getUserProfileDirectoryPath(
|
||||||
|
JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return ToJString(
|
||||||
|
env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetUserProfileDirectoryPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getSysProfileDirectoryPath(
|
||||||
|
JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return ToJString(env,
|
||||||
|
EmulatedControllerFromJava(env, obj)->GetConfig()->GetSysProfileDirectoryPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL
|
JNIEXPORT jobject JNICALL
|
||||||
|
@ -312,7 +312,8 @@ void FreeLookController::UpdateInput(CameraControllerInput* camera_controller)
|
|||||||
|
|
||||||
namespace FreeLook
|
namespace FreeLook
|
||||||
{
|
{
|
||||||
static InputConfig s_config("FreeLookController", _trans("FreeLook"), "FreeLookController");
|
static InputConfig s_config("FreeLookController", _trans("FreeLook"), "FreeLookController",
|
||||||
|
"FreeLookController");
|
||||||
InputConfig* GetInputConfig()
|
InputConfig* GetInputConfig()
|
||||||
{
|
{
|
||||||
return &s_config;
|
return &s_config;
|
||||||
@ -336,12 +337,12 @@ void Initialize()
|
|||||||
|
|
||||||
FreeLook::GetConfig().Refresh();
|
FreeLook::GetConfig().Refresh();
|
||||||
|
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadInputConfig()
|
void LoadInputConfig()
|
||||||
{
|
{
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsInitialized()
|
bool IsInitialized()
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace Pad
|
namespace Pad
|
||||||
{
|
{
|
||||||
static InputConfig s_config("GBA", _trans("Pad"), "GBA");
|
static InputConfig s_config("GBA", _trans("Pad"), "GBA", "GBA");
|
||||||
InputConfig* GetGBAConfig()
|
InputConfig* GetGBAConfig()
|
||||||
{
|
{
|
||||||
return &s_config;
|
return &s_config;
|
||||||
@ -34,12 +34,12 @@ void InitializeGBA()
|
|||||||
s_config.RegisterHotplugCallback();
|
s_config.RegisterHotplugCallback();
|
||||||
|
|
||||||
// Load the saved controller config
|
// Load the saved controller config
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GBA);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGBAConfig()
|
void LoadGBAConfig()
|
||||||
{
|
{
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GBA);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsGBAInitialized()
|
bool IsGBAInitialized()
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace Keyboard
|
namespace Keyboard
|
||||||
{
|
{
|
||||||
static InputConfig s_config("GCKeyNew", _trans("Keyboard"), "GCKey");
|
static InputConfig s_config("GCKeyNew", _trans("Keyboard"), "GCKey", "GCKey");
|
||||||
InputConfig* GetConfig()
|
InputConfig* GetConfig()
|
||||||
{
|
{
|
||||||
return &s_config;
|
return &s_config;
|
||||||
@ -41,12 +41,12 @@ void Initialize()
|
|||||||
s_config.RegisterHotplugCallback();
|
s_config.RegisterHotplugCallback();
|
||||||
|
|
||||||
// Load the saved controller config
|
// Load the saved controller config
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerEmu::ControlGroup* GetGroup(int port, KeyboardGroup group)
|
ControllerEmu::ControlGroup* GetGroup(int port, KeyboardGroup group)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace Pad
|
namespace Pad
|
||||||
{
|
{
|
||||||
static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad");
|
static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad", "Pad");
|
||||||
InputConfig* GetConfig()
|
InputConfig* GetConfig()
|
||||||
{
|
{
|
||||||
return &s_config;
|
return &s_config;
|
||||||
@ -38,12 +38,12 @@ void Initialize()
|
|||||||
s_config.RegisterHotplugCallback();
|
s_config.RegisterHotplugCallback();
|
||||||
|
|
||||||
// Load the saved controller config
|
// Load the saved controller config
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsInitialized()
|
bool IsInitialized()
|
||||||
|
@ -97,7 +97,7 @@ HIDWiimote* GetHIDWiimoteSource(unsigned int index)
|
|||||||
|
|
||||||
namespace Wiimote
|
namespace Wiimote
|
||||||
{
|
{
|
||||||
static InputConfig s_config(WIIMOTE_INI_NAME, _trans("Wii Remote"), "Wiimote");
|
static InputConfig s_config(WIIMOTE_INI_NAME, _trans("Wii Remote"), "Wiimote", "Wiimote");
|
||||||
|
|
||||||
InputConfig* GetConfig()
|
InputConfig* GetConfig()
|
||||||
{
|
{
|
||||||
@ -206,7 +206,7 @@ void ResetAllWiimotes()
|
|||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
s_config.LoadConfig(InputConfig::InputClass::Wii);
|
s_config.LoadConfig();
|
||||||
s_last_connect_request_counter.fill(0);
|
s_last_connect_request_counter.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ static std::array<u32, NUM_HOTKEY_GROUPS> s_hotkey_down;
|
|||||||
static HotkeyStatus s_hotkey;
|
static HotkeyStatus s_hotkey;
|
||||||
static bool s_enabled;
|
static bool s_enabled;
|
||||||
|
|
||||||
static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys");
|
static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys", "Hotkeys");
|
||||||
|
|
||||||
InputConfig* GetConfig()
|
InputConfig* GetConfig()
|
||||||
{
|
{
|
||||||
@ -304,7 +304,7 @@ void Initialize()
|
|||||||
|
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
s_config.LoadConfig(InputConfig::InputClass::GC);
|
s_config.LoadConfig();
|
||||||
LoadLegacyConfig(s_config.GetController(0));
|
LoadLegacyConfig(s_config.GetController(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,9 +319,8 @@ void MappingWindow::OnSaveProfilePressed()
|
|||||||
if (profile_name.isEmpty())
|
if (profile_name.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::string profile_path = File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR +
|
const std::string profile_path =
|
||||||
m_config->GetProfileName() + "/" + profile_name.toStdString() +
|
m_config->GetUserProfileDirectoryPath() + profile_name.toStdString() + ".ini";
|
||||||
".ini";
|
|
||||||
|
|
||||||
File::CreateFullPath(profile_path);
|
File::CreateFullPath(profile_path);
|
||||||
|
|
||||||
@ -487,8 +486,7 @@ void MappingWindow::PopulateProfileSelection()
|
|||||||
{
|
{
|
||||||
m_profiles_combo->clear();
|
m_profiles_combo->clear();
|
||||||
|
|
||||||
const std::string profiles_path =
|
const std::string profiles_path = m_config->GetUserProfileDirectoryPath();
|
||||||
File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR + m_config->GetProfileName();
|
|
||||||
for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"}))
|
for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"}))
|
||||||
{
|
{
|
||||||
std::string basename;
|
std::string basename;
|
||||||
@ -499,9 +497,8 @@ void MappingWindow::PopulateProfileSelection()
|
|||||||
|
|
||||||
m_profiles_combo->insertSeparator(m_profiles_combo->count());
|
m_profiles_combo->insertSeparator(m_profiles_combo->count());
|
||||||
|
|
||||||
const std::string builtin_profiles_path =
|
for (const auto& filename :
|
||||||
File::GetSysDirectory() + PROFILES_DIR + m_config->GetProfileName();
|
Common::DoFileSearch({m_config->GetSysProfileDirectoryPath()}, {".ini"}))
|
||||||
for (const auto& filename : Common::DoFileSearch({builtin_profiles_path}, {".ini"}))
|
|
||||||
{
|
{
|
||||||
std::string basename;
|
std::string basename;
|
||||||
SplitPath(filename, nullptr, &basename, nullptr);
|
SplitPath(filename, nullptr, &basename, nullptr);
|
||||||
|
@ -20,57 +20,40 @@
|
|||||||
#include "InputCommon/InputProfile.h"
|
#include "InputCommon/InputProfile.h"
|
||||||
|
|
||||||
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
|
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||||
const std::string& profile_name)
|
const std::string& profile_directory_name, const std::string& profile_key)
|
||||||
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name)
|
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_directory_name(profile_directory_name),
|
||||||
|
m_profile_key(profile_key)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InputConfig::~InputConfig() = default;
|
InputConfig::~InputConfig() = default;
|
||||||
|
|
||||||
bool InputConfig::LoadConfig(InputClass type)
|
bool InputConfig::LoadConfig()
|
||||||
{
|
{
|
||||||
Common::IniFile inifile;
|
Common::IniFile inifile;
|
||||||
bool useProfile[MAX_BBMOTES] = {false, false, false, false, false};
|
bool useProfile[MAX_BBMOTES] = {false, false, false, false, false};
|
||||||
static constexpr std::array<std::string_view, MAX_BBMOTES> num = {"1", "2", "3", "4", "BB"};
|
static constexpr std::array<std::string_view, MAX_BBMOTES> num = {"1", "2", "3", "4", "BB"};
|
||||||
std::string profile[MAX_BBMOTES];
|
std::string profile[MAX_BBMOTES];
|
||||||
std::string path;
|
|
||||||
|
|
||||||
m_dynamic_input_tex_config_manager.Load();
|
m_dynamic_input_tex_config_manager.Load();
|
||||||
|
|
||||||
if (SConfig::GetInstance().GetGameID() != "00000000")
|
if (SConfig::GetInstance().GetGameID() != "00000000")
|
||||||
{
|
{
|
||||||
std::string type_str;
|
const std::string profile_directory = GetUserProfileDirectoryPath();
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case InputClass::GBA:
|
|
||||||
type_str = "GBA";
|
|
||||||
path = "Profiles/GBA/";
|
|
||||||
break;
|
|
||||||
case InputClass::Wii:
|
|
||||||
type_str = "Wiimote";
|
|
||||||
path = "Profiles/Wiimote/";
|
|
||||||
break;
|
|
||||||
case InputClass::GC:
|
|
||||||
default:
|
|
||||||
type_str = "Pad";
|
|
||||||
path = "Profiles/GCPad/";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni();
|
Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni();
|
||||||
auto* control_section = game_ini.GetOrCreateSection("Controls");
|
auto* control_section = game_ini.GetOrCreateSection("Controls");
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
const auto profile_name = fmt::format("{}Profile{}", type_str, num[i]);
|
const auto profile_name = fmt::format("{}Profile{}", GetProfileKey(), num[i]);
|
||||||
|
|
||||||
if (control_section->Exists(profile_name))
|
if (control_section->Exists(profile_name))
|
||||||
{
|
{
|
||||||
std::string profile_setting;
|
std::string profile_setting;
|
||||||
if (control_section->Get(profile_name, &profile_setting))
|
if (control_section->Get(profile_name, &profile_setting))
|
||||||
{
|
{
|
||||||
auto profiles = InputProfile::GetProfilesFromSetting(
|
auto profiles = InputProfile::GetProfilesFromSetting(profile_setting, profile_directory);
|
||||||
profile_setting, File::GetUserPath(D_CONFIG_IDX) + path);
|
|
||||||
|
|
||||||
if (profiles.empty())
|
if (profiles.empty())
|
||||||
{
|
{
|
||||||
@ -176,6 +159,16 @@ bool InputConfig::ControllersNeedToBeCreated() const
|
|||||||
return m_controllers.empty();
|
return m_controllers.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string InputConfig::GetUserProfileDirectoryPath() const
|
||||||
|
{
|
||||||
|
return fmt::format("{}Profiles/{}/", File::GetUserPath(D_CONFIG_IDX), GetProfileDirectoryName());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string InputConfig::GetSysProfileDirectoryPath() const
|
||||||
|
{
|
||||||
|
return fmt::format("{}Profiles/{}/", File::GetSysDirectory(), GetProfileDirectoryName());
|
||||||
|
}
|
||||||
|
|
||||||
int InputConfig::GetControllerCount() const
|
int InputConfig::GetControllerCount() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(m_controllers.size());
|
return static_cast<int>(m_controllers.size());
|
||||||
|
@ -25,18 +25,11 @@ class InputConfig
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||||
const std::string& profile_name);
|
const std::string& profile_directory_name, const std::string& profile_key);
|
||||||
|
|
||||||
~InputConfig();
|
~InputConfig();
|
||||||
|
|
||||||
enum class InputClass
|
bool LoadConfig();
|
||||||
{
|
|
||||||
GC,
|
|
||||||
Wii,
|
|
||||||
GBA,
|
|
||||||
};
|
|
||||||
|
|
||||||
bool LoadConfig(InputClass type);
|
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
@ -51,7 +44,10 @@ public:
|
|||||||
bool IsControllerControlledByGamepadDevice(int index) const;
|
bool IsControllerControlledByGamepadDevice(int index) const;
|
||||||
|
|
||||||
std::string GetGUIName() const { return m_gui_name; }
|
std::string GetGUIName() const { return m_gui_name; }
|
||||||
std::string GetProfileName() const { return m_profile_name; }
|
std::string GetProfileKey() const { return m_profile_key; }
|
||||||
|
std::string GetProfileDirectoryName() const { return m_profile_directory_name; }
|
||||||
|
std::string GetUserProfileDirectoryPath() const;
|
||||||
|
std::string GetSysProfileDirectoryPath() const;
|
||||||
int GetControllerCount() const;
|
int GetControllerCount() const;
|
||||||
|
|
||||||
// These should be used after creating all controllers and before clearing them, respectively.
|
// These should be used after creating all controllers and before clearing them, respectively.
|
||||||
@ -65,6 +61,7 @@ private:
|
|||||||
std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
|
std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
|
||||||
const std::string m_ini_name;
|
const std::string m_ini_name;
|
||||||
const std::string m_gui_name;
|
const std::string m_gui_name;
|
||||||
const std::string m_profile_name;
|
const std::string m_profile_directory_name;
|
||||||
|
const std::string m_profile_key;
|
||||||
InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager;
|
InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager;
|
||||||
};
|
};
|
||||||
|
@ -55,8 +55,8 @@ std::vector<std::string> GetProfilesFromSetting(const std::string& setting, cons
|
|||||||
|
|
||||||
std::vector<std::string> ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration)
|
std::vector<std::string> ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration)
|
||||||
{
|
{
|
||||||
const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" +
|
const std::string device_profile_root_location(
|
||||||
device_configuration->GetProfileName());
|
device_configuration->GetUserProfileDirectoryPath());
|
||||||
return Common::DoFileSearch({device_profile_root_location}, {".ini"}, true);
|
return Common::DoFileSearch({device_profile_root_location}, {".ini"}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +101,8 @@ ProfileCycler::GetMatchingProfilesFromSetting(const std::string& setting,
|
|||||||
const std::vector<std::string>& profiles,
|
const std::vector<std::string>& profiles,
|
||||||
InputConfig* device_configuration)
|
InputConfig* device_configuration)
|
||||||
{
|
{
|
||||||
const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" +
|
const std::string device_profile_root_location(
|
||||||
device_configuration->GetProfileName() + "/");
|
device_configuration->GetUserProfileDirectoryPath());
|
||||||
|
|
||||||
const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_profile_root_location);
|
const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_profile_root_location);
|
||||||
if (profiles_from_setting.empty())
|
if (profiles_from_setting.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user