diff --git a/Core/Config.cpp b/Core/Config.cpp index 5753b803b7..b04b6705ea 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -637,27 +637,27 @@ static const ConfigSetting controlSettings[] = { ConfigSetting("ShowTouchSquare", &g_Config.bShowTouchSquare, true, CfgFlag::PER_GAME), ConfigSetting("ShowTouchTriangle", &g_Config.bShowTouchTriangle, true, CfgFlag::PER_GAME), - ConfigSetting("Custom0Mapping", "Custom0Image", "Custom0Shape", "Custom0Toggle", "Custom0Repeat", &g_Config.CustomButton0, {0, 0, 0, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom1Mapping", "Custom1Image", "Custom1Shape", "Custom1Toggle", "Custom1Repeat", &g_Config.CustomButton1, {0, 1, 0, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom2Mapping", "Custom2Image", "Custom2Shape", "Custom2Toggle", "Custom2Repeat", &g_Config.CustomButton2, {0, 2, 0, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom3Mapping", "Custom3Image", "Custom3Shape", "Custom3Toggle", "Custom3Repeat", &g_Config.CustomButton3, {0, 3, 0, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom4Mapping", "Custom4Image", "Custom4Shape", "Custom4Toggle", "Custom4Repeat", &g_Config.CustomButton4, {0, 4, 0, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom5Mapping", "Custom5Image", "Custom5Shape", "Custom5Toggle", "Custom5Repeat", &g_Config.CustomButton5, {0, 0, 1, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom6Mapping", "Custom6Image", "Custom6Shape", "Custom6Toggle", "Custom6Repeat", &g_Config.CustomButton6, {0, 1, 1, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom7Mapping", "Custom7Image", "Custom7Shape", "Custom7Toggle", "Custom7Repeat", &g_Config.CustomButton7, {0, 2, 1, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom8Mapping", "Custom8Image", "Custom8Shape", "Custom8Toggle", "Custom8Repeat", &g_Config.CustomButton8, {0, 3, 1, false, false}, CfgFlag::PER_GAME), - ConfigSetting("Custom9Mapping", "Custom9Image", "Custom9Shape", "Custom9Toggle", "Custom9Repeat", &g_Config.CustomButton9, {0, 4, 1, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom0Mapping", "Custom0Image", "Custom0Shape", "Custom0Toggle", "Custom0Repeat", &g_Config.CustomButton[0], {0, 0, 0, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom1Mapping", "Custom1Image", "Custom1Shape", "Custom1Toggle", "Custom1Repeat", &g_Config.CustomButton[1], {0, 1, 0, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom2Mapping", "Custom2Image", "Custom2Shape", "Custom2Toggle", "Custom2Repeat", &g_Config.CustomButton[2], {0, 2, 0, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom3Mapping", "Custom3Image", "Custom3Shape", "Custom3Toggle", "Custom3Repeat", &g_Config.CustomButton[3], {0, 3, 0, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom4Mapping", "Custom4Image", "Custom4Shape", "Custom4Toggle", "Custom4Repeat", &g_Config.CustomButton[4], {0, 4, 0, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom5Mapping", "Custom5Image", "Custom5Shape", "Custom5Toggle", "Custom5Repeat", &g_Config.CustomButton[5], {0, 0, 1, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom6Mapping", "Custom6Image", "Custom6Shape", "Custom6Toggle", "Custom6Repeat", &g_Config.CustomButton[6], {0, 1, 1, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom7Mapping", "Custom7Image", "Custom7Shape", "Custom7Toggle", "Custom7Repeat", &g_Config.CustomButton[7], {0, 2, 1, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom8Mapping", "Custom8Image", "Custom8Shape", "Custom8Toggle", "Custom8Repeat", &g_Config.CustomButton[8], {0, 3, 1, false, false}, CfgFlag::PER_GAME), + ConfigSetting("Custom9Mapping", "Custom9Image", "Custom9Shape", "Custom9Toggle", "Custom9Repeat", &g_Config.CustomButton[9], {0, 4, 1, false, false}, CfgFlag::PER_GAME), // Combo keys are going to be something else, but I don't want to break the config. - ConfigSetting("fcombo0X", "fcombo0Y", "comboKeyScale0", "ShowComboKey0", &g_Config.touchCustom0, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo1X", "fcombo1Y", "comboKeyScale1", "ShowComboKey1", &g_Config.touchCustom1, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo2X", "fcombo2Y", "comboKeyScale2", "ShowComboKey2", &g_Config.touchCustom2, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo3X", "fcombo3Y", "comboKeyScale3", "ShowComboKey3", &g_Config.touchCustom3, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo4X", "fcombo4Y", "comboKeyScale4", "ShowComboKey4", &g_Config.touchCustom4, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo5X", "fcombo5Y", "comboKeyScale5", "ShowComboKey5", &g_Config.touchCustom5, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo6X", "fcombo6Y", "comboKeyScale6", "ShowComboKey6", &g_Config.touchCustom6, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo7X", "fcombo7Y", "comboKeyScale7", "ShowComboKey7", &g_Config.touchCustom7, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo8X", "fcombo8Y", "comboKeyScale8", "ShowComboKey8", &g_Config.touchCustom8, defaultTouchPosHide, CfgFlag::PER_GAME), - ConfigSetting("fcombo9X", "fcombo9Y", "comboKeyScale9", "ShowComboKey9", &g_Config.touchCustom9, defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo0X", "fcombo0Y", "comboKeyScale0", "ShowComboKey0", &g_Config.touchCustom[0], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo1X", "fcombo1Y", "comboKeyScale1", "ShowComboKey1", &g_Config.touchCustom[1], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo2X", "fcombo2Y", "comboKeyScale2", "ShowComboKey2", &g_Config.touchCustom[2], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo3X", "fcombo3Y", "comboKeyScale3", "ShowComboKey3", &g_Config.touchCustom[3], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo4X", "fcombo4Y", "comboKeyScale4", "ShowComboKey4", &g_Config.touchCustom[4], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo5X", "fcombo5Y", "comboKeyScale5", "ShowComboKey5", &g_Config.touchCustom[5], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo6X", "fcombo6Y", "comboKeyScale6", "ShowComboKey6", &g_Config.touchCustom[6], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo7X", "fcombo7Y", "comboKeyScale7", "ShowComboKey7", &g_Config.touchCustom[7], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo8X", "fcombo8Y", "comboKeyScale8", "ShowComboKey8", &g_Config.touchCustom[8], defaultTouchPosHide, CfgFlag::PER_GAME), + ConfigSetting("fcombo9X", "fcombo9Y", "comboKeyScale9", "ShowComboKey9", &g_Config.touchCustom[9], defaultTouchPosHide, CfgFlag::PER_GAME), #if defined(_WIN32) // A win32 user seeing touch controls is likely using PPSSPP on a tablet. There it makes @@ -1707,16 +1707,9 @@ void Config::ResetControlLayout() { reset(g_Config.touchRKey); reset(g_Config.touchAnalogStick); reset(g_Config.touchRightAnalogStick); - reset(g_Config.touchCustom0); - reset(g_Config.touchCustom1); - reset(g_Config.touchCustom2); - reset(g_Config.touchCustom3); - reset(g_Config.touchCustom4); - reset(g_Config.touchCustom5); - reset(g_Config.touchCustom6); - reset(g_Config.touchCustom7); - reset(g_Config.touchCustom8); - reset(g_Config.touchCustom9); + for (int i = 0; i < CUSTOM_BUTTON_COUNT; i++) { + reset(g_Config.touchCustom[i]); + } g_Config.fLeftStickHeadScale = 1.0f; g_Config.fRightStickHeadScale = 1.0f; } diff --git a/Core/Config.h b/Core/Config.h index ae0c95b3d0..a7b3529e8c 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -341,16 +341,9 @@ public: ConfigTouchPos touchAnalogStick; ConfigTouchPos touchRightAnalogStick; - ConfigTouchPos touchCustom0; - ConfigTouchPos touchCustom1; - ConfigTouchPos touchCustom2; - ConfigTouchPos touchCustom3; - ConfigTouchPos touchCustom4; - ConfigTouchPos touchCustom5; - ConfigTouchPos touchCustom6; - ConfigTouchPos touchCustom7; - ConfigTouchPos touchCustom8; - ConfigTouchPos touchCustom9; + enum { CUSTOM_BUTTON_COUNT = 10 }; + + ConfigTouchPos touchCustom[CUSTOM_BUTTON_COUNT]; float fLeftStickHeadScale; float fRightStickHeadScale; @@ -364,16 +357,7 @@ public: bool bShowTouchTriangle; bool bShowTouchSquare; - ConfigCustomButton CustomButton0; - ConfigCustomButton CustomButton1; - ConfigCustomButton CustomButton2; - ConfigCustomButton CustomButton3; - ConfigCustomButton CustomButton4; - ConfigCustomButton CustomButton5; - ConfigCustomButton CustomButton6; - ConfigCustomButton CustomButton7; - ConfigCustomButton CustomButton8; - ConfigCustomButton CustomButton9; + ConfigCustomButton CustomButton[CUSTOM_BUTTON_COUNT]; // Ignored on iOS and other platforms that lack pause. bool bShowTouchPause; diff --git a/UI/CustomButtonMappingScreen.cpp b/UI/CustomButtonMappingScreen.cpp index 31edd6d22e..09ebaa293d 100644 --- a/UI/CustomButtonMappingScreen.cpp +++ b/UI/CustomButtonMappingScreen.cpp @@ -131,73 +131,10 @@ void CustomButtonMappingScreen::CreateViews() { ConfigCustomButton* cfg = nullptr; bool* show = nullptr; memset(array, 0, sizeof(array)); - switch (id_) { - case 0: - cfg = &g_Config.CustomButton0; - show = &g_Config.touchCustom0.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton0.key >> i) & 0x01)); - break; - case 1: - cfg = &g_Config.CustomButton1; - show = &g_Config.touchCustom1.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton1.key >> i) & 0x01)); - break; - case 2: - cfg = &g_Config.CustomButton2; - show = &g_Config.touchCustom2.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton2.key >> i) & 0x01)); - break; - case 3: - cfg = &g_Config.CustomButton3; - show = &g_Config.touchCustom3.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton3.key >> i) & 0x01)); - break; - case 4: - cfg = &g_Config.CustomButton4; - show = &g_Config.touchCustom4.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton4.key >> i) & 0x01)); - break; - case 5: - cfg = &g_Config.CustomButton5; - show = &g_Config.touchCustom5.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton5.key >> i) & 0x01)); - break; - case 6: - cfg = &g_Config.CustomButton6; - show = &g_Config.touchCustom6.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton6.key >> i) & 0x01)); - break; - case 7: - cfg = &g_Config.CustomButton7; - show = &g_Config.touchCustom7.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton7.key >> i) & 0x01)); - break; - case 8: - cfg = &g_Config.CustomButton8; - show = &g_Config.touchCustom8.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton8.key >> i) & 0x01)); - break; - case 9: - cfg = &g_Config.CustomButton9; - show = &g_Config.touchCustom9.show; - for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) - array[i] = (0x01 == ((g_Config.CustomButton9.key >> i) & 0x01)); - break; - default: - // This shouldn't happen, let's just not crash. - cfg = &g_Config.CustomButton0; - show = &g_Config.touchCustom0.show; - break; - } + cfg = &g_Config.CustomButton[id_]; + show = &g_Config.touchCustom[id_].show; + for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) + array[i] = (0x01 == ((g_Config.CustomButton[id_].key >> i) & 0x01)); leftColumn->Add(new ButtonPreview(g_Config.iTouchButtonStyle == 0 ? customKeyShapes[cfg->shape].i : customKeyShapes[cfg->shape].l, customKeyImages[cfg->image].i, customKeyImages[cfg->image].r, customKeyShapes[cfg->shape].f, customKeyShapes[cfg->shape].r, 62, 82)); @@ -282,37 +219,8 @@ static uint64_t arrayToInt(const bool ary[ARRAY_SIZE(CustomKeyData::customKeyLis } void CustomButtonMappingScreen::saveArray() { - switch (id_) { - case 0: - g_Config.CustomButton0.key = arrayToInt(array); - break; - case 1: - g_Config.CustomButton1.key = arrayToInt(array); - break; - case 2: - g_Config.CustomButton2.key = arrayToInt(array); - break; - case 3: - g_Config.CustomButton3.key = arrayToInt(array); - break; - case 4: - g_Config.CustomButton4.key = arrayToInt(array); - break; - case 5: - g_Config.CustomButton5.key = arrayToInt(array); - break; - case 6: - g_Config.CustomButton6.key = arrayToInt(array); - break; - case 7: - g_Config.CustomButton7.key = arrayToInt(array); - break; - case 8: - g_Config.CustomButton8.key = arrayToInt(array); - break; - case 9: - g_Config.CustomButton9.key = arrayToInt(array); - break; + if (id_ >= 0 && id_ < Config::CUSTOM_BUTTON_COUNT) { + g_Config.CustomButton[id_].key = arrayToInt(array); } } diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index 53b6412ce5..a71942c718 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -738,46 +738,27 @@ void InitPadLayout(float xres, float yres, float globalScale) { int r_key_Y = l_key_Y; initTouchPos(g_Config.touchRKey, r_key_X, r_key_Y); - //Combo key - int combo_key_X = halfW + bottom_key_spacing * scale * 1.2f; - int combo_key_Y = yres / 2; - initTouchPos(g_Config.touchCustom0, combo_key_X, combo_key_Y); + struct { float x; float y; } customButtonPositions[10] = { + { 1.2f, 0.5f }, + { 2.2f, 0.5f }, + { 3.2f, 0.5f }, + { 1.2f, 0.333f }, + { 2.2f, 0.333f }, + { -1.2f, 0.5f }, + { -2.2f, 0.5f }, + { -3.2f, 0.5f }, + { -1.2f, 0.333f }, + { -2.2f, 0.333f }, + }; - int combo1_key_X = halfW + bottom_key_spacing * scale * 2.2f; - int combo1_key_Y = yres / 2; - initTouchPos(g_Config.touchCustom1, combo1_key_X, combo1_key_Y); + for (int i = 0; i < Config::CUSTOM_BUTTON_COUNT; i++) { + float y_offset = (float)(i / 10) * 0.08333f; - int combo2_key_X = halfW + bottom_key_spacing * scale * 3.2f; - int combo2_key_Y = yres / 2; - initTouchPos(g_Config.touchCustom2, combo2_key_X, combo2_key_Y); + int combo_key_X = halfW + bottom_key_spacing * scale * customButtonPositions[i % 10].x; + int combo_key_Y = yres * (y_offset + customButtonPositions[i % 10].y); - int combo3_key_X = halfW + bottom_key_spacing * scale * 1.2f; - int combo3_key_Y = yres / 3; - initTouchPos(g_Config.touchCustom3, combo3_key_X, combo3_key_Y); - - int combo4_key_X = halfW + bottom_key_spacing * scale * 2.2f; - int combo4_key_Y = yres / 3; - initTouchPos(g_Config.touchCustom4, combo4_key_X, combo4_key_Y); - - int combo5_key_X = halfW - bottom_key_spacing * scale * 1.2f; - int combo5_key_Y = yres / 2; - initTouchPos(g_Config.touchCustom5, combo5_key_X, combo5_key_Y); - - int combo6_key_X = halfW - bottom_key_spacing * scale * 2.2f; - int combo6_key_Y = yres / 2; - initTouchPos(g_Config.touchCustom6, combo6_key_X, combo6_key_Y); - - int combo7_key_X = halfW - bottom_key_spacing * scale * 3.2f; - int combo7_key_Y = yres / 2; - initTouchPos(g_Config.touchCustom7, combo7_key_X, combo7_key_Y); - - int combo8_key_X = halfW - bottom_key_spacing * scale * 1.2f; - int combo8_key_Y = yres / 3; - initTouchPos(g_Config.touchCustom8, combo8_key_X, combo8_key_Y); - - int combo9_key_X = halfW - bottom_key_spacing * scale * 2.2f; - int combo9_key_Y = yres / 3; - initTouchPos(g_Config.touchCustom9, combo9_key_X, combo9_key_Y); + initTouchPos(g_Config.touchCustom[i], combo_key_X, combo_key_Y); + } } UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPauseButton, ControlMapper* controllMapper) { @@ -884,16 +865,11 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPau root->Add(new PSPStick(stickBg, "Right analog stick", stickImage, ImageID("I_STICK"), 1, g_Config.touchRightAnalogStick.scale, buttonLayoutParams(g_Config.touchRightAnalogStick))); } - addCustomButton(g_Config.CustomButton0, "Custom 1 button", g_Config.touchCustom0); - addCustomButton(g_Config.CustomButton1, "Custom 2 button", g_Config.touchCustom1); - addCustomButton(g_Config.CustomButton2, "Custom 3 button", g_Config.touchCustom2); - addCustomButton(g_Config.CustomButton3, "Custom 4 button", g_Config.touchCustom3); - addCustomButton(g_Config.CustomButton4, "Custom 5 button", g_Config.touchCustom4); - addCustomButton(g_Config.CustomButton5, "Custom 6 button", g_Config.touchCustom5); - addCustomButton(g_Config.CustomButton6, "Custom 7 button", g_Config.touchCustom6); - addCustomButton(g_Config.CustomButton7, "Custom 8 button", g_Config.touchCustom7); - addCustomButton(g_Config.CustomButton8, "Custom 9 button", g_Config.touchCustom8); - addCustomButton(g_Config.CustomButton9, "Custom 10 button", g_Config.touchCustom9); + for (int i = 0; i < Config::CUSTOM_BUTTON_COUNT; i++) { + char temp[64]; + snprintf(temp, sizeof(temp), "Custom %d button", i + 1); + addCustomButton(g_Config.CustomButton[i], temp, g_Config.touchCustom[i]); + } if (g_Config.bGestureControlEnabled) root->Add(new GestureGamepad(controllMapper)); diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index 5c8bd17091..d34f05fcc7 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -44,7 +44,7 @@ public: protected: virtual float GetButtonOpacity(); - const char *key_; + std::string key_; double lastFrameTime_; float secondsWithoutTouch_ = 0.0; bool forceVisible_ = false; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 646056ff2e..ad95e1d7da 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -520,16 +520,12 @@ void ControlLayoutView::CreateViews() { } return b; }; - addDragCustomKey(g_Config.touchCustom0, "Custom 1 button", g_Config.CustomButton0); - addDragCustomKey(g_Config.touchCustom1, "Custom 2 button", g_Config.CustomButton1); - addDragCustomKey(g_Config.touchCustom2, "Custom 3 button", g_Config.CustomButton2); - addDragCustomKey(g_Config.touchCustom3, "Custom 4 button", g_Config.CustomButton3); - addDragCustomKey(g_Config.touchCustom4, "Custom 5 button", g_Config.CustomButton4); - addDragCustomKey(g_Config.touchCustom5, "Custom 6 button", g_Config.CustomButton5); - addDragCustomKey(g_Config.touchCustom6, "Custom 7 button", g_Config.CustomButton6); - addDragCustomKey(g_Config.touchCustom7, "Custom 8 button", g_Config.CustomButton7); - addDragCustomKey(g_Config.touchCustom8, "Custom 9 button", g_Config.CustomButton8); - addDragCustomKey(g_Config.touchCustom9, "Custom 10 button", g_Config.CustomButton9); + + for (int i = 0; i < Config::CUSTOM_BUTTON_COUNT; i++) { + char temp[64]; + snprintf(temp, sizeof(temp), "Custom %d button", i); + addDragCustomKey(g_Config.touchCustom[i], temp, g_Config.CustomButton[i]); + } for (size_t i = 0; i < controls_.size(); i++) { Add(controls_[i]); diff --git a/UI/TouchControlVisibilityScreen.cpp b/UI/TouchControlVisibilityScreen.cpp index 0828e97eb6..6de2bee412 100644 --- a/UI/TouchControlVisibilityScreen.cpp +++ b/UI/TouchControlVisibilityScreen.cpp @@ -89,46 +89,15 @@ void TouchControlVisibilityScreen::CreateViews() { return UI::EVENT_DONE; }}); toggles_.push_back({ "Fast-forward", &g_Config.touchFastForwardKey.show, ImageID::invalid(), nullptr }); - toggles_.push_back({ "Custom 1", &g_Config.touchCustom0.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 0)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 2", &g_Config.touchCustom1.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 1)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 3", &g_Config.touchCustom2.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 2)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 4", &g_Config.touchCustom3.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 3)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 5", &g_Config.touchCustom4.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 4)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 6", &g_Config.touchCustom5.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 5)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 7", &g_Config.touchCustom6.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 6)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 8", &g_Config.touchCustom7.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 7)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 9", &g_Config.touchCustom8.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 8)); - return UI::EVENT_DONE; - }}); - toggles_.push_back({ "Custom 10", &g_Config.touchCustom9.show, ImageID::invalid(), [=](EventParams &e) { - screenManager()->push(new CustomButtonMappingScreen(gamePath_, 9)); - return UI::EVENT_DONE; - }}); + + for (int i = 0; i < Config::CUSTOM_BUTTON_COUNT; i++) { + char temp[256]; + snprintf(temp, sizeof(temp), "Custom %d", i + 1); + toggles_.push_back({ temp, &g_Config.touchCustom[i].show, ImageID::invalid(), [=](EventParams &e) { + screenManager()->push(new CustomButtonMappingScreen(gamePath_, i)); + return UI::EVENT_DONE; + } }); + } auto mc = GetI18NCategory(I18NCat::MAPPABLECONTROLS); for (auto toggle : toggles_) { @@ -139,7 +108,7 @@ void TouchControlVisibilityScreen::CreateViews() { row->Add(checkbox); Choice *choice; if (toggle.handle) { - choice = new Choice(std::string(mc->T(toggle.key))+" ("+mc->T("tap to customize")+")", "", false, new LinearLayoutParams(1.0f)); + choice = new Choice(std::string(mc->T(toggle.key)) + " (" + mc->T("tap to customize") + ")", "", false, new LinearLayoutParams(1.0f)); choice->OnClick.Add(toggle.handle); } else if (toggle.img.isValid()) { choice = new CheckBoxChoice(toggle.img, checkbox, new LinearLayoutParams(1.0f)); diff --git a/UI/TouchControlVisibilityScreen.h b/UI/TouchControlVisibilityScreen.h index c21efbde8f..f528627351 100644 --- a/UI/TouchControlVisibilityScreen.h +++ b/UI/TouchControlVisibilityScreen.h @@ -25,7 +25,7 @@ namespace UI { } struct TouchButtonToggle { - const char *key; + std::string key; bool *show; ImageID img; std::function handle;