summaryrefslogtreecommitdiff
path: root/core/input
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-10 13:43:44 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-01-10 14:39:05 +0200
commit61ea8f83377952a8ca8e1cb5cf8ec1099ca8369f (patch)
treed64d786ecf9f88172ea61cf94f6e3498b27b5240 /core/input
parent5f7bbf4d333ec4a7473a8e720de57bc8cbadd469 (diff)
Add joystick button index boundary check. Increase max. button number to 128 (max. buttons supported by DirectInput).
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input.cpp3
-rw-r--r--core/input/input_enums.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp
index c5540f926d..507a686cab 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -892,7 +892,8 @@ void Input::set_event_dispatch_function(EventDispatchFunc p_function) {
void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) {
_THREAD_SAFE_METHOD_;
Joypad &joy = joy_names[p_device];
- //printf("got button %i, mapping is %i\n", p_button, joy.mapping);
+ ERR_FAIL_INDEX((int)p_button, (int)JoyButton::MAX);
+
if (joy.last_buttons[(size_t)p_button] == p_pressed) {
return;
}
diff --git a/core/input/input_enums.h b/core/input/input_enums.h
index aa55316ec8..0282de2176 100644
--- a/core/input/input_enums.h
+++ b/core/input/input_enums.h
@@ -83,7 +83,7 @@ enum class JoyButton {
PADDLE4 = 19,
TOUCHPAD = 20,
SDL_MAX = 21,
- MAX = 36, // Android supports up to 36 buttons.
+ MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons.
};
enum class MIDIMessage {