Add a toggle to use unified or per-game configs, and add a deadzone example to the default config

This commit is contained in:
kalaposfos13 2025-01-31 16:58:57 +01:00
parent c4bfaa6031
commit e5b0d638fd
3 changed files with 19 additions and 6 deletions

View File

@ -68,6 +68,7 @@ static bool vkGuestMarkers = false;
static bool rdocEnable = false; static bool rdocEnable = false;
static s16 cursorState = HideCursorState::Idle; static s16 cursorState = HideCursorState::Idle;
static int cursorHideTimeout = 5; // 5 seconds (default) static int cursorHideTimeout = 5; // 5 seconds (default)
static bool useUnifiedInputConfig = true;
static bool separateupdatefolder = false; static bool separateupdatefolder = false;
static bool compatibilityData = false; static bool compatibilityData = false;
static bool checkCompatibilityOnStartup = false; static bool checkCompatibilityOnStartup = false;
@ -98,6 +99,14 @@ std::string emulator_language = "en";
// Language // Language
u32 m_language = 1; // english u32 m_language = 1; // english
bool GetUseUnifiedInputConfig() {
return useUnifiedInputConfig;
}
void SetUseUnifiedInputConfig(bool use) {
useUnifiedInputConfig = use;
}
std::string getTrophyKey() { std::string getTrophyKey() {
return trophyKey; return trophyKey;
} }
@ -657,6 +666,7 @@ void load(const std::filesystem::path& path) {
useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false); useSpecialPad = toml::find_or<bool>(input, "useSpecialPad", false);
specialPadClass = toml::find_or<int>(input, "specialPadClass", 1); specialPadClass = toml::find_or<int>(input, "specialPadClass", 1);
isMotionControlsEnabled = toml::find_or<bool>(input, "isMotionControlsEnabled", true); isMotionControlsEnabled = toml::find_or<bool>(input, "isMotionControlsEnabled", true);
useUnifiedInputConfig = toml::find_or<bool>(input, "useUnifiedInputConfig", true);
} }
if (data.contains("GPU")) { if (data.contains("GPU")) {
@ -779,6 +789,7 @@ void save(const std::filesystem::path& path) {
data["Input"]["useSpecialPad"] = useSpecialPad; data["Input"]["useSpecialPad"] = useSpecialPad;
data["Input"]["specialPadClass"] = specialPadClass; data["Input"]["specialPadClass"] = specialPadClass;
data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled; data["Input"]["isMotionControlsEnabled"] = isMotionControlsEnabled;
data["Input"]["useUnifiedInputConfig"] = useUnifiedInputConfig;
data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenWidth"] = screenWidth;
data["GPU"]["screenHeight"] = screenHeight; data["GPU"]["screenHeight"] = screenHeight;
data["GPU"]["nullGpu"] = isNullGpu; data["GPU"]["nullGpu"] = isNullGpu;
@ -969,9 +980,12 @@ touchpad = back
axis_left_x = axis_left_x axis_left_x = axis_left_x
axis_left_y = axis_left_y axis_left_y = axis_left_y
axis_right_x = axis_right_x axis_right_x = axis_right_x
axis_right_y = axis_right_y axis_right_y = axis_right_y
# Range of deadzones: 1 (almost none) to 127 (max)
analog_deadzone = leftjoystick, 2
analog_deadzone = rightjoystick, 2
)"; )";
} }
std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) { std::filesystem::path GetFoolproofKbmConfigFile(const std::string& game_id) {

View File

@ -43,6 +43,8 @@ std::string getBackButtonBehavior();
bool getUseSpecialPad(); bool getUseSpecialPad();
int getSpecialPadClass(); int getSpecialPadClass();
bool getIsMotionControlsEnabled(); bool getIsMotionControlsEnabled();
bool GetUseUnifiedInputConfig();
void SetUseUnifiedInputConfig(bool use);
u32 getScreenWidth(); u32 getScreenWidth();
u32 getScreenHeight(); u32 getScreenHeight();

View File

@ -198,11 +198,8 @@ InputBinding GetBindingFromString(std::string& line) {
} }
void ParseInputConfig(const std::string game_id = "") { void ParseInputConfig(const std::string game_id = "") {
const auto config_file = Config::GetFoolproofKbmConfigFile(game_id); std::string config_file = Config::GetUseUnifiedInputConfig() ? "default" : game_id;
const auto config_file = Config::GetFoolproofKbmConfigFile(config_file);
if (game_id == "") {
return;
}
// we reset these here so in case the user fucks up or doesn't include some of these, // we reset these here so in case the user fucks up or doesn't include some of these,
// we can fall back to default // we can fall back to default