summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-10 16:22:43 +0100
committerGitHub <noreply@github.com>2022-01-10 16:22:43 +0100
commite6cc0ff1a58bc8b8400b44149155ca19e1353866 (patch)
tree482279fbc378372e6c1a190686821c440e01b71f
parent04fa320650220aac62109b5916507fef9f6bb3f7 (diff)
parent61ea8f83377952a8ca8e1cb5cf8ec1099ca8369f (diff)
Merge pull request #56666 from bruvzg/joy_button_fix
-rw-r--r--core/input/input.cpp3
-rw-r--r--core/input/input_enums.h2
-rw-r--r--doc/classes/@GlobalScope.xml7
3 files changed, 8 insertions, 4 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 {
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 20a371c3d0..be7ac1164e 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -2134,8 +2134,11 @@
<constant name="JOY_BUTTON_SDL_MAX" value="21" enum="JoyButton">
The number of SDL game controller buttons.
</constant>
- <constant name="JOY_BUTTON_MAX" value="36" enum="JoyButton">
- The maximum number of game controller buttons: Android supports up to 36 buttons.
+ <constant name="JOY_BUTTON_MAX" value="128" enum="JoyButton">
+ The maximum number of game controller buttons supported by the engine. The actual limit may be lower on specific platforms:
+ - Android: Up to 36 buttons.
+ - Linux: Up to 80 buttons.
+ - Windows and macOS: Up to 128 buttons.
</constant>
<constant name="JOY_AXIS_INVALID" value="-1" enum="JoyAxis">
An invalid game controller axis.