Skip to content

Commit

Permalink
Merge pull request #59195 from Snowapril/fix_59175
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Mar 17, 2022
2 parents 72aa848 + c77b710 commit 88e2c51
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions main/input_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,11 +1338,14 @@ String InputDefault::get_joy_button_string(int p_button) {

int InputDefault::get_joy_button_index_from_string(String p_button) {
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
if (p_button == _buttons[i]) {
if (_buttons[i] == nullptr) {
break;
}
if (p_button == String(_buttons[i])) {
return i;
}
}
ERR_FAIL_V(-1);
ERR_FAIL_V_MSG(-1, vformat("Could not find a button index matching the string \"%s\".", p_button));
}

int InputDefault::get_unused_joy_id() {
Expand All @@ -1361,9 +1364,12 @@ String InputDefault::get_joy_axis_string(int p_axis) {

int InputDefault::get_joy_axis_index_from_string(String p_axis) {
for (int i = 0; i < JOY_AXIS_MAX; i++) {
if (p_axis == _axes[i]) {
if (_axes[i] == nullptr) {
break;
}
if (p_axis == String(_axes[i])) {
return i;
}
}
ERR_FAIL_V(-1);
ERR_FAIL_V_MSG(-1, vformat("Could not find an axis index matching the string \"%s\".", p_axis));
}

0 comments on commit 88e2c51

Please sign in to comment.