You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Add joystick button index boundary check. Increase max. button number to 128 (max. buttons supported by DirectInput).
This commit is contained in:
@@ -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) {
|
void Input::joy_button(int p_device, JoyButton p_button, bool p_pressed) {
|
||||||
_THREAD_SAFE_METHOD_;
|
_THREAD_SAFE_METHOD_;
|
||||||
Joypad &joy = joy_names[p_device];
|
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) {
|
if (joy.last_buttons[(size_t)p_button] == p_pressed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ enum class JoyButton {
|
|||||||
PADDLE4 = 19,
|
PADDLE4 = 19,
|
||||||
TOUCHPAD = 20,
|
TOUCHPAD = 20,
|
||||||
SDL_MAX = 21,
|
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 {
|
enum class MIDIMessage {
|
||||||
|
|||||||
@@ -2134,8 +2134,11 @@
|
|||||||
<constant name="JOY_BUTTON_SDL_MAX" value="21" enum="JoyButton">
|
<constant name="JOY_BUTTON_SDL_MAX" value="21" enum="JoyButton">
|
||||||
The number of SDL game controller buttons.
|
The number of SDL game controller buttons.
|
||||||
</constant>
|
</constant>
|
||||||
<constant name="JOY_BUTTON_MAX" value="36" enum="JoyButton">
|
<constant name="JOY_BUTTON_MAX" value="128" enum="JoyButton">
|
||||||
The maximum number of game controller buttons: Android supports up to 36 buttons.
|
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>
|
||||||
<constant name="JOY_AXIS_INVALID" value="-1" enum="JoyAxis">
|
<constant name="JOY_AXIS_INVALID" value="-1" enum="JoyAxis">
|
||||||
An invalid game controller axis.
|
An invalid game controller axis.
|
||||||
|
|||||||
Reference in New Issue
Block a user