From 69dd59d9b9ccf872a1e8152028b2df6fc0138c4a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 16 Jun 2018 22:14:41 -0700 Subject: [PATCH] UI: Refactor touch control config handling. Much cleaner this way, less repetition. --- Core/Config.cpp | 203 +++++++---------- Core/Config.h | 72 ++---- UI/GamepadEmu.cpp | 326 +++++++++------------------- UI/TouchControlLayoutScreen.cpp | 64 +++--- UI/TouchControlVisibilityScreen.cpp | 24 +- 5 files changed, 252 insertions(+), 437 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 810b9102b7..a0cd76f37f 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -64,6 +64,7 @@ struct ConfigSetting { TYPE_UINT32, TYPE_FLOAT, TYPE_STRING, + TYPE_TOUCH_POS, }; union Value { bool b; @@ -71,6 +72,7 @@ struct ConfigSetting { uint32_t u; float f; const char *s; + ConfigTouchPos touchPos; }; union SettingPtr { bool *b; @@ -78,6 +80,7 @@ struct ConfigSetting { uint32_t *u; float *f; std::string *s; + ConfigTouchPos *touchPos; }; typedef bool (*BoolDefaultCallback)(); @@ -85,6 +88,7 @@ struct ConfigSetting { typedef uint32_t (*Uint32DefaultCallback)(); typedef float (*FloatDefaultCallback)(); typedef const char *(*StringDefaultCallback)(); + typedef ConfigTouchPos (*TouchPosDefaultCallback)(); union Callback { BoolDefaultCallback b; @@ -92,6 +96,7 @@ struct ConfigSetting { Uint32DefaultCallback u; FloatDefaultCallback f; StringDefaultCallback s; + TouchPosDefaultCallback touchPos; }; ConfigSetting(bool v) @@ -135,6 +140,13 @@ struct ConfigSetting { default_.s = def; } + ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, ConfigTouchPos def, bool save = true, bool perGame = false) + : ini_(iniX), ini2_(iniY), ini3_(iniScale), ini4_(iniShow), type_(TYPE_TOUCH_POS), report_(false), save_(save), perGame_(perGame) { + ptr_.touchPos = v; + cb_.touchPos = nullptr; + default_.touchPos = def; + } + ConfigSetting(const char *ini, bool *v, BoolDefaultCallback def, bool save = true, bool perGame = false) : ini_(ini), type_(TYPE_BOOL), report_(false), save_(save), perGame_(perGame) { ptr_.b = v; @@ -165,6 +177,12 @@ struct ConfigSetting { cb_.s = def; } + ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, TouchPosDefaultCallback def, bool save = true, bool perGame = false) + : ini_(iniX), ini2_(iniY), ini3_(iniScale), ini4_(iniShow), type_(TYPE_TOUCH_POS), report_(false), save_(save), perGame_(perGame) { + ptr_.touchPos = v; + cb_.touchPos = def; + } + bool HasMore() const { return type_ != TYPE_TERMINATOR; } @@ -196,6 +214,19 @@ struct ConfigSetting { default_.s = cb_.s(); } return section->Get(ini_, ptr_.s, default_.s); + case TYPE_TOUCH_POS: + if (cb_.touchPos) { + default_.touchPos = cb_.touchPos(); + } + section->Get(ini_, &ptr_.touchPos->x, default_.touchPos.x); + section->Get(ini2_, &ptr_.touchPos->y, default_.touchPos.y); + section->Get(ini3_, &ptr_.touchPos->scale, default_.touchPos.scale); + if (ini4_) { + section->Get(ini4_, &ptr_.touchPos->show, default_.touchPos.show); + } else { + ptr_.touchPos->show = default_.touchPos.show; + } + return true; default: _dbg_assert_msg_(LOADER, false, "Unexpected ini setting type"); return false; @@ -217,6 +248,14 @@ struct ConfigSetting { return section->Set(ini_, *ptr_.f); case TYPE_STRING: return section->Set(ini_, *ptr_.s); + case TYPE_TOUCH_POS: + section->Set(ini_, ptr_.touchPos->x); + section->Set(ini2_, ptr_.touchPos->y); + section->Set(ini3_, ptr_.touchPos->scale); + if (ini4_) { + section->Set(ini4_, ptr_.touchPos->show); + } + return; default: _dbg_assert_msg_(LOADER, false, "Unexpected ini setting type"); return; @@ -238,6 +277,9 @@ struct ConfigSetting { return data.Add(prefix + ini_, *ptr_.f); case TYPE_STRING: return data.Add(prefix + ini_, *ptr_.s); + case TYPE_TOUCH_POS: + // Doesn't report. + return; default: _dbg_assert_msg_(LOADER, false, "Unexpected ini setting type"); return; @@ -245,6 +287,9 @@ struct ConfigSetting { } const char *ini_; + const char *ini2_; + const char *ini3_; + const char *ini4_; Type type_; bool report_; bool save_; @@ -612,6 +657,8 @@ static bool DefaultShowTouchControls() { } static const float defaultControlScale = 1.15f; +static const ConfigTouchPos defaultTouchPosShow = { -1.0f, -1.0f, defaultControlScale, true }; +static const ConfigTouchPos defaultTouchPosHide = { -1.0f, -1.0f, defaultControlScale, false }; static ConfigSetting controlSettings[] = { ConfigSetting("HapticFeedback", &g_Config.bHapticFeedback, false, true, true), @@ -619,19 +666,7 @@ static ConfigSetting controlSettings[] = { ConfigSetting("ShowTouchCircle", &g_Config.bShowTouchCircle, true, true, true), ConfigSetting("ShowTouchSquare", &g_Config.bShowTouchSquare, true, true, true), ConfigSetting("ShowTouchTriangle", &g_Config.bShowTouchTriangle, true, true, true), - ConfigSetting("ShowTouchStart", &g_Config.bShowTouchStart, true, true, true), - ConfigSetting("ShowTouchSelect", &g_Config.bShowTouchSelect, true, true, true), - ConfigSetting("ShowTouchLTrigger", &g_Config.bShowTouchLTrigger, true, true, true), - ConfigSetting("ShowTouchRTrigger", &g_Config.bShowTouchRTrigger, true, true, true), - ConfigSetting("ShowAnalogStick", &g_Config.bShowTouchAnalogStick, true, true, true), - ConfigSetting("ShowTouchDpad", &g_Config.bShowTouchDpad, true, true, true), - ConfigSetting("ShowTouchUnthrottle", &g_Config.bShowTouchUnthrottle, true, true, true), - ConfigSetting("ShowComboKey0", &g_Config.bShowComboKey0, false, true, true), - ConfigSetting("ShowComboKey1", &g_Config.bShowComboKey1, false, true, true), - ConfigSetting("ShowComboKey2", &g_Config.bShowComboKey2, false, true, true), - ConfigSetting("ShowComboKey3", &g_Config.bShowComboKey3, false, true, true), - ConfigSetting("ShowComboKey4", &g_Config.bShowComboKey4, false, true, true), ConfigSetting("ComboKey0Mapping", &g_Config.iCombokey0, 0, true, true), ConfigSetting("ComboKey1Mapping", &g_Config.iCombokey1, 0, true, true), ConfigSetting("ComboKey2Mapping", &g_Config.iCombokey2, 0, true, true), @@ -671,49 +706,24 @@ static ConfigSetting controlSettings[] = { // -1.0f means uninitialized, set in GamepadEmu::CreatePadLayout(). ConfigSetting("ActionButtonSpacing2", &g_Config.fActionButtonSpacing, 1.0f, true, true), - ConfigSetting("ActionButtonCenterX", &g_Config.fActionButtonCenterX, -1.0f, true, true), - ConfigSetting("ActionButtonCenterY", &g_Config.fActionButtonCenterY, -1.0f, true, true), - ConfigSetting("ActionButtonScale", &g_Config.fActionButtonScale, defaultControlScale, true, true), - ConfigSetting("DPadX", &g_Config.fDpadX, -1.0f, true, true), - ConfigSetting("DPadY", &g_Config.fDpadY, -1.0f, true, true), + ConfigSetting("ActionButtonCenterX", "ActionButtonCenterY", "ActionButtonScale", nullptr, &g_Config.touchActionButtonCenter, defaultTouchPosShow, true, true), + ConfigSetting("DPadX", "DPadY", "DPadScale", "ShowTouchDpad", &g_Config.touchDpad, defaultTouchPosShow, true, true), // Note: these will be overwritten if DPadRadius is set. - ConfigSetting("DPadScale", &g_Config.fDpadScale, defaultControlScale, true, true), ConfigSetting("DPadSpacing", &g_Config.fDpadSpacing, 1.0f, true, true), - ConfigSetting("StartKeyX", &g_Config.fStartKeyX, -1.0f, true, true), - ConfigSetting("StartKeyY", &g_Config.fStartKeyY, -1.0f, true, true), - ConfigSetting("StartKeyScale", &g_Config.fStartKeyScale, defaultControlScale, true, true), - ConfigSetting("SelectKeyX", &g_Config.fSelectKeyX, -1.0f, true, true), - ConfigSetting("SelectKeyY", &g_Config.fSelectKeyY, -1.0f, true, true), - ConfigSetting("SelectKeyScale", &g_Config.fSelectKeyScale, defaultControlScale, true, true), - ConfigSetting("UnthrottleKeyX", &g_Config.fUnthrottleKeyX, -1.0f, true, true), - ConfigSetting("UnthrottleKeyY", &g_Config.fUnthrottleKeyY, -1.0f, true, true), - ConfigSetting("UnthrottleKeyScale", &g_Config.fUnthrottleKeyScale, defaultControlScale, true, true), - ConfigSetting("LKeyX", &g_Config.fLKeyX, -1.0f, true, true), - ConfigSetting("LKeyY", &g_Config.fLKeyY, -1.0f, true, true), - ConfigSetting("LKeyScale", &g_Config.fLKeyScale, defaultControlScale, true, true), - ConfigSetting("RKeyX", &g_Config.fRKeyX, -1.0f, true, true), - ConfigSetting("RKeyY", &g_Config.fRKeyY, -1.0f, true, true), - ConfigSetting("RKeyScale", &g_Config.fRKeyScale, defaultControlScale, true, true), - ConfigSetting("AnalogStickX", &g_Config.fAnalogStickX, -1.0f, true, true), - ConfigSetting("AnalogStickY", &g_Config.fAnalogStickY, -1.0f, true, true), - ConfigSetting("AnalogStickScale", &g_Config.fAnalogStickScale, defaultControlScale, true, true), + ConfigSetting("StartKeyX", "StartKeyY", "StartKeyScale", "ShowTouchStart", &g_Config.touchStartKey, defaultTouchPosShow, true, true), + ConfigSetting("SelectKeyX", "SelectKeyY", "SelectKeyScale", "ShowTouchSelect", &g_Config.touchSelectKey, defaultTouchPosShow, true, true), + ConfigSetting("UnthrottleKeyX", "UnthrottleKeyY", "UnthrottleKeyScale", "ShowTouchUnthrottle", &g_Config.touchUnthrottleKey, defaultTouchPosShow, true, true), + ConfigSetting("LKeyX", "LKeyY", "LKeyScale", "ShowTouchLTrigger", &g_Config.touchLKey, defaultTouchPosShow, true, true), + ConfigSetting("RKeyX", "RKeyY", "RKeyScale", "ShowTouchRTrigger", &g_Config.touchRKey, defaultTouchPosShow, true, true), + ConfigSetting("AnalogStickX", "AnalogStickY", "AnalogStickScale", "ShowAnalogStick", &g_Config.touchAnalogStick, defaultTouchPosShow, true, true), + + ConfigSetting("fcombo0X", "fcombo0Y", "comboKeyScale0", "ShowComboKey0", &g_Config.touchCombo0, defaultTouchPosHide, true, true), + ConfigSetting("fcombo1X", "fcombo1Y", "comboKeyScale1", "ShowComboKey1", &g_Config.touchCombo1, defaultTouchPosHide, true, true), + ConfigSetting("fcombo2X", "fcombo2Y", "comboKeyScale2", "ShowComboKey2", &g_Config.touchCombo2, defaultTouchPosHide, true, true), + ConfigSetting("fcombo3X", "fcombo3Y", "comboKeyScale3", "ShowComboKey3", &g_Config.touchCombo3, defaultTouchPosHide, true, true), + ConfigSetting("fcombo4X", "fcombo4Y", "comboKeyScale4", "ShowComboKey4", &g_Config.touchCombo4, defaultTouchPosHide, true, true), - ConfigSetting("fcombo0X", &g_Config.fcombo0X, -1.0f, true, true), - ConfigSetting("fcombo0Y", &g_Config.fcombo0Y, -1.0f, true, true), - ConfigSetting("comboKeyScale0", &g_Config.fcomboScale0, defaultControlScale, true, true), - ConfigSetting("fcombo1X", &g_Config.fcombo1X, -1.0f, true, true), - ConfigSetting("fcombo1Y", &g_Config.fcombo1Y, -1.0f, true, true), - ConfigSetting("comboKeyScale1", &g_Config.fcomboScale1, defaultControlScale, true, true), - ConfigSetting("fcombo2X", &g_Config.fcombo2X, -1.0f, true, true), - ConfigSetting("fcombo2Y", &g_Config.fcombo2Y, -1.0f, true, true), - ConfigSetting("comboKeyScale2", &g_Config.fcomboScale2, defaultControlScale, true, true), - ConfigSetting("fcombo3X", &g_Config.fcombo3X, -1.0f, true, true), - ConfigSetting("fcombo3Y", &g_Config.fcombo3Y, -1.0f, true, true), - ConfigSetting("comboKeyScale3", &g_Config.fcomboScale3, defaultControlScale, true, true), - ConfigSetting("fcombo4X", &g_Config.fcombo4X, -1.0f, true, true), - ConfigSetting("fcombo4Y", &g_Config.fcombo4Y, -1.0f, true, true), - ConfigSetting("comboKeyScale4", &g_Config.fcomboScale4, defaultControlScale, true, true), #ifdef _WIN32 ConfigSetting("DInputAnalogDeadzone", &g_Config.fDInputAnalogDeadzone, 0.1f, true, true), ConfigSetting("DInputAnalogInverseMode", &g_Config.iDInputAnalogInverseMode, 0, true, true), @@ -1001,40 +1011,6 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { ResetControlLayout(); } - // MIGRATION: For users who had the old static touch layout, aren't I nice? - // We can probably kill this in 0.9.8 or something. - if (fDpadX > 1.0 || fDpadY > 1.0) { // Likely the rest are too! - float screen_width = dp_xres; - float screen_height = dp_yres; - - fActionButtonCenterX /= screen_width; - fActionButtonCenterY /= screen_height; - fDpadX /= screen_width; - fDpadY /= screen_height; - fStartKeyX /= screen_width; - fStartKeyY /= screen_height; - fSelectKeyX /= screen_width; - fSelectKeyY /= screen_height; - fUnthrottleKeyX /= screen_width; - fUnthrottleKeyY /= screen_height; - fLKeyX /= screen_width; - fLKeyY /= screen_height; - fRKeyX /= screen_width; - fRKeyY /= screen_height; - fAnalogStickX /= screen_width; - fAnalogStickY /= screen_height; - fcombo0X /= screen_width; - fcombo0Y /= screen_height; - fcombo1X /= screen_width; - fcombo1Y /= screen_height; - fcombo2X /= screen_width; - fcombo2Y /= screen_height; - fcombo3X /= screen_width; - fcombo3Y /= screen_height; - fcombo4X /= screen_width; - fcombo4Y /= screen_height; - } - const char *gitVer = PPSSPP_GIT_VERSION; Version installed(gitVer); Version upgrade(upgradeVersion); @@ -1432,47 +1408,26 @@ void Config::LoadStandardControllerIni() { } void Config::ResetControlLayout() { - g_Config.fActionButtonScale = defaultControlScale; + auto reset = [](ConfigTouchPos &pos) { + pos.x = defaultTouchPosShow.x; + pos.y = defaultTouchPosShow.y; + pos.scale = defaultTouchPosShow.scale; + }; + reset(g_Config.touchActionButtonCenter); g_Config.fActionButtonSpacing = 1.0f; - g_Config.fActionButtonCenterX = -1.0; - g_Config.fActionButtonCenterY = -1.0; - g_Config.fDpadScale = defaultControlScale; + reset(g_Config.touchDpad); g_Config.fDpadSpacing = 1.0f; - g_Config.fDpadX = -1.0; - g_Config.fDpadY = -1.0; - g_Config.fStartKeyX = -1.0; - g_Config.fStartKeyY = -1.0; - g_Config.fStartKeyScale = defaultControlScale; - g_Config.fSelectKeyX = -1.0; - g_Config.fSelectKeyY = -1.0; - g_Config.fSelectKeyScale = defaultControlScale; - g_Config.fUnthrottleKeyX = -1.0; - g_Config.fUnthrottleKeyY = -1.0; - g_Config.fUnthrottleKeyScale = defaultControlScale; - g_Config.fLKeyX = -1.0; - g_Config.fLKeyY = -1.0; - g_Config.fLKeyScale = defaultControlScale; - g_Config.fRKeyX = -1.0; - g_Config.fRKeyY = -1.0; - g_Config.fRKeyScale = defaultControlScale; - g_Config.fAnalogStickX = -1.0; - g_Config.fAnalogStickY = -1.0; - g_Config.fAnalogStickScale = defaultControlScale; - g_Config.fcombo0X = -1.0; - g_Config.fcombo0Y = -1.0; - g_Config.fcomboScale0 = defaultControlScale; - g_Config.fcombo1X = -1.0f; - g_Config.fcombo1Y = -1.0f; - g_Config.fcomboScale1 = defaultControlScale; - g_Config.fcombo2X = -1.0f; - g_Config.fcombo2Y = -1.0f; - g_Config.fcomboScale2 = defaultControlScale; - g_Config.fcombo3X = -1.0f; - g_Config.fcombo3Y = -1.0f; - g_Config.fcomboScale3 = defaultControlScale; - g_Config.fcombo4X = -1.0f; - g_Config.fcombo4Y = -1.0f; - g_Config.fcomboScale4 = defaultControlScale; + reset(g_Config.touchStartKey); + reset(g_Config.touchSelectKey); + reset(g_Config.touchUnthrottleKey); + reset(g_Config.touchLKey); + reset(g_Config.touchRKey); + reset(g_Config.touchAnalogStick); + reset(g_Config.touchCombo0); + reset(g_Config.touchCombo1); + reset(g_Config.touchCombo2); + reset(g_Config.touchCombo3); + reset(g_Config.touchCombo4); } void Config::GetReportingInfo(UrlEncoder &data) { diff --git a/Core/Config.h b/Core/Config.h index da179fa8d3..60d12010de 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -32,6 +32,14 @@ namespace http { struct UrlEncoder; +struct ConfigTouchPos { + float x; + float y; + float scale; + // Note: Show is not used for all settings. + bool show; +}; + struct Config { public: Config(); @@ -267,46 +275,25 @@ public: //space between PSP buttons //the PSP button's center (triangle, circle, square, cross) - float fActionButtonCenterX, fActionButtonCenterY; - float fActionButtonScale; + ConfigTouchPos touchActionButtonCenter; float fActionButtonSpacing; //radius of the D-pad (PSP cross) // int iDpadRadius; //the D-pad (PSP cross) position - float fDpadX, fDpadY; - float fDpadScale; + ConfigTouchPos touchDpad; float fDpadSpacing; - //the start key position - float fStartKeyX, fStartKeyY; - float fStartKeyScale; - //the select key position; - float fSelectKeyX, fSelectKeyY; - float fSelectKeyScale; + ConfigTouchPos touchStartKey; + ConfigTouchPos touchSelectKey; + ConfigTouchPos touchUnthrottleKey; + ConfigTouchPos touchLKey; + ConfigTouchPos touchRKey; + ConfigTouchPos touchAnalogStick; - float fUnthrottleKeyX, fUnthrottleKeyY; - float fUnthrottleKeyScale; - - float fLKeyX, fLKeyY; - float fLKeyScale; - - float fRKeyX, fRKeyY; - float fRKeyScale; - - //position of the analog stick - float fAnalogStickX, fAnalogStickY; - float fAnalogStickScale; - - //the Combo Button position - float fcombo0X, fcombo0Y; - float fcomboScale0; - float fcombo1X, fcombo1Y; - float fcomboScale1; - float fcombo2X, fcombo2Y; - float fcomboScale2; - float fcombo3X, fcombo3Y; - float fcomboScale3; - float fcombo4X, fcombo4Y; - float fcomboScale4; + ConfigTouchPos touchCombo0; + ConfigTouchPos touchCombo1; + ConfigTouchPos touchCombo2; + ConfigTouchPos touchCombo3; + ConfigTouchPos touchCombo4; // Controls Visibility bool bShowTouchControls; @@ -316,23 +303,6 @@ public: bool bShowTouchTriangle; bool bShowTouchSquare; - bool bShowTouchStart; - bool bShowTouchSelect; - bool bShowTouchUnthrottle; - - bool bShowTouchLTrigger; - bool bShowTouchRTrigger; - - bool bShowTouchAnalogStick; - bool bShowTouchDpad; - - //Combo Button Visibility - bool bShowComboKey0; - bool bShowComboKey1; - bool bShowComboKey2; - bool bShowComboKey3; - bool bShowComboKey4; - // Combo_key mapping. These are bitfields. int iCombokey0; int iCombokey1; diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 42edfa2979..a0de9fa829 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -387,6 +387,15 @@ void PSPStick::ProcessTouch(float x, float y, bool down) { void InitPadLayout(float xres, float yres, float globalScale) { const float scale = globalScale; + const int halfW = xres / 2; + + auto initTouchPos = [=](ConfigTouchPos &touch, float x, float y) { + if (touch.x == -1.0f || touch.y == -1.0f) { + touch.x = x / xres; + touch.y = y / yres; + touch.scale = scale; + } + }; // PSP buttons (triangle, circle, square, cross)--------------------- // space between the PSP buttons (triangle, circle, square and cross) @@ -398,12 +407,7 @@ void InitPadLayout(float xres, float yres, float globalScale) { float Action_button_spacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing; int Action_button_center_X = xres - Action_button_spacing * 2; int Action_button_center_Y = yres - Action_button_spacing * 2; - - if (g_Config.fActionButtonCenterX == -1.0 || g_Config.fActionButtonCenterY == -1.0) { - // Setup defaults - g_Config.fActionButtonCenterX = (float)Action_button_center_X / xres; - g_Config.fActionButtonCenterY = (float)Action_button_center_Y / yres; - } + initTouchPos(g_Config.touchActionButtonCenter, Action_button_center_X, Action_button_center_Y); //D-PAD (up down left right) (aka PSP cross)---------------------------- //radius to the D-pad @@ -411,26 +415,16 @@ void InitPadLayout(float xres, float yres, float globalScale) { int D_pad_X = 2.5 * D_pad_Radius * scale; int D_pad_Y = yres - D_pad_Radius * scale; - if (g_Config.bShowTouchAnalogStick) { + if (g_Config.touchAnalogStick.show) { D_pad_Y -= 200 * scale; } - - if (g_Config.fDpadX == -1.0 || g_Config.fDpadY == -1.0 ) { - //setup defaults - g_Config.fDpadX = (float)D_pad_X / xres; - g_Config.fDpadY = (float)D_pad_Y / yres; - } + initTouchPos(g_Config.touchDpad, D_pad_X, D_pad_Y); //analog stick------------------------------------------------------- //keep the analog stick right below the D pad int analog_stick_X = D_pad_X; int analog_stick_Y = yres - 80 * scale; - - if (g_Config.fAnalogStickX == -1.0 || g_Config.fAnalogStickY == -1.0 ) { - g_Config.fAnalogStickX = (float)analog_stick_X / xres; - g_Config.fAnalogStickY = (float)analog_stick_Y / yres; - g_Config.fAnalogStickScale = scale; - } + initTouchPos(g_Config.touchAnalogStick, analog_stick_X, analog_stick_Y); //select, start, throttle-------------------------------------------- //space between the bottom keys (space between select, start and un-throttle) @@ -439,32 +433,17 @@ void InitPadLayout(float xres, float yres, float globalScale) { bottom_key_spacing *= 0.8f; } - int start_key_X = xres / 2 + (bottom_key_spacing) * scale; + int start_key_X = halfW + bottom_key_spacing * scale; int start_key_Y = yres - 60 * scale; + initTouchPos(g_Config.touchStartKey, start_key_X, start_key_Y); - if (g_Config.fStartKeyX == -1.0 || g_Config.fStartKeyY == -1.0 ) { - g_Config.fStartKeyX = (float)start_key_X / xres; - g_Config.fStartKeyY = (float)start_key_Y / yres; - g_Config.fStartKeyScale = scale; - } - - int select_key_X = xres / 2; + int select_key_X = halfW; int select_key_Y = yres - 60 * scale; + initTouchPos(g_Config.touchSelectKey, select_key_X, select_key_Y); - if (g_Config.fSelectKeyX == -1.0 || g_Config.fSelectKeyY == -1.0 ) { - g_Config.fSelectKeyX = (float)select_key_X / xres; - g_Config.fSelectKeyY = (float)select_key_Y / yres; - g_Config.fSelectKeyScale = scale; - } - - int unthrottle_key_X = xres / 2 - (bottom_key_spacing) * scale; + int unthrottle_key_X = halfW - bottom_key_spacing * scale; int unthrottle_key_Y = yres - 60 * scale; - - if (g_Config.fUnthrottleKeyX == -1.0 || g_Config.fUnthrottleKeyY == -1.0 ) { - g_Config.fUnthrottleKeyX = (float)unthrottle_key_X / xres; - g_Config.fUnthrottleKeyY = (float)unthrottle_key_Y / yres; - g_Config.fUnthrottleKeyScale = scale; - } + initTouchPos(g_Config.touchUnthrottleKey, unthrottle_key_X, unthrottle_key_Y); // L and R------------------------------------------------------------ // Put them above the analog stick / above the buttons to the right. @@ -472,214 +451,125 @@ void InitPadLayout(float xres, float yres, float globalScale) { int l_key_X = 60 * scale; int l_key_Y = yres - 380 * scale; - - if (g_Config.fLKeyX == -1.0 || g_Config.fLKeyY == -1.0 ) { - g_Config.fLKeyX = (float)l_key_X / xres; - g_Config.fLKeyY = (float)l_key_Y / yres; - g_Config.fLKeyScale = scale; - } + initTouchPos(g_Config.touchLKey, l_key_X, l_key_Y); int r_key_X = xres - 60 * scale; int r_key_Y = l_key_Y; - - if (g_Config.fRKeyX == -1.0 || g_Config.fRKeyY == -1.0 ) { - g_Config.fRKeyX = (float)r_key_X / xres; - g_Config.fRKeyY = (float)r_key_Y / yres; - g_Config.fRKeyScale = scale; - } + initTouchPos(g_Config.touchRKey, r_key_X, r_key_Y); //Combo key - int combo_key_X = xres / 2 + (bottom_key_spacing)* scale*1.2f; + int combo_key_X = halfW + bottom_key_spacing * scale * 1.2f; int combo_key_Y = yres / 2; + initTouchPos(g_Config.touchCombo0, combo_key_X, combo_key_Y); - if (g_Config.fcombo0X == -1.0 || g_Config.fcombo0Y == -1.0) { - g_Config.fcombo0X = (float)combo_key_X / xres; - g_Config.fcombo0Y = (float)combo_key_Y / yres; - g_Config.fcomboScale0 = scale; - } - - int combo1_key_X = xres / 2 + (bottom_key_spacing)* scale * 2.2; + int combo1_key_X = halfW + bottom_key_spacing * scale * 2.2f; int combo1_key_Y = yres / 2; + initTouchPos(g_Config.touchCombo1, combo1_key_X, combo1_key_Y); - if (g_Config.fcombo1X == -1.0 || g_Config.fcombo1Y == -1.0) { - g_Config.fcombo1X = (float)combo1_key_X / xres; - g_Config.fcombo1Y = (float)combo1_key_Y / yres; - g_Config.fcomboScale1 = scale; - } - - int combo2_key_X = xres / 2 + (bottom_key_spacing)* scale * 3.2; + int combo2_key_X = halfW + bottom_key_spacing * scale * 3.2f; int combo2_key_Y = yres / 2; + initTouchPos(g_Config.touchCombo2, combo2_key_X, combo2_key_Y); - if (g_Config.fcombo2X == -1.0 || g_Config.fcombo2Y == -1.0) { - g_Config.fcombo2X = (float)combo2_key_X / xres; - g_Config.fcombo2Y = (float)combo2_key_Y / yres; - g_Config.fcomboScale2 = scale; - } - - int combo3_key_X = xres / 2 + (bottom_key_spacing)* scale * 1.2; + int combo3_key_X = halfW + bottom_key_spacing * scale * 1.2f; int combo3_key_Y = yres / 3; + initTouchPos(g_Config.touchCombo3, combo3_key_X, combo3_key_Y); - if (g_Config.fcombo3X == -1.0 || g_Config.fcombo3Y == -1.0) { - g_Config.fcombo3X = (float)combo3_key_X / xres; - g_Config.fcombo3Y = (float)combo3_key_Y / yres; - g_Config.fcomboScale3 = scale; - } - - int combo4_key_X = xres / 2 + (bottom_key_spacing)* scale * 2.2; + int combo4_key_X = halfW + bottom_key_spacing * scale * 2.2f; int combo4_key_Y = yres / 3; - - if (g_Config.fcombo4X == -1.0 || g_Config.fcombo4Y == -1.0) { - g_Config.fcombo4X = (float)combo4_key_X / xres; - g_Config.fcombo4Y = (float)combo4_key_Y / yres; - g_Config.fcomboScale4 = scale; - } - -}; + initTouchPos(g_Config.touchCombo4, combo4_key_X, combo4_key_Y); +} UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) { - //standard coord system - using namespace UI; AnchorLayout *root = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + if (!g_Config.bShowTouchControls) { + return root; + } - //PSP buttons (triangle, circle, square, cross)--------------------- - //space between the PSP buttons (traingle, circle, square and cross) - const float Action_button_scale = g_Config.fActionButtonScale; - const float Action_button_spacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing; - //position of the circle button (the PSP circle button). It is the farthest to the left - float Action_button_center_X = g_Config.fActionButtonCenterX * xres; - float Action_button_center_Y = g_Config.fActionButtonCenterY * yres; + struct ButtonOffset { + float x; + float y; + }; + auto buttonLayoutParams = [=](const ConfigTouchPos &touch, ButtonOffset off = { 0, 0 }) { + return new AnchorLayoutParams(touch.x * xres + off.x, touch.y * yres + off.y, NONE, NONE, true); + }; - const float Action_circle_button_X = Action_button_center_X + Action_button_spacing; - const float Action_circle_button_Y = Action_button_center_Y; - - const float Action_cross_button_X = Action_button_center_X; - const float Action_cross_button_Y = Action_button_center_Y + Action_button_spacing; - - const float Action_triangle_button_X = Action_button_center_X; - const float Action_triangle_button_Y = Action_button_center_Y - Action_button_spacing; - - const float Action_square_button_X = Action_button_center_X - Action_button_spacing; - const float Action_square_button_Y = Action_button_center_Y; - - //D-PAD (up down left right) (aka PSP cross)-------------------------------------------------------------- - //radius to the D-pad - - float D_pad_X = g_Config.fDpadX * xres; - float D_pad_Y = g_Config.fDpadY * yres; - float D_pad_scale = g_Config.fDpadScale; - float D_pad_spacing = g_Config.fDpadSpacing; - - //select, start, throttle-------------------------------------------- - //space between the bottom keys (space between select, start and un-throttle) - float start_key_X = g_Config.fStartKeyX * xres; - float start_key_Y = g_Config.fStartKeyY * yres; - float start_key_scale = g_Config.fStartKeyScale; - - float select_key_X = g_Config.fSelectKeyX * xres; - float select_key_Y = g_Config.fSelectKeyY * yres; - float select_key_scale = g_Config.fSelectKeyScale; - - float unthrottle_key_X = g_Config.fUnthrottleKeyX * xres; - float unthrottle_key_Y = g_Config.fUnthrottleKeyY * yres; - float unthrottle_key_scale = g_Config.fUnthrottleKeyScale; - - //L and R------------------------------------------------------------ - float l_key_X = g_Config.fLKeyX * xres; - float l_key_Y = g_Config.fLKeyY * yres; - float l_key_scale = g_Config.fLKeyScale; - - float r_key_X = g_Config.fRKeyX * xres; - float r_key_Y = g_Config.fRKeyY * yres; - float r_key_scale = g_Config.fRKeyScale; - - //analog stick------------------------------------------------------- - float analog_stick_X = g_Config.fAnalogStickX * xres; - float analog_stick_Y = g_Config.fAnalogStickY * yres; - float analog_stick_scale = g_Config.fAnalogStickScale; - - //combo key ------------------------------------------------------- - float combo0_key_X = g_Config.fcombo0X * xres; - float combo0_key_Y = g_Config.fcombo0Y * yres; - float combo_key_scale = g_Config.fcomboScale0; - float combo1_key_X = g_Config.fcombo1X * xres; - float combo1_key_Y = g_Config.fcombo1Y * yres; - float combo1_key_scale = g_Config.fcomboScale1; - float combo2_key_X = g_Config.fcombo2X * xres; - float combo2_key_Y = g_Config.fcombo2Y * yres; - float combo2_key_scale = g_Config.fcomboScale2; - float combo3_key_X = g_Config.fcombo3X * xres; - float combo3_key_Y = g_Config.fcombo3Y * yres; - float combo3_key_scale = g_Config.fcomboScale3; - float combo4_key_X = g_Config.fcombo4X * xres; - float combo4_key_Y = g_Config.fcombo4Y * yres; - float combo4_key_scale = g_Config.fcomboScale4; + // Space between the PSP buttons (traingle, circle, square and cross) + const float actionButtonSpacing = g_Config.fActionButtonSpacing * baseActionButtonSpacing; + // Position of the circle button (the PSP circle button). It is the farthest to the right. + ButtonOffset circleOffset{ actionButtonSpacing, 0.0f }; + ButtonOffset crossOffset{ 0.0f, actionButtonSpacing }; + ButtonOffset triangleOffset{ 0.0f, -actionButtonSpacing }; + ButtonOffset squareOffset{ -actionButtonSpacing, 0.0f }; const int halfW = xres / 2; const int roundImage = g_Config.iTouchButtonStyle ? I_ROUND_LINE : I_ROUND; - if (g_Config.bShowTouchControls) { - const int rectImage = g_Config.iTouchButtonStyle ? I_RECT_LINE : I_RECT; - const int shoulderImage = g_Config.iTouchButtonStyle ? I_SHOULDER_LINE : I_SHOULDER; - const int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR; - const int stickImage = g_Config.iTouchButtonStyle ? I_STICK_LINE : I_STICK; - const int stickBg = g_Config.iTouchButtonStyle ? I_STICK_BG_LINE : I_STICK_BG; - static const int comboKeyImages[5] = { I_1, I_2, I_3, I_4, I_5 }; + const int rectImage = g_Config.iTouchButtonStyle ? I_RECT_LINE : I_RECT; + const int shoulderImage = g_Config.iTouchButtonStyle ? I_SHOULDER_LINE : I_SHOULDER; + const int dirImage = g_Config.iTouchButtonStyle ? I_DIR_LINE : I_DIR; + const int stickImage = g_Config.iTouchButtonStyle ? I_STICK_LINE : I_STICK; + const int stickBg = g_Config.iTouchButtonStyle ? I_STICK_BG_LINE : I_STICK_BG; + static const int comboKeyImages[5] = { I_1, I_2, I_3, I_4, I_5 }; - if (!System_GetPropertyBool(SYSPROP_HAS_BACK_BUTTON) || g_Config.bShowTouchPause) { - root->Add(new BoolButton(pause, roundImage, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); + auto addPSPButton = [=](int buttonBit, int bgImg, int img, const ConfigTouchPos &touch, ButtonOffset off = { 0, 0 }) -> PSPButton * { + if (touch.show) { + return root->Add(new PSPButton(buttonBit, bgImg, img, touch.scale, buttonLayoutParams(touch, off))); } + return nullptr; + }; + auto addComboKey = [=](int buttonBit, int bgImg, int img, const ConfigTouchPos &touch) -> ComboKey * { + if (touch.show) { + return root->Add(new ComboKey(buttonBit, bgImg, img, touch.scale, buttonLayoutParams(touch))); + } + return nullptr; + }; + auto addBoolButton = [=](bool *value, int bgImg, int img, const ConfigTouchPos &touch) -> BoolButton * { + if (touch.show) { + return root->Add(new BoolButton(value, bgImg, img, touch.scale, buttonLayoutParams(touch))); + } + return nullptr; + }; - if (g_Config.bShowTouchCircle) - root->Add(new PSPButton(CTRL_CIRCLE, roundImage, I_CIRCLE, Action_button_scale, new AnchorLayoutParams(Action_circle_button_X, Action_circle_button_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchCross) - root->Add(new PSPButton(CTRL_CROSS, roundImage, I_CROSS, Action_button_scale, new AnchorLayoutParams(Action_cross_button_X, Action_cross_button_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchTriangle) - root->Add(new PSPButton(CTRL_TRIANGLE, roundImage, I_TRIANGLE, Action_button_scale, new AnchorLayoutParams(Action_triangle_button_X, Action_triangle_button_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchSquare) - root->Add(new PSPButton(CTRL_SQUARE, roundImage, I_SQUARE, Action_button_scale, new AnchorLayoutParams(Action_square_button_X, Action_square_button_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchStart) - root->Add(new PSPButton(CTRL_START, rectImage, I_START, start_key_scale, new AnchorLayoutParams(start_key_X, start_key_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchSelect) - root->Add(new PSPButton(CTRL_SELECT, rectImage, I_SELECT, select_key_scale, new AnchorLayoutParams(select_key_X, select_key_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchUnthrottle) - root->Add(new BoolButton(&PSP_CoreParameter().unthrottle, rectImage, I_ARROW, unthrottle_key_scale, new AnchorLayoutParams(unthrottle_key_X, unthrottle_key_Y, NONE, NONE, true)))->SetAngle(180); - - if (g_Config.bShowTouchLTrigger) - root->Add(new PSPButton(CTRL_LTRIGGER, shoulderImage, I_L, l_key_scale, new AnchorLayoutParams(l_key_X, l_key_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchRTrigger) - root->Add(new PSPButton(CTRL_RTRIGGER, shoulderImage, I_R, r_key_scale, new AnchorLayoutParams(r_key_X,r_key_Y, NONE, NONE, true)))->FlipImageH(true); - - if (g_Config.bShowTouchDpad) - root->Add(new PSPDpad(dirImage, I_ARROW, D_pad_scale, D_pad_spacing, new AnchorLayoutParams(D_pad_X, D_pad_Y, NONE, NONE, true))); - - if (g_Config.bShowTouchAnalogStick) - root->Add(new PSPStick(stickBg, stickImage, 0, analog_stick_scale, new AnchorLayoutParams(analog_stick_X, analog_stick_Y, NONE, NONE, true))); - - if (g_Config.bShowComboKey0) - root->Add(new ComboKey(g_Config.iCombokey0, roundImage, comboKeyImages[0], combo_key_scale, new AnchorLayoutParams(combo0_key_X, combo0_key_Y, NONE, NONE, true))); - - if (g_Config.bShowComboKey1) - root->Add(new ComboKey(g_Config.iCombokey1, roundImage, comboKeyImages[1], combo1_key_scale, new AnchorLayoutParams(combo1_key_X, combo1_key_Y, NONE, NONE, true))); - - if (g_Config.bShowComboKey2) - root->Add(new ComboKey(g_Config.iCombokey2, roundImage, comboKeyImages[2], combo2_key_scale, new AnchorLayoutParams(combo2_key_X, combo2_key_Y, NONE, NONE, true))); - - if (g_Config.bShowComboKey3) - root->Add(new ComboKey(g_Config.iCombokey3, roundImage, comboKeyImages[3], combo3_key_scale, new AnchorLayoutParams(combo3_key_X, combo3_key_Y, NONE, NONE, true))); - - if (g_Config.bShowComboKey4) - root->Add(new ComboKey(g_Config.iCombokey4, roundImage, comboKeyImages[4], combo4_key_scale, new AnchorLayoutParams(combo4_key_X, combo4_key_Y, NONE, NONE, true))); + if (!System_GetPropertyBool(SYSPROP_HAS_BACK_BUTTON) || g_Config.bShowTouchPause) { + root->Add(new BoolButton(pause, roundImage, I_ARROW, 1.0f, new AnchorLayoutParams(halfW, 20, NONE, NONE, true)))->SetAngle(90); } + // touchActionButtonCenter.show will always be true, since that's the default. + if (g_Config.bShowTouchCircle) + addPSPButton(CTRL_CIRCLE, roundImage, I_CIRCLE, g_Config.touchActionButtonCenter, circleOffset); + if (g_Config.bShowTouchCross) + addPSPButton(CTRL_CROSS, roundImage, I_CROSS, g_Config.touchActionButtonCenter, crossOffset); + if (g_Config.bShowTouchTriangle) + addPSPButton(CTRL_TRIANGLE, roundImage, I_TRIANGLE, g_Config.touchActionButtonCenter, triangleOffset); + if (g_Config.bShowTouchSquare) + addPSPButton(CTRL_SQUARE, roundImage, I_SQUARE, g_Config.touchActionButtonCenter, squareOffset); + + addPSPButton(CTRL_START, rectImage, I_START, g_Config.touchStartKey); + addPSPButton(CTRL_SELECT, rectImage, I_SELECT, g_Config.touchSelectKey); + + BoolButton *unthrottle = addBoolButton(&PSP_CoreParameter().unthrottle, rectImage, I_ARROW, g_Config.touchUnthrottleKey); + if (unthrottle) + unthrottle->SetAngle(180); + + addPSPButton(CTRL_LTRIGGER, shoulderImage, I_L, g_Config.touchLKey); + PSPButton *rTrigger = addPSPButton(CTRL_RTRIGGER, shoulderImage, I_R, g_Config.touchRKey); + if (rTrigger) + rTrigger->FlipImageH(true); + + if (g_Config.touchDpad.show) + root->Add(new PSPDpad(dirImage, I_ARROW, g_Config.touchDpad.scale, g_Config.fDpadSpacing, buttonLayoutParams(g_Config.touchDpad))); + + if (g_Config.touchAnalogStick.show) + root->Add(new PSPStick(stickBg, stickImage, 0, g_Config.touchAnalogStick.scale, buttonLayoutParams(g_Config.touchAnalogStick))); + + addComboKey(g_Config.iCombokey0, roundImage, comboKeyImages[0], g_Config.touchCombo0); + addComboKey(g_Config.iCombokey1, roundImage, comboKeyImages[1], g_Config.touchCombo1); + addComboKey(g_Config.iCombokey2, roundImage, comboKeyImages[2], g_Config.touchCombo2); + addComboKey(g_Config.iCombokey3, roundImage, comboKeyImages[3], g_Config.touchCombo3); + addComboKey(g_Config.iCombokey4, roundImage, comboKeyImages[4], g_Config.touchCombo4); + return root; } diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 87dee45e31..a248b01f9e 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -42,9 +42,9 @@ static u32 GetButtonColor() { class DragDropButton : public MultiTouchButton { public: - DragDropButton(float &x, float &y, int bgImg, int img, float &scale) - : MultiTouchButton(bgImg, img, scale, new UI::AnchorLayoutParams(fromFullscreenCoord(x), y*local_dp_yres, UI::NONE, UI::NONE, true)), - x_(x), y_(y), theScale_(scale) { + DragDropButton(ConfigTouchPos &pos, int bgImg, int img) + : MultiTouchButton(bgImg, img, pos.scale, new UI::AnchorLayoutParams(fromFullscreenCoord(pos.x), pos.y * local_dp_yres, UI::NONE, UI::NONE, true)), + x_(pos.x), y_(pos.y), theScale_(pos.scale) { scale_ = theScale_; } @@ -89,8 +89,8 @@ private: class PSPActionButtons : public DragDropButton { public: - PSPActionButtons(float &x, float &y, float &scale, float &spacing) - : DragDropButton(x, y, -1, -1, scale), spacing_(spacing) { + PSPActionButtons(ConfigTouchPos &pos, float &spacing) + : DragDropButton(pos, -1, -1), spacing_(spacing) { using namespace UI; roundId_ = g_Config.iTouchButtonStyle ? I_ROUND_LINE : I_ROUND; @@ -172,8 +172,8 @@ private: class PSPDPadButtons : public DragDropButton { public: - PSPDPadButtons(float &x, float &y, float &scale, float &spacing) - : DragDropButton(x, y, -1, -1, scale), spacing_(spacing) { + PSPDPadButtons(ConfigTouchPos &pos, float &spacing) + : DragDropButton(pos, -1, -1), spacing_(spacing) { } void Draw(UIContext &dc) override { @@ -361,7 +361,7 @@ void TouchControlLayoutScreen::CreateViews() { controls_.clear(); - PSPActionButtons *actionButtons = new PSPActionButtons(g_Config.fActionButtonCenterX, g_Config.fActionButtonCenterY, g_Config.fActionButtonScale, g_Config.fActionButtonSpacing); + PSPActionButtons *actionButtons = new PSPActionButtons(g_Config.touchActionButtonCenter, g_Config.fActionButtonSpacing); actionButtons->setCircleVisibility(g_Config.bShowTouchCircle); actionButtons->setCrossVisibility(g_Config.bShowTouchCross); actionButtons->setTriangleVisibility(g_Config.bShowTouchTriangle); @@ -378,51 +378,51 @@ void TouchControlLayoutScreen::CreateViews() { const int comboKeyImages[5] = { I_1, I_2, I_3, I_4, I_5 }; - if (g_Config.bShowTouchDpad) { - controls_.push_back(new PSPDPadButtons(g_Config.fDpadX, g_Config.fDpadY, g_Config.fDpadScale, g_Config.fDpadSpacing)); + if (g_Config.touchDpad.show) { + controls_.push_back(new PSPDPadButtons(g_Config.touchDpad, g_Config.fDpadSpacing)); } - if (g_Config.bShowTouchSelect) { - controls_.push_back(new DragDropButton(g_Config.fSelectKeyX, g_Config.fSelectKeyY, rectImage, I_SELECT, g_Config.fSelectKeyScale)); + if (g_Config.touchSelectKey.show) { + controls_.push_back(new DragDropButton(g_Config.touchSelectKey, rectImage, I_SELECT)); } - if (g_Config.bShowTouchStart) { - controls_.push_back(new DragDropButton(g_Config.fStartKeyX, g_Config.fStartKeyY, rectImage, I_START, g_Config.fStartKeyScale)); + if (g_Config.touchStartKey.show) { + controls_.push_back(new DragDropButton(g_Config.touchStartKey, rectImage, I_START)); } - if (g_Config.bShowTouchUnthrottle) { - DragDropButton *unthrottle = new DragDropButton(g_Config.fUnthrottleKeyX, g_Config.fUnthrottleKeyY, rectImage, I_ARROW, g_Config.fUnthrottleKeyScale); + if (g_Config.touchUnthrottleKey.show) { + DragDropButton *unthrottle = new DragDropButton(g_Config.touchUnthrottleKey, rectImage, I_ARROW); unthrottle->SetAngle(180.0f); controls_.push_back(unthrottle); } - if (g_Config.bShowTouchLTrigger) { - controls_.push_back(new DragDropButton(g_Config.fLKeyX, g_Config.fLKeyY, shoulderImage, I_L, g_Config.fLKeyScale)); + if (g_Config.touchLKey.show) { + controls_.push_back(new DragDropButton(g_Config.touchLKey, shoulderImage, I_L)); } - if (g_Config.bShowTouchRTrigger) { - DragDropButton *rbutton = new DragDropButton(g_Config.fRKeyX, g_Config.fRKeyY, shoulderImage, I_R, g_Config.fRKeyScale); + if (g_Config.touchRKey.show) { + DragDropButton *rbutton = new DragDropButton(g_Config.touchRKey, shoulderImage, I_R); rbutton->FlipImageH(true); controls_.push_back(rbutton); } - if (g_Config.bShowTouchAnalogStick) { - controls_.push_back(new DragDropButton(g_Config.fAnalogStickX, g_Config.fAnalogStickY, stickBg, stickImage, g_Config.fAnalogStickScale)); + if (g_Config.touchAnalogStick.show) { + controls_.push_back(new DragDropButton(g_Config.touchAnalogStick, stickBg, stickImage)); } - if (g_Config.bShowComboKey0) { - controls_.push_back(new DragDropButton(g_Config.fcombo0X, g_Config.fcombo0Y, roundImage, comboKeyImages[0], g_Config.fcomboScale0)); + if (g_Config.touchCombo0.show) { + controls_.push_back(new DragDropButton(g_Config.touchCombo0, roundImage, comboKeyImages[0])); } - if (g_Config.bShowComboKey1) { - controls_.push_back(new DragDropButton(g_Config.fcombo1X, g_Config.fcombo1Y, roundImage, comboKeyImages[1], g_Config.fcomboScale1)); + if (g_Config.touchCombo1.show) { + controls_.push_back(new DragDropButton(g_Config.touchCombo1, roundImage, comboKeyImages[1])); } - if (g_Config.bShowComboKey2) { - controls_.push_back(new DragDropButton(g_Config.fcombo2X, g_Config.fcombo2Y, roundImage, comboKeyImages[2], g_Config.fcomboScale2)); + if (g_Config.touchCombo2.show) { + controls_.push_back(new DragDropButton(g_Config.touchCombo2, roundImage, comboKeyImages[2])); } - if (g_Config.bShowComboKey3) { - controls_.push_back(new DragDropButton(g_Config.fcombo3X, g_Config.fcombo3Y, roundImage, comboKeyImages[3], g_Config.fcomboScale3)); + if (g_Config.touchCombo3.show) { + controls_.push_back(new DragDropButton(g_Config.touchCombo3, roundImage, comboKeyImages[3])); } - if (g_Config.bShowComboKey4) { - controls_.push_back(new DragDropButton(g_Config.fcombo4X, g_Config.fcombo4Y, roundImage, comboKeyImages[4], g_Config.fcomboScale4)); + if (g_Config.touchCombo4.show) { + controls_.push_back(new DragDropButton(g_Config.touchCombo4, roundImage, comboKeyImages[4])); }; for (size_t i = 0; i < controls_.size(); i++) { diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 2d0381ede5..a4fd18c9e9 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -62,18 +62,18 @@ void TouchControlVisibilityScreen::CreateViews() { keyToggles["Cross"] = &g_Config.bShowTouchCross; keyToggles["Square"] = &g_Config.bShowTouchSquare; keyToggles["Triangle"] = &g_Config.bShowTouchTriangle; - keyToggles["L"] = &g_Config.bShowTouchLTrigger; - keyToggles["R"] = &g_Config.bShowTouchRTrigger; - keyToggles["Start"] = &g_Config.bShowTouchStart; - keyToggles["Select"] = &g_Config.bShowTouchSelect; - keyToggles["Dpad"] = &g_Config.bShowTouchDpad; - keyToggles["Analog Stick"] = &g_Config.bShowTouchAnalogStick; - keyToggles["Unthrottle"] = &g_Config.bShowTouchUnthrottle; - keyToggles["Combo0"] = &g_Config.bShowComboKey0; - keyToggles["Combo1"] = &g_Config.bShowComboKey1; - keyToggles["Combo2"] = &g_Config.bShowComboKey2; - keyToggles["Combo3"] = &g_Config.bShowComboKey3; - keyToggles["Combo4"] = &g_Config.bShowComboKey4; + keyToggles["L"] = &g_Config.touchLKey.show; + keyToggles["R"] = &g_Config.touchRKey.show; + keyToggles["Start"] = &g_Config.touchStartKey.show; + keyToggles["Select"] = &g_Config.touchSelectKey.show; + keyToggles["Dpad"] = &g_Config.touchDpad.show; + keyToggles["Analog Stick"] = &g_Config.touchAnalogStick.show; + keyToggles["Unthrottle"] = &g_Config.touchUnthrottleKey.show; + keyToggles["Combo0"] = &g_Config.touchCombo0.show; + keyToggles["Combo1"] = &g_Config.touchCombo1.show; + keyToggles["Combo2"] = &g_Config.touchCombo2.show; + keyToggles["Combo3"] = &g_Config.touchCombo3.show; + keyToggles["Combo4"] = &g_Config.touchCombo4.show; std::map::iterator imageFinder;