Skip to content

Commit

Permalink
Validation fun
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp committed Feb 16, 2025
1 parent b49f70e commit d9375bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/gui/touchcontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,10 @@ TouchControls::~TouchControls()

bool TouchControls::mayAddButton(touch_gui_button_id id)
{
if (!ButtonLayout::isButtonAllowed(id))
return false;
if (id != overflow_id && id_to_keycode(id) == KEY_UNKNOWN)
return false;
return true;
assert(ButtonLayout::isButtonValid(id));
assert(ButtonLayout::isButtonAllowed(id));
// The overflow button doesn't need a keycode to be valid.
return id == overflow_id || id_to_keycode(id) != KEY_UNKNOWN;
}

void TouchControls::addButton(std::vector<button_info> &buttons, touch_gui_button_id id,
Expand Down
4 changes: 2 additions & 2 deletions src/gui/touchscreenlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ bool ButtonLayout::isButtonAllowed(touch_gui_button_id id)
if (id == dig_id || id == place_id)
return g_settings->get("touch_interaction_style") == buttons_crosshair;
if (id == aux1_id)
return g_settings->getBool("virtual_joystick_triggers_aux1");
return !g_settings->getBool("virtual_joystick_triggers_aux1");
return true;
}

Expand Down Expand Up @@ -293,7 +293,7 @@ std::vector<touch_gui_button_id> ButtonLayout::getMissingButtons()
std::vector<touch_gui_button_id> missing_buttons;
for (u8 i = 0; i < touch_gui_button_id_END; i++) {
touch_gui_button_id btn = (touch_gui_button_id)i;
if (isButtonAllowed(btn) && layout.count(btn) == 0)
if (isButtonValid(btn) && isButtonAllowed(btn) && layout.count(btn) == 0)
missing_buttons.push_back(btn);
}
return missing_buttons;
Expand Down

0 comments on commit d9375bb

Please sign in to comment.