mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Android: Add game specific gc/wii controller settings
This commit is contained in:
@ -335,7 +335,7 @@ static void AddBind(const std::string& dev, sBind* bind)
|
||||
m_controllers[dev]->AddBind(bind);
|
||||
}
|
||||
|
||||
void Init()
|
||||
void Init(const std::string& gameId)
|
||||
{
|
||||
// Initialize our touchScreenKey buttons
|
||||
for (int a = 0; a < 8; ++a)
|
||||
@ -592,6 +592,40 @@ void Init()
|
||||
new sBind(padID, configTypes[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + std::string(gameId + ".ini"));
|
||||
for (u32 a = 0; a < configStrings.size(); ++a)
|
||||
{
|
||||
for (int padID = 0; padID < 8; ++padID)
|
||||
{
|
||||
std::ostringstream config;
|
||||
config << configStrings[a] << "_" << padID;
|
||||
BindType type;
|
||||
int bindnum;
|
||||
char dev[128];
|
||||
bool hasbind = false;
|
||||
char modifier = '+';
|
||||
std::string value;
|
||||
ini.GetOrCreateSection("Android")->Get(config.str(), &value, "None");
|
||||
if (value == "None")
|
||||
continue;
|
||||
if (std::string::npos != value.find("Axis"))
|
||||
{
|
||||
hasbind = true;
|
||||
type = BIND_AXIS;
|
||||
sscanf(value.c_str(), "Device '%127[^\']'-Axis %d%c", dev, &bindnum, &modifier);
|
||||
}
|
||||
else if (std::string::npos != value.find("Button"))
|
||||
{
|
||||
hasbind = true;
|
||||
type = BIND_BUTTON;
|
||||
sscanf(value.c_str(), "Device '%127[^\']'-Button %d", dev, &bindnum);
|
||||
}
|
||||
if (hasbind)
|
||||
AddBind(std::string(dev),
|
||||
new sBind(padID, configTypes[a], type, bindnum, modifier == '-' ? -1.0f : 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GetButtonPressed(int padID, ButtonType button)
|
||||
|
@ -250,7 +250,7 @@ public:
|
||||
float AxisValue(int padID, ButtonType axis);
|
||||
};
|
||||
|
||||
void Init();
|
||||
void Init(const std::string&);
|
||||
bool GetButtonPressed(int padID, ButtonType button);
|
||||
float GetAxisValue(int padID, ButtonType axis);
|
||||
bool GamepadEvent(const std::string& dev, int button, int action);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <UICommon/GameFile.h>
|
||||
|
||||
#include "Common/AndroidAnalytics.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
@ -250,8 +251,10 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling
|
||||
jboolean enable);
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env, jobject obj);
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Z(
|
||||
JNIEnv* env, jobject obj, jstring jFile, jboolean jfirstOpen);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z(
|
||||
JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate, jboolean jDeleteSavestate);
|
||||
@ -381,6 +384,29 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetUserSetti
|
||||
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + gameid + ".ini");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfileSetting(
|
||||
JNIEnv* env, jobject obj, jstring jProfile, jstring jSection, jstring jKey, jstring jValue)
|
||||
{
|
||||
IniFile ini;
|
||||
std::string profile = GetJString(env, jProfile);
|
||||
std::string section = GetJString(env, jSection);
|
||||
std::string key = GetJString(env, jKey);
|
||||
std::string val = GetJString(env, jValue);
|
||||
|
||||
ini.Load(File::GetUserPath(D_CONFIG_IDX) + "Profiles/Wiimote/" + profile + ".ini");
|
||||
|
||||
if (val != "-1")
|
||||
{
|
||||
ini.GetOrCreateSection(section)->Set(key, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
ini.GetOrCreateSection(section)->Delete(key);
|
||||
}
|
||||
|
||||
ini.Save(File::GetUserPath(D_CONFIG_IDX) + "Profiles/Wiimote/" + profile + ".ini");
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig(
|
||||
JNIEnv* env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jDefault)
|
||||
{
|
||||
@ -539,7 +565,6 @@ static void Run(const std::string& path, bool first_open,
|
||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", path.c_str());
|
||||
|
||||
// Install our callbacks
|
||||
OSD::AddCallback(OSD::CallbackType::Initialization, ButtonManager::Init);
|
||||
OSD::AddCallback(OSD::CallbackType::Shutdown, ButtonManager::Shutdown);
|
||||
|
||||
RegisterMsgAlertHandler(&MsgAlert);
|
||||
@ -563,6 +588,7 @@ static void Run(const std::string& path, bool first_open,
|
||||
WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf);
|
||||
if (BootManager::BootCore(std::move(boot), wsi))
|
||||
{
|
||||
ButtonManager::Init(SConfig::GetInstance().GetGameID());
|
||||
static constexpr int TIMEOUT = 10000;
|
||||
static constexpr int WAIT_STEP = 25;
|
||||
int time_waited = 0;
|
||||
|
Reference in New Issue
Block a user