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

Add support for new SDL gamecontroller keywords. #45797

Merged
merged 1 commit into from
Feb 8, 2021
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
6 changes: 6 additions & 0 deletions core/core_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_DOWN);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_LEFT);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_RIGHT);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_MISC1);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE1);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE2);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE3);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_PADDLE4);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_TOUCHPAD);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_SDL_MAX);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_MAX);

Expand Down
6 changes: 6 additions & 0 deletions core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = {
"dpdown",
"dpleft",
"dpright",
"misc1",
"paddle1",
"paddle2",
"paddle3",
"paddle4",
"touchpad",
};

static const char *_joy_axes[JOY_AXIS_SDL_MAX] = {
Expand Down
6 changes: 6 additions & 0 deletions core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,12 @@ static const char *_joy_button_descriptions[JOY_BUTTON_SDL_MAX] = {
TTRC("D-pad Down"),
TTRC("D-pad Left"),
TTRC("D-pad Right"),
TTRC("Xbox Share, PS5 Microphone, Nintendo Capture"),
TTRC("Xbox Paddle 1"),
TTRC("Xbox Paddle 2"),
TTRC("Xbox Paddle 3"),
TTRC("Xbox Paddle 4"),
TTRC("PS4/5 Touchpad"),
};

String InputEventJoypadButton::as_text() const {
Expand Down
8 changes: 7 additions & 1 deletion core/input/input_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ enum JoyButtonList {
JOY_BUTTON_DPAD_DOWN = 12,
JOY_BUTTON_DPAD_LEFT = 13,
JOY_BUTTON_DPAD_RIGHT = 14,
JOY_BUTTON_SDL_MAX = 15,
JOY_BUTTON_MISC1 = 15,
JOY_BUTTON_PADDLE1 = 16,
JOY_BUTTON_PADDLE2 = 17,
JOY_BUTTON_PADDLE3 = 18,
JOY_BUTTON_PADDLE4 = 19,
JOY_BUTTON_TOUCHPAD = 20,
JOY_BUTTON_SDL_MAX = 21,
JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
};

Expand Down
20 changes: 19 additions & 1 deletion doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,25 @@
<constant name="JOY_BUTTON_DPAD_RIGHT" value="14" enum="JoyButtonList">
Game controller D-pad right button.
</constant>
<constant name="JOY_BUTTON_SDL_MAX" value="15" enum="JoyButtonList">
<constant name="JOY_BUTTON_MISC1" value="15" enum="JoyButtonList">
Game controller SDL miscellaneous button. Corresponds to Xbox share button, PS5 microphone button, Nintendo capture button.
</constant>
<constant name="JOY_BUTTON_PADDLE1" value="16" enum="JoyButtonList">
Game controller SDL paddle 1 button.
</constant>
<constant name="JOY_BUTTON_PADDLE2" value="17" enum="JoyButtonList">
Game controller SDL paddle 2 button.
</constant>
<constant name="JOY_BUTTON_PADDLE3" value="18" enum="JoyButtonList">
Game controller SDL paddle 3 button.
</constant>
<constant name="JOY_BUTTON_PADDLE4" value="19" enum="JoyButtonList">
Game controller SDL paddle 4 button.
</constant>
<constant name="JOY_BUTTON_TOUCHPAD" value="20" enum="JoyButtonList">
Game controller SDL touchpad button.
</constant>
<constant name="JOY_BUTTON_SDL_MAX" value="21" enum="JoyButtonList">
The number of SDL game controller buttons.
</constant>
<constant name="JOY_BUTTON_MAX" value="36" enum="JoyButtonList">
Expand Down