Add joystick button index boundary check. Increase max. button number to 128 (max. buttons supported by DirectInput).
(cherry picked from commit 61ea8f8337
)
This commit is contained in:
parent
e1f96d5ee8
commit
6eac65d4fe
|
@ -85,7 +85,7 @@ enum JoystickList {
|
|||
JOY_BUTTON_20 = 20,
|
||||
JOY_BUTTON_21 = 21,
|
||||
JOY_BUTTON_22 = 22,
|
||||
JOY_BUTTON_MAX = 23,
|
||||
JOY_BUTTON_MAX = 128, // Android supports up to 36 buttons. DirectInput supports up to 128 buttons.
|
||||
|
||||
JOY_L = JOY_BUTTON_4,
|
||||
JOY_R = JOY_BUTTON_5,
|
||||
|
|
|
@ -1015,8 +1015,11 @@
|
|||
<constant name="JOY_BUTTON_22" value="22" enum="JoystickList">
|
||||
Gamepad button 22.
|
||||
</constant>
|
||||
<constant name="JOY_BUTTON_MAX" value="23" enum="JoystickList">
|
||||
Represents the maximum number of joystick buttons supported.
|
||||
<constant name="JOY_BUTTON_MAX" value="128" enum="JoystickList">
|
||||
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_SONY_CIRCLE" value="1" enum="JoystickList">
|
||||
DualShock circle button.
|
||||
|
|
|
@ -775,7 +775,8 @@ InputDefault::InputDefault() {
|
|||
void InputDefault::joy_button(int p_device, int 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(p_button, JOY_BUTTON_MAX);
|
||||
|
||||
if (joy.last_buttons[p_button] == p_pressed) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue