Custom buttons: sanitize image/shape on the one screen that didn't

CustomButtonMappingScreen indexes customKeyImages[36] and customKeyShapes[11] with
values read straight from the ini, and it's reachable from the main menu - so
neither GamepadEmu nor TouchControlLayoutScreen, which both sanitize first, need
have run. Those two had the same fixup copy-pasted; hoisted it into a Sanitize()
next to the tables and called it from all three.
This commit is contained in:
Henrik Rydgård
2026-09-02 18:06:47 +02:00
parent 329b7a15bd
commit dcbfa7d3ee
4 changed files with 17 additions and 12 deletions
+1 -6
View File
@@ -537,12 +537,7 @@ void ControlLayoutView::CreateViews() {
for (int i = 0; i < TouchControlConfig::CUSTOM_BUTTON_COUNT; i++) {
// Similar to GamepadEmu, we sanitize the images for valid values.
if (g_Config.CustomButton[i].shape >= ARRAY_SIZE(CustomKeyData::customKeyShapes)) {
g_Config.CustomButton[i].shape = 0;
}
if (g_Config.CustomButton[i].image >= ARRAY_SIZE(CustomKeyData::customKeyImages)) {
g_Config.CustomButton[i].image = 0;
}
CustomKeyData::Sanitize(g_Config.CustomButton[i]);
char temp[64];
snprintf(temp, sizeof(temp), "Custom %d button", i);