From 3d479d086ce77b160bd8698bebcd61691e2c95dc Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sun, 7 Feb 2021 13:52:38 +0000 Subject: [PATCH] Add support for new SDL gamecontroller keywords. --- core/core_constants.cpp | 6 ++++++ core/input/input.cpp | 6 ++++++ core/input/input_event.cpp | 6 ++++++ core/input/input_event.h | 8 +++++++- doc/classes/@GlobalScope.xml | 20 +++++++++++++++++++- 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/core/core_constants.cpp b/core/core_constants.cpp index 3df121b9cb8..ef5dbf17bb5 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -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); diff --git a/core/input/input.cpp b/core/input/input.cpp index 2e3f112ebcc..047aeb47fda 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -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] = { diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 2771a15b801..c91dc4d0676 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -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 { diff --git a/core/input/input_event.h b/core/input/input_event.h index 1500faa24c4..a354119cf9f 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -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. }; diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index bf81362e796..e5bcc773fe4 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -2147,7 +2147,25 @@ Game controller D-pad right button. - + + Game controller SDL miscellaneous button. Corresponds to Xbox share button, PS5 microphone button, Nintendo capture button. + + + Game controller SDL paddle 1 button. + + + Game controller SDL paddle 2 button. + + + Game controller SDL paddle 3 button. + + + Game controller SDL paddle 4 button. + + + Game controller SDL touchpad button. + + The number of SDL game controller buttons.