Rename some more global enums (Key, Joy, MIDI)

This commit is contained in:
Aaron Franke 2020-05-13 18:27:34 -04:00
parent 10d7fccb54
commit a5324787c8
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
27 changed files with 366 additions and 366 deletions

View file

@ -104,12 +104,12 @@ static Vector<_CoreConstant> _global_constants;
#endif #endif
VARIANT_ENUM_CAST(KeyList); VARIANT_ENUM_CAST(Key);
VARIANT_ENUM_CAST(KeyModifierMask); VARIANT_ENUM_CAST(KeyModifierMask);
VARIANT_ENUM_CAST(MouseButton); VARIANT_ENUM_CAST(MouseButton);
VARIANT_ENUM_CAST(JoyButtonList); VARIANT_ENUM_CAST(JoyButton);
VARIANT_ENUM_CAST(JoyAxisList); VARIANT_ENUM_CAST(JoyAxis);
VARIANT_ENUM_CAST(MidiMessageList); VARIANT_ENUM_CAST(MIDIMessage);
void register_global_constants() { void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(SIDE_LEFT); BIND_CORE_ENUM_CONSTANT(SIDE_LEFT);

View file

@ -907,7 +907,7 @@ void Input::joy_button(int p_device, int p_button, bool p_pressed) {
// no event? // no event?
} }
void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) { void Input::joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value) {
_THREAD_SAFE_METHOD_; _THREAD_SAFE_METHOD_;
ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX); ERR_FAIL_INDEX(p_axis, JOY_AXIS_MAX);
@ -921,12 +921,12 @@ void Input::joy_axis(int p_device, int p_axis, const JoyAxis &p_value) {
//when changing direction quickly, insert fake event to release pending inputmap actions //when changing direction quickly, insert fake event to release pending inputmap actions
float last = joy.last_axis[p_axis]; float last = joy.last_axis[p_axis];
if (p_value.min == 0 && (last < 0.25 || last > 0.75) && (last - 0.5) * (p_value.value - 0.5) < 0) { if (p_value.min == 0 && (last < 0.25 || last > 0.75) && (last - 0.5) * (p_value.value - 0.5) < 0) {
JoyAxis jx; JoyAxisValue jx;
jx.min = p_value.min; jx.min = p_value.min;
jx.value = p_value.value < 0.5 ? 0.6 : 0.4; jx.value = p_value.value < 0.5 ? 0.6 : 0.4;
joy_axis(p_device, p_axis, jx); joy_axis(p_device, p_axis, jx);
} else if (ABS(last) > 0.5 && last * p_value.value <= 0) { } else if (ABS(last) > 0.5 && last * p_value.value <= 0) {
JoyAxis jx; JoyAxisValue jx;
jx.min = p_value.min; jx.min = p_value.min;
jx.value = last > 0 ? 0.1 : -0.1; jx.value = last > 0 ? 0.1 : -0.1;
joy_axis(p_device, p_axis, jx); joy_axis(p_device, p_axis, jx);
@ -1206,22 +1206,22 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, J
} }
} }
JoyButtonList Input::_get_output_button(String output) { JoyButton Input::_get_output_button(String output) {
for (int i = 0; i < JOY_BUTTON_SDL_MAX; 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 JoyButton(i);
} }
} }
return JoyButtonList::JOY_BUTTON_INVALID; return JoyButton::JOY_BUTTON_INVALID;
} }
JoyAxisList Input::_get_output_axis(String output) { JoyAxis Input::_get_output_axis(String output) {
for (int i = 0; i < JOY_AXIS_SDL_MAX; 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 JoyAxis(i);
} }
} }
return JoyAxisList::JOY_AXIS_INVALID; return JoyAxis::JOY_AXIS_INVALID;
} }
void Input::parse_mapping(String p_mapping) { void Input::parse_mapping(String p_mapping) {
@ -1279,8 +1279,8 @@ void Input::parse_mapping(String p_mapping) {
input = input.left(input.length() - 1); input = input.left(input.length() - 1);
} }
JoyButtonList output_button = _get_output_button(output); JoyButton output_button = _get_output_button(output);
JoyAxisList output_axis = _get_output_axis(output); JoyAxis output_axis = _get_output_axis(output);
ERR_CONTINUE_MSG(output_button == JOY_BUTTON_INVALID && output_axis == JOY_AXIS_INVALID, 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_BUTTON_INVALID && output_axis != JOY_AXIS_INVALID, ERR_CONTINUE_MSG(output_button != JOY_BUTTON_INVALID && output_axis != JOY_AXIS_INVALID,

View file

@ -91,7 +91,7 @@ public:
JOYPADS_MAX = 16, JOYPADS_MAX = 16,
}; };
struct JoyAxis { struct JoyAxisValue {
int min; int min;
float value; float value;
}; };
@ -199,10 +199,10 @@ private:
JoyType outputType; JoyType outputType;
union { union {
JoyButtonList button; JoyButton button;
struct { struct {
JoyAxisList axis; JoyAxis axis;
JoyAxisRange range; JoyAxisRange range;
} axis; } axis;
@ -220,8 +220,8 @@ private:
JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button); JoyEvent _get_mapped_button_event(const JoyDeviceMapping &mapping, int p_button);
JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value); JoyEvent _get_mapped_axis_event(const JoyDeviceMapping &mapping, int p_axis, float p_value);
void _get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[HAT_MAX]); void _get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[HAT_MAX]);
JoyButtonList _get_output_button(String output); JoyButton _get_output_button(String output);
JoyAxisList _get_output_axis(String output); JoyAxis _get_output_axis(String output);
void _button_event(int p_device, int p_index, bool p_pressed); void _button_event(int p_device, int p_index, bool p_pressed);
void _axis_event(int p_device, int p_axis, float p_value); void _axis_event(int p_device, int p_axis, float p_value);
@ -325,7 +325,7 @@ public:
void parse_mapping(String p_mapping); void parse_mapping(String p_mapping);
void joy_button(int p_device, int p_button, bool p_pressed); void joy_button(int p_device, int p_button, bool p_pressed);
void joy_axis(int p_device, int p_axis, const JoyAxis &p_value); void joy_axis(int p_device, int p_axis, const JoyAxisValue &p_value);
void joy_hat(int p_device, int p_val); void joy_hat(int p_device, int p_val);
void add_joy_mapping(String p_mapping, bool p_update_existing = false); void add_joy_mapping(String p_mapping, bool p_update_existing = false);

View file

@ -59,7 +59,7 @@ enum MouseButton {
MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1)) MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1))
}; };
enum JoyButtonList { enum JoyButton {
JOY_BUTTON_INVALID = -1, JOY_BUTTON_INVALID = -1,
JOY_BUTTON_A = 0, JOY_BUTTON_A = 0,
JOY_BUTTON_B = 1, JOY_BUTTON_B = 1,
@ -86,7 +86,7 @@ enum JoyButtonList {
JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons. JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
}; };
enum JoyAxisList { enum JoyAxis {
JOY_AXIS_INVALID = -1, JOY_AXIS_INVALID = -1,
JOY_AXIS_LEFT_X = 0, JOY_AXIS_LEFT_X = 0,
JOY_AXIS_LEFT_Y = 1, JOY_AXIS_LEFT_Y = 1,
@ -98,7 +98,7 @@ enum JoyAxisList {
JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes. JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
}; };
enum MidiMessageList { enum MIDIMessage {
MIDI_MESSAGE_NOTE_OFF = 0x8, MIDI_MESSAGE_NOTE_OFF = 0x8,
MIDI_MESSAGE_NOTE_ON = 0x9, MIDI_MESSAGE_NOTE_ON = 0x9,
MIDI_MESSAGE_AFTERTOUCH = 0xA, MIDI_MESSAGE_AFTERTOUCH = 0xA,

View file

@ -45,7 +45,7 @@ enum {
SPKEY = (1 << 24) SPKEY = (1 << 24)
}; };
enum KeyList { enum Key {
/* CURSOR/FUNCTION/BROWSER/MULTIMEDIA/MISC KEYS */ /* CURSOR/FUNCTION/BROWSER/MULTIMEDIA/MISC KEYS */
KEY_ESCAPE = SPKEY | 0x01, KEY_ESCAPE = SPKEY | 0x01,
KEY_TAB = SPKEY | 0x02, KEY_TAB = SPKEY | 0x02,

File diff suppressed because it is too large Load diff

View file

@ -126,7 +126,7 @@
<argument index="1" name="axis" type="int"> <argument index="1" name="axis" type="int">
</argument> </argument>
<description> <description>
Returns the current value of the joypad axis at given index (see [enum JoyAxisList]). Returns the current value of the joypad axis at given index (see [enum JoyAxis]).
</description> </description>
</method> </method>
<method name="get_joy_guid" qualifiers="const"> <method name="get_joy_guid" qualifiers="const">
@ -255,7 +255,7 @@
<argument index="1" name="button" type="int"> <argument index="1" name="button" type="int">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if you are pressing the joypad button (see [enum JoyButtonList]). Returns [code]true[/code] if you are pressing the joypad button (see [enum JoyButton]).
</description> </description>
</method> </method>
<method name="is_joy_known"> <method name="is_joy_known">
@ -273,7 +273,7 @@
<argument index="0" name="keycode" type="int"> <argument index="0" name="keycode" type="int">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if you are pressing the key in the current keyboard layout. You can pass a [enum KeyList] constant. Returns [code]true[/code] if you are pressing the key in the current keyboard layout. You can pass a [enum Key] constant.
</description> </description>
</method> </method>
<method name="is_mouse_button_pressed" qualifiers="const"> <method name="is_mouse_button_pressed" qualifiers="const">
@ -282,7 +282,7 @@
<argument index="0" name="button" type="int"> <argument index="0" name="button" type="int">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if you are pressing the mouse button specified with [enum ButtonList]. Returns [code]true[/code] if you are pressing the mouse button specified with [enum MouseButton].
</description> </description>
</method> </method>
<method name="joy_connection_changed"> <method name="joy_connection_changed">

View file

@ -13,7 +13,7 @@
</methods> </methods>
<members> <members>
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0"> <member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
Button identifier. One of the [enum JoyButtonList] button constants. Button identifier. One of the [enum JoyButton] button constants.
</member> </member>
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false"> <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">
If [code]true[/code], the button's state is pressed. If [code]false[/code], the button's state is released. If [code]true[/code], the button's state is pressed. If [code]false[/code], the button's state is released.

View file

@ -13,7 +13,7 @@
</methods> </methods>
<members> <members>
<member name="axis" type="int" setter="set_axis" getter="get_axis" default="0"> <member name="axis" type="int" setter="set_axis" getter="get_axis" default="0">
Axis identifier. Use one of the [enum JoyAxisList] axis constants. Axis identifier. Use one of the [enum JoyAxis] axis constants.
</member> </member>
<member name="axis_value" type="float" setter="set_axis_value" getter="get_axis_value" default="0.0"> <member name="axis_value" type="float" setter="set_axis_value" getter="get_axis_value" default="0.0">
Current position of the joystick on the given axis. The value ranges from [code]-1.0[/code] to [code]1.0[/code]. A value of [code]0[/code] means the axis is in its resting position. Current position of the joystick on the given axis. The value ranges from [code]-1.0[/code] to [code]1.0[/code]. A value of [code]0[/code] means the axis is in its resting position.

View file

@ -32,11 +32,11 @@
If [code]true[/code], the key was already pressed before this event. It means the user is holding the key down. If [code]true[/code], the key was already pressed before this event. It means the user is holding the key down.
</member> </member>
<member name="keycode" type="int" setter="set_keycode" getter="get_keycode" default="0"> <member name="keycode" type="int" setter="set_keycode" getter="get_keycode" default="0">
The key keycode, which corresponds to one of the [enum KeyList] constants. Represent key in the current keyboard layout. The key keycode, which corresponds to one of the [enum Key] constants. Represent key in the current keyboard layout.
To get a human-readable representation of the [InputEventKey], use [code]OS.get_keycode_string(event.keycode)[/code] where [code]event[/code] is the [InputEventKey]. To get a human-readable representation of the [InputEventKey], use [code]OS.get_keycode_string(event.keycode)[/code] where [code]event[/code] is the [InputEventKey].
</member> </member>
<member name="physical_keycode" type="int" setter="set_physical_keycode" getter="get_physical_keycode" default="0"> <member name="physical_keycode" type="int" setter="set_physical_keycode" getter="get_physical_keycode" default="0">
Key physical keycode, which corresponds to one of the [enum KeyList] constants. Represent the physical location of a key on the 101/102-key US QWERTY keyboard. Key physical keycode, which corresponds to one of the [enum Key] constants. Represent the physical location of a key on the 101/102-key US QWERTY keyboard.
To get a human-readable representation of the [InputEventKey], use [code]OS.get_keycode_string(event.keycode)[/code] where [code]event[/code] is the [InputEventKey]. To get a human-readable representation of the [InputEventKey], use [code]OS.get_keycode_string(event.keycode)[/code] where [code]event[/code] is the [InputEventKey].
</member> </member>
<member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false"> <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false">

View file

@ -13,7 +13,7 @@
</methods> </methods>
<members> <members>
<member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" default="0"> <member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" default="0">
The mouse button mask identifier, one of or a bitwise combination of the [enum ButtonList] button masks. The mouse button mask identifier, one of or a bitwise combination of the [enum MouseButton] button masks.
</member> </member>
<member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2( 0, 0 )"> <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2( 0, 0 )">
The global mouse position relative to the current [Viewport] when used in [method Control._gui_input], otherwise is at 0,0. The global mouse position relative to the current [Viewport] when used in [method Control._gui_input], otherwise is at 0,0.

View file

@ -13,7 +13,7 @@
</methods> </methods>
<members> <members>
<member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0"> <member name="button_index" type="int" setter="set_button_index" getter="get_button_index" default="0">
The mouse button identifier, one of the [enum ButtonList] button or button wheel constants. The mouse button identifier, one of the [enum MouseButton] button or button wheel constants.
</member> </member>
<member name="doubleclick" type="bool" setter="set_doubleclick" getter="is_doubleclick" default="false"> <member name="doubleclick" type="bool" setter="set_doubleclick" getter="is_doubleclick" default="false">
If [code]true[/code], the mouse button's state is a double-click. If [code]true[/code], the mouse button's state is a double-click.

View file

@ -62,7 +62,7 @@
<argument index="0" name="button" type="int"> <argument index="0" name="button" type="int">
</argument> </argument>
<description> <description>
Returns [code]true[/code] if the button at index [code]button[/code] is pressed. See [enum JoyButtonList]. Returns [code]true[/code] if the button at index [code]button[/code] is pressed. See [enum JoyButton].
</description> </description>
</method> </method>
</methods> </methods>

View file

@ -25583,7 +25583,7 @@ msgstr ""
#: doc/classes/Input.xml:99 #: doc/classes/Input.xml:99
msgid "" msgid ""
"Returns the current value of the joypad axis at given index (see [enum " "Returns the current value of the joypad axis at given index (see [enum "
"JoyAxisList])." "JoyAxis])."
msgstr "" msgstr ""
#: doc/classes/Input.xml:108 #: doc/classes/Input.xml:108
@ -25592,7 +25592,7 @@ msgstr ""
#: doc/classes/Input.xml:117 #: doc/classes/Input.xml:117
msgid "" msgid ""
"Receives a [enum JoyAxisList] axis and returns its equivalent name as a " "Receives a [enum JoyAxis] axis and returns its equivalent name as a "
"string." "string."
msgstr "" msgstr ""
@ -25602,7 +25602,7 @@ msgstr ""
#: doc/classes/Input.xml:135 #: doc/classes/Input.xml:135
msgid "" msgid ""
"Receives a gamepad button from [enum JoyButtonList] and returns its " "Receives a gamepad button from [enum JoyButton] and returns its "
"equivalent name as a string." "equivalent name as a string."
msgstr "" msgstr ""
@ -25677,7 +25677,7 @@ msgstr ""
#: doc/classes/Input.xml:238 #: doc/classes/Input.xml:238
msgid "" msgid ""
"Returns [code]true[/code] if you are pressing the joypad button (see [enum " "Returns [code]true[/code] if you are pressing the joypad button (see [enum "
"JoyButtonList])." "JoyButton])."
msgstr "" msgstr ""
#: doc/classes/Input.xml:247 #: doc/classes/Input.xml:247
@ -26077,7 +26077,7 @@ msgid ""
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadButton.xml:16 #: doc/classes/InputEventJoypadButton.xml:16
msgid "Button identifier. One of the [enum JoyButtonList] button constants." msgid "Button identifier. One of the [enum JoyButton] button constants."
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadButton.xml:19 #: doc/classes/InputEventJoypadButton.xml:19
@ -26105,7 +26105,7 @@ msgid ""
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadMotion.xml:16 #: doc/classes/InputEventJoypadMotion.xml:16
msgid "Axis identifier. Use one of the [enum JoyAxisList] axis constants." msgid "Axis identifier. Use one of the [enum JoyAxis] axis constants."
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadMotion.xml:19 #: doc/classes/InputEventJoypadMotion.xml:19
@ -60259,7 +60259,7 @@ msgstr ""
#: doc/classes/XRController3D.xml:65 #: doc/classes/XRController3D.xml:65
msgid "" msgid ""
"Returns [code]true[/code] if the button at index [code]button[/code] is " "Returns [code]true[/code] if the button at index [code]button[/code] is "
"pressed. See [enum JoyButtonList]." "pressed. See [enum JoyButton]."
msgstr "" msgstr ""
#: doc/classes/XRController3D.xml:71 #: doc/classes/XRController3D.xml:71

View file

@ -25946,7 +25946,7 @@ msgstr ""
#: doc/classes/Input.xml:99 #: doc/classes/Input.xml:99
msgid "" msgid ""
"Returns the current value of the joypad axis at given index (see [enum " "Returns the current value of the joypad axis at given index (see [enum "
"JoyAxisList])." "JoyAxis])."
msgstr "" msgstr ""
#: doc/classes/Input.xml:108 #: doc/classes/Input.xml:108
@ -25955,7 +25955,7 @@ msgstr ""
#: doc/classes/Input.xml:117 #: doc/classes/Input.xml:117
msgid "" msgid ""
"Receives a [enum JoyAxisList] axis and returns its equivalent name as a " "Receives a [enum JoyAxis] axis and returns its equivalent name as a "
"string." "string."
msgstr "" msgstr ""
@ -25965,7 +25965,7 @@ msgstr ""
#: doc/classes/Input.xml:135 #: doc/classes/Input.xml:135
msgid "" msgid ""
"Receives a gamepad button from [enum JoyButtonList] and returns its " "Receives a gamepad button from [enum JoyButton] and returns its "
"equivalent name as a string." "equivalent name as a string."
msgstr "" msgstr ""
@ -26041,7 +26041,7 @@ msgstr ""
#, fuzzy #, fuzzy
msgid "" msgid ""
"Returns [code]true[/code] if you are pressing the joypad button (see [enum " "Returns [code]true[/code] if you are pressing the joypad button (see [enum "
"JoyButtonList])." "JoyButton])."
msgstr "" msgstr ""
"Retourne [code]true[/code] (vrai) si la chaîne de caractères finit par la " "Retourne [code]true[/code] (vrai) si la chaîne de caractères finit par la "
"chaîne de caractères donnée." "chaîne de caractères donnée."
@ -26443,7 +26443,7 @@ msgid ""
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadButton.xml:16 #: doc/classes/InputEventJoypadButton.xml:16
msgid "Button identifier. One of the [enum JoyButtonList] button constants." msgid "Button identifier. One of the [enum JoyButton] button constants."
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadButton.xml:19 #: doc/classes/InputEventJoypadButton.xml:19
@ -26471,7 +26471,7 @@ msgid ""
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadMotion.xml:16 #: doc/classes/InputEventJoypadMotion.xml:16
msgid "Axis identifier. Use one of the [enum JoyAxisList] axis constants." msgid "Axis identifier. Use one of the [enum JoyAxis] axis constants."
msgstr "" msgstr ""
#: doc/classes/InputEventJoypadMotion.xml:19 #: doc/classes/InputEventJoypadMotion.xml:19
@ -60738,7 +60738,7 @@ msgstr ""
#, fuzzy #, fuzzy
msgid "" msgid ""
"Returns [code]true[/code] if the button at index [code]button[/code] is " "Returns [code]true[/code] if the button at index [code]button[/code] is "
"pressed. See [enum JoyButtonList]." "pressed. See [enum JoyButton]."
msgstr "" msgstr ""
"Renvoie [code]true[/code] (vrai) si [code]s[/code] vaut zéro ou quasiment " "Renvoie [code]true[/code] (vrai) si [code]s[/code] vaut zéro ou quasiment "
"zéro." "zéro."

View file

@ -398,7 +398,7 @@ void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_a
if (tracker != nullptr) { if (tracker != nullptr) {
int joyid = tracker->get_joy_id(); int joyid = tracker->get_joy_id();
if (joyid != -1) { if (joyid != -1) {
Input::JoyAxis jx; Input::JoyAxisValue jx;
jx.min = p_can_be_negative ? -1 : 0; jx.min = p_can_be_negative ? -1 : 0;
jx.value = p_value; jx.value = p_value;
input->joy_axis(joyid, p_axis, jx); input->joy_axis(joyid, p_axis, jx);

View file

@ -416,7 +416,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
int *axes = godot_webxr_get_controller_axes(p_controller_id); int *axes = godot_webxr_get_controller_axes(p_controller_id);
if (axes) { if (axes) {
for (int i = 0; i < axes[0]; i++) { for (int i = 0; i < axes[0]; i++) {
Input::JoyAxis joy_axis; Input::JoyAxisValue joy_axis;
joy_axis.min = -1; joy_axis.min = -1;
joy_axis.value = *((float *)axes + (i + 1)); joy_axis.value = *((float *)axes + (i + 1));
input->joy_axis(p_controller_id + 100, i, joy_axis); input->joy_axis(p_controller_id + 100, i, joy_axis);

View file

@ -477,7 +477,7 @@ void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p
Input::get_singleton()->joy_button(p_event.device, p_event.index, p_event.pressed); Input::get_singleton()->joy_button(p_event.device, p_event.index, p_event.pressed);
break; break;
case JOY_EVENT_AXIS: case JOY_EVENT_AXIS:
Input::JoyAxis value; Input::JoyAxisValue value;
value.min = -1; value.min = -1;
value.value = p_event.value; value.value = p_event.value;
Input::get_singleton()->joy_axis(p_event.device, p_event.index, value); Input::get_singleton()->joy_axis(p_event.device, p_event.index, value);

View file

@ -287,7 +287,7 @@ void JoypadIPhone::start_processing() {
gamepad.dpad.right.isPressed); gamepad.dpad.right.isPressed);
}; };
Input::JoyAxis jx; Input::JoyAxisValue jx;
jx.min = -1; jx.min = -1;
if (element == gamepad.leftThumbstick) { if (element == gamepad.leftThumbstick) {
jx.value = gamepad.leftThumbstick.xAxis.value; jx.value = gamepad.leftThumbstick.xAxis.value;

View file

@ -601,7 +601,7 @@ void DisplayServerJavaScript::process_joypads() {
// Buttons 6 and 7 in the standard mapping need to be // Buttons 6 and 7 in the standard mapping need to be
// axis to be handled as JOY_AXIS_TRIGGER by Godot. // axis to be handled as JOY_AXIS_TRIGGER by Godot.
if (s_standard && (b == 6 || b == 7)) { if (s_standard && (b == 6 || b == 7)) {
Input::JoyAxis joy_axis; Input::JoyAxisValue joy_axis;
joy_axis.min = 0; joy_axis.min = 0;
joy_axis.value = value; joy_axis.value = value;
int a = b == 6 ? JOY_AXIS_TRIGGER_LEFT : JOY_AXIS_TRIGGER_RIGHT; int a = b == 6 ? JOY_AXIS_TRIGGER_LEFT : JOY_AXIS_TRIGGER_RIGHT;
@ -611,7 +611,7 @@ void DisplayServerJavaScript::process_joypads() {
} }
} }
for (int a = 0; a < s_axes_num; a++) { for (int a = 0; a < s_axes_num; a++) {
Input::JoyAxis joy_axis; Input::JoyAxisValue joy_axis;
joy_axis.min = -1; joy_axis.min = -1;
joy_axis.value = s_axes[a]; joy_axis.value = s_axes[a];
input->joy_axis(idx, a, joy_axis); input->joy_axis(idx, a, joy_axis);

View file

@ -62,7 +62,7 @@ void JoypadLinux::Joypad::reset() {
dpad = 0; dpad = 0;
fd = -1; fd = -1;
Input::JoyAxis jx; Input::JoyAxisValue jx;
jx.min = -1; jx.min = -1;
jx.value = 0.0f; jx.value = 0.0f;
for (int i = 0; i < MAX_ABS; i++) { for (int i = 0; i < MAX_ABS; i++) {
@ -428,10 +428,10 @@ void JoypadLinux::joypad_vibration_stop(int p_id, uint64_t p_timestamp) {
joy.ff_effect_timestamp = p_timestamp; joy.ff_effect_timestamp = p_timestamp;
} }
Input::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const { Input::JoyAxisValue JoypadLinux::axis_correct(const input_absinfo *p_abs, int p_value) const {
int min = p_abs->minimum; int min = p_abs->minimum;
int max = p_abs->maximum; int max = p_abs->maximum;
Input::JoyAxis jx; Input::JoyAxisValue jx;
if (min < 0) { if (min < 0) {
jx.min = -1; jx.min = -1;
@ -513,7 +513,7 @@ void JoypadLinux::process_joypads() {
return; return;
} }
if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) { if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) {
Input::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value); Input::JoyAxisValue value = axis_correct(joy->abs_info[ev.code], ev.value);
joy->curr_axis[joy->abs_map[ev.code]] = value; joy->curr_axis[joy->abs_map[ev.code]] = value;
} }
break; break;

View file

@ -53,7 +53,7 @@ private:
}; };
struct Joypad { struct Joypad {
Input::JoyAxis curr_axis[MAX_ABS]; Input::JoyAxisValue curr_axis[MAX_ABS];
int key_map[MAX_KEY]; int key_map[MAX_KEY];
int abs_map[MAX_ABS]; int abs_map[MAX_ABS];
int dpad = 0; int dpad = 0;
@ -97,7 +97,7 @@ private:
void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); void joypad_vibration_start(int p_id, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop(int p_id, uint64_t p_timestamp); void joypad_vibration_stop(int p_id, uint64_t p_timestamp);
Input::JoyAxis axis_correct(const input_absinfo *p_abs, int p_value) const; Input::JoyAxisValue axis_correct(const input_absinfo *p_abs, int p_value) const;
}; };
#endif #endif

View file

@ -433,8 +433,8 @@ void JoypadOSX::poll_joypads() const {
} }
} }
static const Input::JoyAxis axis_correct(int p_value, int p_min, int p_max) { static const Input::JoyAxisValue axis_correct(int p_value, int p_min, int p_max) {
Input::JoyAxis jx; Input::JoyAxisValue jx;
if (p_min < 0) { if (p_min < 0) {
jx.min = -1; jx.min = -1;
if (p_value < 0) { if (p_value < 0) {

View file

@ -134,8 +134,8 @@ void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Inp
input->joy_connection_changed(idx, false, "Xbox Controller"); input->joy_connection_changed(idx, false, "Xbox Controller");
} }
InputDefault::JoyAxis JoypadUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const { InputDefault::JoyAxisValue JoypadUWP::axis_correct(double p_val, bool p_negate, bool p_trigger) const {
InputDefault::JoyAxis jx; InputDefault::JoyAxisValue jx;
jx.min = p_trigger ? 0 : -1; jx.min = p_trigger ? 0 : -1;
jx.value = (float)(p_negate ? -p_val : p_val); jx.value = (float)(p_negate ? -p_val : p_val);

View file

@ -73,7 +73,7 @@ private:
void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value); void OnGamepadAdded(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value); void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value);
InputDefault::JoyAxis axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const; InputDefault::JoyAxisValue axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const;
void joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); void joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop(int p_device, uint64_t p_timestamp); void joypad_vibration_stop(int p_device, uint64_t p_timestamp);
}; };

View file

@ -446,8 +446,8 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
input->joy_hat(p_device, dpad_val); input->joy_hat(p_device, dpad_val);
}; };
Input::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const { Input::JoyAxisValue JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
Input::JoyAxis jx; Input::JoyAxisValue jx;
if (Math::abs(p_val) < MIN_JOY_AXIS) { if (Math::abs(p_val) < MIN_JOY_AXIS) {
jx.min = p_trigger ? 0 : -1; jx.min = p_trigger ? 0 : -1;
jx.value = 0.0f; jx.value = 0.0f;

View file

@ -132,7 +132,7 @@ private:
void joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); void joypad_vibration_start_xinput(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp);
void joypad_vibration_stop_xinput(int p_device, uint64_t p_timestamp); void joypad_vibration_stop_xinput(int p_device, uint64_t p_timestamp);
Input::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const; Input::JoyAxisValue axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const;
XInputGetState_t xinput_get_state; XInputGetState_t xinput_get_state;
XInputSetState_t xinput_set_state; XInputSetState_t xinput_set_state;
}; };