Update joy button and stick names, enums and documentation

This commit is contained in:
Marcel Admiraal 2020-11-18 09:44:25 +00:00
parent b115ea4c28
commit 20f2b71e21
6 changed files with 68 additions and 336 deletions

View File

@ -409,7 +409,7 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(BUTTON_MASK_XBUTTON2); BIND_CORE_ENUM_CONSTANT(BUTTON_MASK_XBUTTON2);
// Joypad buttons // Joypad buttons
BIND_CORE_ENUM_CONSTANT(JOY_INVALID_BUTTON); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_INVALID);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_A); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_A);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_B); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_B);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_X); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_X);
@ -425,51 +425,18 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_DOWN); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_DOWN);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_LEFT); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_LEFT);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_RIGHT); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_DPAD_RIGHT);
BIND_CORE_ENUM_CONSTANT(JOY_SDL_BUTTONS); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_SDL_MAX);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_X);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_CROSS);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_CIRCLE);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_SQUARE);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_TRIANGLE);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_SELECT);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_START);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_PS);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_L1);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_R1);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_L3);
BIND_CORE_ENUM_CONSTANT(JOY_SONY_R3);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_A);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_B);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_X);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_Y);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_BACK);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_START);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_HOME);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_LS);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_RS);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_LB);
BIND_CORE_ENUM_CONSTANT(JOY_XBOX_RB);
BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_MAX); BIND_CORE_ENUM_CONSTANT(JOY_BUTTON_MAX);
// Joypad axes // Joypad axes
BIND_CORE_ENUM_CONSTANT(JOY_INVALID_AXIS); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_INVALID);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_LEFT_X); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_LEFT_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_LEFT_Y); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_LEFT_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_RIGHT_X); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_RIGHT_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_RIGHT_Y); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_RIGHT_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_TRIGGER_LEFT); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_TRIGGER_LEFT);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_TRIGGER_RIGHT); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_TRIGGER_RIGHT);
BIND_CORE_ENUM_CONSTANT(JOY_SDL_AXES); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_SDL_MAX);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_0_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_0_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_1_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_1_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_2_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_2_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_3_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_3_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_4_X);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_4_Y);
BIND_CORE_ENUM_CONSTANT(JOY_AXIS_MAX); BIND_CORE_ENUM_CONSTANT(JOY_AXIS_MAX);
// midi // midi

View File

@ -39,7 +39,7 @@
#include "editor/editor_settings.h" #include "editor/editor_settings.h"
#endif #endif
static const char *_joy_buttons[JOY_SDL_BUTTONS + 1] = { static const char *_joy_buttons[JOY_BUTTON_SDL_MAX] = {
"a", "a",
"b", "b",
"x", "x",
@ -55,69 +55,15 @@ static const char *_joy_buttons[JOY_SDL_BUTTONS + 1] = {
"dpdown", "dpdown",
"dpleft", "dpleft",
"dpright", "dpright",
nullptr
}; };
static const char *_joy_button_names[JOY_BUTTON_MAX] = { static const char *_joy_axes[JOY_AXIS_SDL_MAX] = {
"Face Bottom",
"Face Right",
"Face Left",
"Face Top",
"Select",
"Guide",
"Start",
"Left Stick",
"Right Stick",
"Left Shoulder",
"Right Shoulder",
"D-Pad Up",
"D-Pad Down",
"D-Pad Left",
"D-Pad Right",
"Button 15",
"Button 16",
"Button 17",
"Button 18",
"Button 19",
"Button 20",
"Button 21",
"Button 22",
"Button 23",
"Button 24",
"Button 25",
"Button 26",
"Button 27",
"Button 28",
"Button 29",
"Button 30",
"Button 31",
"Button 32",
"Button 33",
"Button 34",
"Button 35"
};
static const char *_joy_axes[JOY_SDL_AXES + 1] = {
"leftx", "leftx",
"lefty", "lefty",
"rightx", "rightx",
"righty", "righty",
"lefttrigger", "lefttrigger",
"righttrigger", "righttrigger",
nullptr
};
static const char *_joy_axis_names[JOY_AXIS_MAX] = {
"Left Stick X",
"Left Stick Y",
"Right Stick X",
"Right Stick Y",
"Left Trigger",
"Right Trigger",
"Joystick 3 Stick X",
"Joystick 3 Stick Y",
"Joystick 4 Stick X",
"Joystick 4 Stick Y"
}; };
Input *Input::singleton = nullptr; Input *Input::singleton = nullptr;
@ -162,10 +108,6 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_connected_joypads"), &Input::get_connected_joypads); ClassDB::bind_method(D_METHOD("get_connected_joypads"), &Input::get_connected_joypads);
ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength); ClassDB::bind_method(D_METHOD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength);
ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration); ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
ClassDB::bind_method(D_METHOD("get_joy_button_string", "button_index"), &Input::get_joy_button_string);
ClassDB::bind_method(D_METHOD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string);
ClassDB::bind_method(D_METHOD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string);
ClassDB::bind_method(D_METHOD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string);
ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0)); ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration); ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500)); ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500));
@ -1226,21 +1168,21 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, J
} }
JoyButtonList Input::_get_output_button(String output) { JoyButtonList Input::_get_output_button(String output) {
for (int i = 0; _joy_buttons[i]; i++) { for (int i = 0; i < JOY_BUTTON_SDL_MAX; i++) {
if (output == _joy_buttons[i]) { if (output == _joy_buttons[i]) {
return JoyButtonList(i); return JoyButtonList(i);
} }
} }
return JoyButtonList::JOY_INVALID_BUTTON; return JoyButtonList::JOY_BUTTON_INVALID;
} }
JoyAxisList Input::_get_output_axis(String output) { JoyAxisList Input::_get_output_axis(String output) {
for (int i = 0; _joy_axes[i]; i++) { for (int i = 0; i < JOY_AXIS_SDL_MAX; i++) {
if (output == _joy_axes[i]) { if (output == _joy_axes[i]) {
return JoyAxisList(i); return JoyAxisList(i);
} }
} }
return JoyAxisList::JOY_INVALID_AXIS; return JoyAxisList::JOY_AXIS_INVALID;
} }
void Input::parse_mapping(String p_mapping) { void Input::parse_mapping(String p_mapping) {
@ -1300,16 +1242,16 @@ void Input::parse_mapping(String p_mapping) {
JoyButtonList output_button = _get_output_button(output); JoyButtonList output_button = _get_output_button(output);
JoyAxisList output_axis = _get_output_axis(output); JoyAxisList output_axis = _get_output_axis(output);
ERR_CONTINUE_MSG(output_button == JOY_INVALID_BUTTON && output_axis == JOY_INVALID_AXIS, ERR_CONTINUE_MSG(output_button == JOY_BUTTON_INVALID && output_axis == JOY_AXIS_INVALID,
String(entry[idx] + "\nUnrecognised output string: " + output)); String(entry[idx] + "\nUnrecognised output string: " + output));
ERR_CONTINUE_MSG(output_button != JOY_INVALID_BUTTON && output_axis != JOY_INVALID_AXIS, ERR_CONTINUE_MSG(output_button != JOY_BUTTON_INVALID && output_axis != JOY_AXIS_INVALID,
String("BUG: Output string matched both button and axis: " + output)); String("BUG: Output string matched both button and axis: " + output));
JoyBinding binding; JoyBinding binding;
if (output_button != JOY_INVALID_BUTTON) { if (output_button != JOY_BUTTON_INVALID) {
binding.outputType = TYPE_BUTTON; binding.outputType = TYPE_BUTTON;
binding.output.button = output_button; binding.output.button = output_button;
} else if (output_axis != JOY_INVALID_AXIS) { } else if (output_axis != JOY_AXIS_INVALID) {
binding.outputType = TYPE_AXIS; binding.outputType = TYPE_AXIS;
binding.output.axis.axis = output_axis; binding.output.axis.axis = output_axis;
binding.output.axis.range = output_range; binding.output.axis.range = output_range;
@ -1401,20 +1343,6 @@ Array Input::get_connected_joypads() {
return ret; return ret;
} }
String Input::get_joy_button_string(int p_button) {
ERR_FAIL_INDEX_V(p_button, JOY_BUTTON_MAX, "Invalid button");
return _joy_button_names[p_button];
}
int Input::get_joy_button_index_from_string(String p_button) {
for (int i = 0; i < JOY_BUTTON_MAX; i++) {
if (p_button == _joy_button_names[i]) {
return i;
}
}
ERR_FAIL_V(JOY_INVALID_BUTTON);
}
int Input::get_unused_joy_id() { int Input::get_unused_joy_id() {
for (int i = 0; i < JOYPADS_MAX; i++) { for (int i = 0; i < JOYPADS_MAX; i++) {
if (!joy_names.has(i) || !joy_names[i].connected) { if (!joy_names.has(i) || !joy_names[i].connected) {
@ -1424,20 +1352,6 @@ int Input::get_unused_joy_id() {
return -1; return -1;
} }
String Input::get_joy_axis_string(int p_axis) {
ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, "Invalid axis");
return _joy_axis_names[p_axis];
}
int Input::get_joy_axis_index_from_string(String p_axis) {
for (int i = 0; i < JOY_AXIS_MAX; i++) {
if (p_axis == _joy_axis_names[i]) {
return i;
}
}
ERR_FAIL_V(JOY_INVALID_AXIS);
}
Input::Input() { Input::Input() {
singleton = this; singleton = this;

View File

@ -330,11 +330,6 @@ public:
void add_joy_mapping(String p_mapping, bool p_update_existing = false); void add_joy_mapping(String p_mapping, bool p_update_existing = false);
void remove_joy_mapping(String p_guid); void remove_joy_mapping(String p_guid);
String get_joy_button_string(int p_button);
String get_joy_axis_string(int p_axis);
int get_joy_axis_index_from_string(String p_axis);
int get_joy_button_index_from_string(String p_button);
int get_unused_joy_id(); int get_unused_joy_id();
bool is_joy_known(int p_device); bool is_joy_known(int p_device);

View File

@ -60,9 +60,7 @@ enum ButtonList {
}; };
enum JoyButtonList { enum JoyButtonList {
JOY_INVALID_BUTTON = -1, JOY_BUTTON_INVALID = -1,
// SDL Buttons
JOY_BUTTON_A = 0, JOY_BUTTON_A = 0,
JOY_BUTTON_B = 1, JOY_BUTTON_B = 1,
JOY_BUTTON_X = 2, JOY_BUTTON_X = 2,
@ -78,63 +76,20 @@ enum JoyButtonList {
JOY_BUTTON_DPAD_DOWN = 12, JOY_BUTTON_DPAD_DOWN = 12,
JOY_BUTTON_DPAD_LEFT = 13, JOY_BUTTON_DPAD_LEFT = 13,
JOY_BUTTON_DPAD_RIGHT = 14, JOY_BUTTON_DPAD_RIGHT = 14,
JOY_SDL_BUTTONS = 15, JOY_BUTTON_SDL_MAX = 15,
JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
// Sony Buttons
JOY_SONY_X = JOY_BUTTON_A,
JOY_SONY_CROSS = JOY_BUTTON_A,
JOY_SONY_CIRCLE = JOY_BUTTON_B,
JOY_SONY_SQUARE = JOY_BUTTON_X,
JOY_SONY_TRIANGLE = JOY_BUTTON_Y,
JOY_SONY_SELECT = JOY_BUTTON_BACK,
JOY_SONY_START = JOY_BUTTON_START,
JOY_SONY_PS = JOY_BUTTON_GUIDE,
JOY_SONY_L1 = JOY_BUTTON_LEFT_SHOULDER,
JOY_SONY_R1 = JOY_BUTTON_RIGHT_SHOULDER,
JOY_SONY_L3 = JOY_BUTTON_LEFT_STICK,
JOY_SONY_R3 = JOY_BUTTON_RIGHT_STICK,
// Xbox Buttons
JOY_XBOX_A = JOY_BUTTON_A,
JOY_XBOX_B = JOY_BUTTON_B,
JOY_XBOX_X = JOY_BUTTON_X,
JOY_XBOX_Y = JOY_BUTTON_Y,
JOY_XBOX_BACK = JOY_BUTTON_BACK,
JOY_XBOX_START = JOY_BUTTON_START,
JOY_XBOX_HOME = JOY_BUTTON_GUIDE,
JOY_XBOX_LS = JOY_BUTTON_LEFT_STICK,
JOY_XBOX_RS = JOY_BUTTON_RIGHT_STICK,
JOY_XBOX_LB = JOY_BUTTON_LEFT_SHOULDER,
JOY_XBOX_RB = JOY_BUTTON_RIGHT_SHOULDER,
JOY_BUTTON_MAX = 36 // Apparently Android supports up to 36 buttons.
}; };
enum JoyAxisList { enum JoyAxisList {
JOY_INVALID_AXIS = -1, JOY_AXIS_INVALID = -1,
// SDL Axes
JOY_AXIS_LEFT_X = 0, JOY_AXIS_LEFT_X = 0,
JOY_AXIS_LEFT_Y = 1, JOY_AXIS_LEFT_Y = 1,
JOY_AXIS_RIGHT_X = 2, JOY_AXIS_RIGHT_X = 2,
JOY_AXIS_RIGHT_Y = 3, JOY_AXIS_RIGHT_Y = 3,
JOY_AXIS_TRIGGER_LEFT = 4, JOY_AXIS_TRIGGER_LEFT = 4,
JOY_AXIS_TRIGGER_RIGHT = 5, JOY_AXIS_TRIGGER_RIGHT = 5,
JOY_SDL_AXES = 6, JOY_AXIS_SDL_MAX = 6,
JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
// Joystick axes.
JOY_AXIS_0_X = 0,
JOY_AXIS_0_Y = 1,
JOY_AXIS_1_X = 2,
JOY_AXIS_1_Y = 3,
JOY_AXIS_2_X = 4,
JOY_AXIS_2_Y = 5,
JOY_AXIS_3_X = 6,
JOY_AXIS_3_Y = 7,
JOY_AXIS_4_X = 8,
JOY_AXIS_4_Y = 9,
JOY_AXIS_MAX = 10 // OpenVR supports up to 5 Joysticks making a total of 10 axes.
}; };
enum MidiMessageList { enum MidiMessageList {

View File

@ -2093,130 +2093,61 @@
<constant name="BUTTON_MASK_XBUTTON2" value="256" enum="ButtonList"> <constant name="BUTTON_MASK_XBUTTON2" value="256" enum="ButtonList">
Extra mouse button 2 mask. Extra mouse button 2 mask.
</constant> </constant>
<constant name="JOY_INVALID_BUTTON" value="-1" enum="JoyButtonList"> <constant name="JOY_BUTTON_INVALID" value="-1" enum="JoyButtonList">
An invalid game controller button. An invalid game controller button.
</constant> </constant>
<constant name="JOY_BUTTON_A" value="0" enum="JoyButtonList"> <constant name="JOY_BUTTON_A" value="0" enum="JoyButtonList">
Game controller SDL button A. Game controller SDL button A. Corresponds to the bottom action button: Sony Cross, Xbox A, Nintendo B.
</constant> </constant>
<constant name="JOY_BUTTON_B" value="1" enum="JoyButtonList"> <constant name="JOY_BUTTON_B" value="1" enum="JoyButtonList">
Game controller SDL button B. Game controller SDL button B. Corresponds to the right action button: Sony Circle, Xbox B, Nintendo A.
</constant> </constant>
<constant name="JOY_BUTTON_X" value="2" enum="JoyButtonList"> <constant name="JOY_BUTTON_X" value="2" enum="JoyButtonList">
Game controller SDL button X. Game controller SDL button X. Corresponds to the left action button: Sony Square, Xbox X, Nintendo Y.
</constant> </constant>
<constant name="JOY_BUTTON_Y" value="3" enum="JoyButtonList"> <constant name="JOY_BUTTON_Y" value="3" enum="JoyButtonList">
Game controller SDL button Y. Game controller SDL button Y. Corresponds to the top action button: Sony Triangle, Xbox Y, Nintendo X.
</constant> </constant>
<constant name="JOY_BUTTON_BACK" value="4" enum="JoyButtonList"> <constant name="JOY_BUTTON_BACK" value="4" enum="JoyButtonList">
Game controller SDL back button. Game controller SDL back button. Corresponds to the Sony Select, Xbox Back, Nintendo - button.
</constant> </constant>
<constant name="JOY_BUTTON_GUIDE" value="5" enum="JoyButtonList"> <constant name="JOY_BUTTON_GUIDE" value="5" enum="JoyButtonList">
Game controller SDL guide button. Game controller SDL guide button. Corresponds to the Sony PS, Xbox Home button.
</constant> </constant>
<constant name="JOY_BUTTON_START" value="6" enum="JoyButtonList"> <constant name="JOY_BUTTON_START" value="6" enum="JoyButtonList">
Game controller SDL start button. Game controller SDL start button. Corresponds to the Nintendo + button.
</constant> </constant>
<constant name="JOY_BUTTON_LEFT_STICK" value="7" enum="JoyButtonList"> <constant name="JOY_BUTTON_LEFT_STICK" value="7" enum="JoyButtonList">
Game controller SDL left stick button. Game controller SDL left stick button. Corresponds to the Sony L3, Xbox L/LS button.
</constant> </constant>
<constant name="JOY_BUTTON_RIGHT_STICK" value="8" enum="JoyButtonList"> <constant name="JOY_BUTTON_RIGHT_STICK" value="8" enum="JoyButtonList">
Game controller SDL right stick button. Game controller SDL right stick button. Corresponds to the Sony R3, Xbox R/RS button.
</constant> </constant>
<constant name="JOY_BUTTON_LEFT_SHOULDER" value="9" enum="JoyButtonList"> <constant name="JOY_BUTTON_LEFT_SHOULDER" value="9" enum="JoyButtonList">
Game controller SDL left shoulder button. Game controller SDL left shoulder button. Corresponds to the Sony L1, Xbox LB button.
</constant> </constant>
<constant name="JOY_BUTTON_RIGHT_SHOULDER" value="10" enum="JoyButtonList"> <constant name="JOY_BUTTON_RIGHT_SHOULDER" value="10" enum="JoyButtonList">
Game controller SDL right shoulder button. Game controller SDL right shoulder button. Corresponds to the Sony R1, Xbox RB button.
</constant> </constant>
<constant name="JOY_BUTTON_DPAD_UP" value="11" enum="JoyButtonList"> <constant name="JOY_BUTTON_DPAD_UP" value="11" enum="JoyButtonList">
Game controller SDL D-pad up button. Game controller D-pad up button.
</constant> </constant>
<constant name="JOY_BUTTON_DPAD_DOWN" value="12" enum="JoyButtonList"> <constant name="JOY_BUTTON_DPAD_DOWN" value="12" enum="JoyButtonList">
Game controller SDL D-pad down button. Game controller D-pad down button.
</constant> </constant>
<constant name="JOY_BUTTON_DPAD_LEFT" value="13" enum="JoyButtonList"> <constant name="JOY_BUTTON_DPAD_LEFT" value="13" enum="JoyButtonList">
Game controller SDL D-pad left button. Game controller D-pad left button.
</constant> </constant>
<constant name="JOY_BUTTON_DPAD_RIGHT" value="14" enum="JoyButtonList"> <constant name="JOY_BUTTON_DPAD_RIGHT" value="14" enum="JoyButtonList">
Game controller SDL D-pad right button. Game controller D-pad right button.
</constant> </constant>
<constant name="JOY_SDL_BUTTONS" value="15" enum="JoyButtonList"> <constant name="JOY_BUTTON_SDL_MAX" value="15" enum="JoyButtonList">
The number of SDL game controller buttons. The number of SDL game controller buttons.
</constant> </constant>
<constant name="JOY_SONY_X" value="0" enum="JoyButtonList">
Sony DualShock controller X button maps to SDL button A.
</constant>
<constant name="JOY_SONY_CROSS" value="0" enum="JoyButtonList">
Sony DualShock controller cross button maps to SDL button A.
</constant>
<constant name="JOY_SONY_CIRCLE" value="1" enum="JoyButtonList">
Sony DualShock controller circle button maps to SDL button B.
</constant>
<constant name="JOY_SONY_SQUARE" value="2" enum="JoyButtonList">
Sony DualShock controller square button maps to SDL button X.
</constant>
<constant name="JOY_SONY_TRIANGLE" value="3" enum="JoyButtonList">
Sony DualShock controller triangle button maps to SDL button Y.
</constant>
<constant name="JOY_SONY_SELECT" value="4" enum="JoyButtonList">
Sony DualShock controller select button maps to SDL back button.
</constant>
<constant name="JOY_SONY_START" value="6" enum="JoyButtonList">
Sony DualShock controller start button maps to SDL start button.
</constant>
<constant name="JOY_SONY_PS" value="5" enum="JoyButtonList">
Sony DualShock controller PS button maps to SDL guide button.
</constant>
<constant name="JOY_SONY_L1" value="9" enum="JoyButtonList">
Sony DualShock controller L1 button maps to SDL left shoulder button.
</constant>
<constant name="JOY_SONY_R1" value="10" enum="JoyButtonList">
Sony DualShock controller R1 button maps to SDL right shoulder button.
</constant>
<constant name="JOY_SONY_L3" value="7" enum="JoyButtonList">
Sony DualShock controller L3 button maps to SDL left stick button.
</constant>
<constant name="JOY_SONY_R3" value="8" enum="JoyButtonList">
Sony DualShock controller R3 button maps to SDL right stick button.
</constant>
<constant name="JOY_XBOX_A" value="0" enum="JoyButtonList">
Xbox game controller A button maps to SDL button A.
</constant>
<constant name="JOY_XBOX_B" value="1" enum="JoyButtonList">
Xbox game controller B button maps to SDL button B.
</constant>
<constant name="JOY_XBOX_X" value="2" enum="JoyButtonList">
Xbox game controller X button maps to SDL button X.
</constant>
<constant name="JOY_XBOX_Y" value="3" enum="JoyButtonList">
Xbox game controller Y button maps to SDL button Y.
</constant>
<constant name="JOY_XBOX_BACK" value="4" enum="JoyButtonList">
Xbox game controller back button maps to SDL back button.
</constant>
<constant name="JOY_XBOX_START" value="6" enum="JoyButtonList">
Xbox game controller start button maps to SDL start button.
</constant>
<constant name="JOY_XBOX_HOME" value="5" enum="JoyButtonList">
Xbox game controller home button maps to SDL guide button.
</constant>
<constant name="JOY_XBOX_LS" value="7" enum="JoyButtonList">
Xbox game controller left stick button maps to SDL left stick button.
</constant>
<constant name="JOY_XBOX_RS" value="8" enum="JoyButtonList">
Xbox game controller right stick button maps to SDL right stick button.
</constant>
<constant name="JOY_XBOX_LB" value="9" enum="JoyButtonList">
Xbox game controller left bumper button maps to SDL left shoulder button.
</constant>
<constant name="JOY_XBOX_RB" value="10" enum="JoyButtonList">
Xbox game controller right bumper button maps to SDL right shoulder button.
</constant>
<constant name="JOY_BUTTON_MAX" value="36" enum="JoyButtonList"> <constant name="JOY_BUTTON_MAX" value="36" enum="JoyButtonList">
The maximum number of game controller buttons. The maximum number of game controller buttons: Android supports up to 36 buttons.
</constant> </constant>
<constant name="JOY_INVALID_AXIS" value="-1" enum="JoyAxisList"> <constant name="JOY_AXIS_INVALID" value="-1" enum="JoyAxisList">
An invalid game controller axis. An invalid game controller axis.
</constant> </constant>
<constant name="JOY_AXIS_LEFT_X" value="0" enum="JoyAxisList"> <constant name="JOY_AXIS_LEFT_X" value="0" enum="JoyAxisList">
@ -2237,41 +2168,11 @@
<constant name="JOY_AXIS_TRIGGER_RIGHT" value="5" enum="JoyAxisList"> <constant name="JOY_AXIS_TRIGGER_RIGHT" value="5" enum="JoyAxisList">
Game controller right trigger axis. Game controller right trigger axis.
</constant> </constant>
<constant name="JOY_SDL_AXES" value="6" enum="JoyAxisList"> <constant name="JOY_AXIS_SDL_MAX" value="6" enum="JoyAxisList">
The number of SDL game controller axes. The number of SDL game controller axes.
</constant> </constant>
<constant name="JOY_AXIS_0_X" value="0" enum="JoyAxisList">
Game controller joystick 0 x-axis.
</constant>
<constant name="JOY_AXIS_0_Y" value="1" enum="JoyAxisList">
Game controller joystick 0 y-axis.
</constant>
<constant name="JOY_AXIS_1_X" value="2" enum="JoyAxisList">
Game controller joystick 1 x-axis.
</constant>
<constant name="JOY_AXIS_1_Y" value="3" enum="JoyAxisList">
Game controller joystick 1 y-axis.
</constant>
<constant name="JOY_AXIS_2_X" value="4" enum="JoyAxisList">
Game controller joystick 2 x-axis.
</constant>
<constant name="JOY_AXIS_2_Y" value="5" enum="JoyAxisList">
Game controller joystick 2 y-axis.
</constant>
<constant name="JOY_AXIS_3_X" value="6" enum="JoyAxisList">
Game controller joystick 3 x-axis.
</constant>
<constant name="JOY_AXIS_3_Y" value="7" enum="JoyAxisList">
Game controller joystick 3 y-axis.
</constant>
<constant name="JOY_AXIS_4_X" value="8" enum="JoyAxisList">
Game controller joystick 4 x-axis.
</constant>
<constant name="JOY_AXIS_4_Y" value="9" enum="JoyAxisList">
Game controller joystick 4 y-axis.
</constant>
<constant name="JOY_AXIS_MAX" value="10" enum="JoyAxisList"> <constant name="JOY_AXIS_MAX" value="10" enum="JoyAxisList">
The maximum number of game controller axes. The maximum number of game controller axes: OpenVR supports up to 5 Joysticks making a total of 10 axes.
</constant> </constant>
<constant name="MIDI_MESSAGE_NOTE_OFF" value="8" enum="MidiMessageList"> <constant name="MIDI_MESSAGE_NOTE_OFF" value="8" enum="MidiMessageList">
MIDI note OFF message. MIDI note OFF message.

View File

@ -35,37 +35,37 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
static const char *_button_descriptions[JOY_SDL_BUTTONS] = { static const char *_button_descriptions[JOY_BUTTON_SDL_MAX] = {
TTRC("Face Bottom, DualShock Cross, Xbox A, Nintendo B"), TTRC("Bottom Action, Sony Cross, Xbox A, Nintendo B"),
TTRC("Face Right, DualShock Circle, Xbox B, Nintendo A"), TTRC("Right Action, Sony Circle, Xbox B, Nintendo A"),
TTRC("Face Left, DualShock Square, Xbox X, Nintendo Y"), TTRC("Left Action, Sony Square, Xbox X, Nintendo Y"),
TTRC("Face Top, DualShock Triangle, Xbox Y, Nintendo X"), TTRC("Top Action, Sony Triangle, Xbox Y, Nintendo X"),
TTRC("DualShock Select, Xbox Back, Nintendo -"), TTRC("Back, Sony Select, Xbox Back, Nintendo -"),
TTRC("Home, DualShock PS, Guide"), TTRC("Guide, Sony PS, Xbox Home"),
TTRC("Start, Nintendo +"), TTRC("Start, Nintendo +"),
TTRC("Left Stick, DualShock L3, Xbox L/LS"), TTRC("Left Stick, Sony L3, Xbox L/LS"),
TTRC("Right Stick, DualShock R3, Xbox R/RS"), TTRC("Right Stick, Sony R3, Xbox R/RS"),
TTRC("Left Shoulder, DualShock L1, Xbox LB"), TTRC("Left Shoulder, Sony L1, Xbox LB"),
TTRC("Right Shoulder, DualShock R1, Xbox RB"), TTRC("Right Shoulder, Sony R1, Xbox RB"),
TTRC("D-Pad Up"), TTRC("D-pad Up"),
TTRC("D-Pad Down"), TTRC("D-pad Down"),
TTRC("D-Pad Left"), TTRC("D-pad Left"),
TTRC("D-Pad Right") TTRC("D-pad Right"),
}; };
static const char *_axis_descriptions[JOY_AXIS_MAX * 2] = { static const char *_axis_descriptions[JOY_AXIS_MAX * 2] = {
TTRC("Left Stick Left"), TTRC("Left Stick Left, Joystick 0 Left"),
TTRC("Left Stick Right"), TTRC("Left Stick Right, Joystick 0 Right"),
TTRC("Left Stick Up"), TTRC("Left Stick Up, Joystick 0 Up"),
TTRC("Left Stick Down"), TTRC("Left Stick Down, Joystick 0 Down"),
TTRC("Right Stick Left"), TTRC("Right Stick Left, Joystick 1 Left"),
TTRC("Right Stick Right"), TTRC("Right Stick Right, Joystick 1 Right"),
TTRC("Right Stick Up"), TTRC("Right Stick Up, Joystick 1 Up"),
TTRC("Right Stick Down"), TTRC("Right Stick Down, Joystick 1 Down"),
TTRC("Joystick 2 Left"), TTRC("Joystick 2 Left"),
TTRC("Joystick 2 Right, Left Trigger, L2, LT"), TTRC("Left Trigger, L2, LT, Joystick 2 Right"),
TTRC("Joystick 2 Up"), TTRC("Joystick 2 Up"),
TTRC("Joystick 2 Down, Right Trigger, R2, RT"), TTRC("Right Trigger, R2, RT, Joystick 2 Down"),
TTRC("Joystick 3 Left"), TTRC("Joystick 3 Left"),
TTRC("Joystick 3 Right"), TTRC("Joystick 3 Right"),
TTRC("Joystick 3 Up"), TTRC("Joystick 3 Up"),
@ -503,7 +503,7 @@ void InputMapEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) {
device_index->clear(); device_index->clear();
for (int i = 0; i < JOY_BUTTON_MAX; i++) { for (int i = 0; i < JOY_BUTTON_MAX; i++) {
String desc = TTR("Button") + " " + itos(i); String desc = TTR("Button") + " " + itos(i);
if (i < JOY_SDL_BUTTONS) { if (i < JOY_BUTTON_SDL_MAX) {
desc += " (" + TTR(_button_descriptions[i]) + ")"; desc += " (" + TTR(_button_descriptions[i]) + ")";
} }
device_index->add_item(desc); device_index->add_item(desc);
@ -717,7 +717,7 @@ void InputMapEditor::_update_actions() {
const int idx = jb->get_button_index(); const int idx = jb->get_button_index();
String str = _get_device_string(jb->get_device()) + ", " + String str = _get_device_string(jb->get_device()) + ", " +
TTR("Button") + " " + itos(idx); TTR("Button") + " " + itos(idx);
if (idx >= 0 && idx < JOY_SDL_BUTTONS) { if (idx >= 0 && idx < JOY_BUTTON_SDL_MAX) {
str += String() + " (" + TTR(_button_descriptions[jb->get_button_index()]) + ")"; str += String() + " (" + TTR(_button_descriptions[jb->get_button_index()]) + ")";
} }