Skip to content

Commit

Permalink
Merge pull request #17604 from hrydgard/more-custom-buttons
Browse files Browse the repository at this point in the history
More custom touch buttons (20)
  • Loading branch information
hrydgard committed Jun 20, 2023
2 parents 56e5cbe + 91aa940 commit d7e4055
Show file tree
Hide file tree
Showing 52 changed files with 176 additions and 708 deletions.
75 changes: 44 additions & 31 deletions Core/Config.cpp
Expand Up @@ -637,27 +637,47 @@ 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),
// 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("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),
ConfigSetting("Custom10Mapping", "Custom10Image", "Custom10Shape", "Custom10Toggle", "Custom10Repeat", &g_Config.CustomButton[10], {0, 0, 2, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom11Mapping", "Custom11Image", "Custom11Shape", "Custom11Toggle", "Custom11Repeat", &g_Config.CustomButton[11], {0, 1, 2, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom12Mapping", "Custom12Image", "Custom12Shape", "Custom12Toggle", "Custom12Repeat", &g_Config.CustomButton[12], {0, 2, 2, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom13Mapping", "Custom13Image", "Custom13Shape", "Custom13Toggle", "Custom13Repeat", &g_Config.CustomButton[13], {0, 3, 2, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom14Mapping", "Custom14Image", "Custom14Shape", "Custom14Toggle", "Custom14Repeat", &g_Config.CustomButton[14], {0, 4, 2, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom15Mapping", "Custom15Image", "Custom15Shape", "Custom15Toggle", "Custom15Repeat", &g_Config.CustomButton[15], {0, 0, 9, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom16Mapping", "Custom16Image", "Custom16Shape", "Custom16Toggle", "Custom16Repeat", &g_Config.CustomButton[16], {0, 1, 9, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom17Mapping", "Custom17Image", "Custom17Shape", "Custom17Toggle", "Custom17Repeat", &g_Config.CustomButton[17], {0, 2, 9, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom18Mapping", "Custom18Image", "Custom18Shape", "Custom18Toggle", "Custom18Repeat", &g_Config.CustomButton[18], {0, 3, 9, false, false}, CfgFlag::PER_GAME),
ConfigSetting("Custom19Mapping", "Custom19Image", "Custom19Shape", "Custom19Toggle", "Custom19Repeat", &g_Config.CustomButton[19], {0, 4, 9, false, false}, CfgFlag::PER_GAME),
// Combo keys are something else, but I don't want to break the config backwards compatibility so these will stay wrongly named.
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),
ConfigSetting("fcombo10X", "fcombo10Y", "comboKeyScale10", "ShowComboKey10", &g_Config.touchCustom[10], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo11X", "fcombo11Y", "comboKeyScale11", "ShowComboKey11", &g_Config.touchCustom[11], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo12X", "fcombo12Y", "comboKeyScale12", "ShowComboKey12", &g_Config.touchCustom[12], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo13X", "fcombo13Y", "comboKeyScale13", "ShowComboKey13", &g_Config.touchCustom[13], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo14X", "fcombo14Y", "comboKeyScale14", "ShowComboKey14", &g_Config.touchCustom[14], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo15X", "fcombo15Y", "comboKeyScale15", "ShowComboKey15", &g_Config.touchCustom[15], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo16X", "fcombo16Y", "comboKeyScale16", "ShowComboKey16", &g_Config.touchCustom[16], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo17X", "fcombo17Y", "comboKeyScale17", "ShowComboKey17", &g_Config.touchCustom[17], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo18X", "fcombo18Y", "comboKeyScale18", "ShowComboKey18", &g_Config.touchCustom[18], defaultTouchPosHide, CfgFlag::PER_GAME),
ConfigSetting("fcombo19X", "fcombo19Y", "comboKeyScale19", "ShowComboKey19", &g_Config.touchCustom[19], defaultTouchPosHide, CfgFlag::PER_GAME),

#if defined(_WIN32)
// A win32 user seeing touch controls is likely using PPSSPP on a tablet. There it makes
Expand Down Expand Up @@ -1707,16 +1727,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;
}
Expand Down
24 changes: 4 additions & 20 deletions Core/Config.h
Expand Up @@ -341,16 +341,9 @@ struct Config {
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 = 20 };

ConfigTouchPos touchCustom[CUSTOM_BUTTON_COUNT];

float fLeftStickHeadScale;
float fRightStickHeadScale;
Expand All @@ -364,16 +357,7 @@ struct Config {
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;
Expand Down
16 changes: 8 additions & 8 deletions Tools/langtool/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 6 additions & 98 deletions UI/CustomButtonMappingScreen.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit d7e4055

Please sign in to comment.