Merge pull request #59195 from Snowapril/fix_59175

This commit is contained in:
Rémi Verschelde 2022-03-17 10:07:27 +01:00 committed by GitHub
commit 88e2c513e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1338,11 +1338,14 @@ String InputDefault::get_joy_button_string(int p_button) {
int InputDefault::get_joy_button_index_from_string(String p_button) { int InputDefault::get_joy_button_index_from_string(String p_button) {
for (int i = 0; i < JOY_BUTTON_MAX; i++) { 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; 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() { int InputDefault::get_unused_joy_id() {
@ -1361,9 +1364,12 @@ String InputDefault::get_joy_axis_string(int p_axis) {
int InputDefault::get_joy_axis_index_from_string(String p_axis) { int InputDefault::get_joy_axis_index_from_string(String p_axis) {
for (int i = 0; i < JOY_AXIS_MAX; i++) { 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; return i;
} }
} }
ERR_FAIL_V(-1); ERR_FAIL_V_MSG(-1, vformat("Could not find an axis index matching the string \"%s\".", p_axis));
} }