Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase joystick max button number and fix crash. #56666

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion core/input/input_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down