| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="InputEvent" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Abstract base class for input events. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Abstract base class of all types of input events. See [method Node._input]. |
| 8 | </description> |
| 9 | <tutorials> |
| 10 | <link title="Using InputEvent">$DOCS_URL/tutorials/inputs/inputevent.html</link> |
| 11 | <link title="Viewport and canvas transforms">$DOCS_URL/tutorials/2d/2d_transforms.html</link> |
| 12 | <link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/2712</link> |
| 13 | <link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/2755</link> |
| 14 | </tutorials> |
| 15 | <methods> |
| 16 | <method name="accumulate"> |
| 17 | <return type="bool" /> |
| 18 | <param index="0" name="with_event" type="InputEvent" /> |
| 19 | <description> |
| 20 | Returns [code]true[/code] if the given input event and this input event can be added together (only for events of type [InputEventMouseMotion]). |
| 21 | The given input event's position, global position and speed will be copied. The resulting [code]relative[/code] is a sum of both events. Both events' modifiers have to be identical. |
| 22 | </description> |
| 23 | </method> |
| 24 | <method name="as_text" qualifiers="const"> |
| 25 | <return type="String" /> |
| 26 | <description> |
| 27 | Returns a [String] representation of the event. |
| 28 | </description> |
| 29 | </method> |
| 30 | <method name="get_action_strength" qualifiers="const"> |
| 31 | <return type="float" /> |
| 32 | <param index="0" name="action" type="StringName" /> |
| 33 | <param index="1" name="exact_match" type="bool" default="false" /> |
| 34 | <description> |
| 35 | Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type [InputEventJoypadMotion]. |
| 36 | If [param exact_match] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. |
| 37 | </description> |
| 38 | </method> |
| 39 | <method name="is_action" qualifiers="const"> |
| 40 | <return type="bool" /> |
| 41 | <param index="0" name="action" type="StringName" /> |
| 42 | <param index="1" name="exact_match" type="bool" default="false" /> |
| 43 | <description> |
| 44 | Returns [code]true[/code] if this input event matches a pre-defined action of any type. |
| 45 | If [param exact_match] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. |
| 46 | </description> |
| 47 | </method> |
| 48 | <method name="is_action_pressed" qualifiers="const"> |
| 49 | <return type="bool" /> |
| 50 | <param index="0" name="action" type="StringName" /> |
| 51 | <param index="1" name="allow_echo" type="bool" default="false" /> |
| 52 | <param index="2" name="exact_match" type="bool" default="false" /> |
| 53 | <description> |
| 54 | Returns [code]true[/code] if the given action matches this event and is being pressed (and is not an echo event for [InputEventKey] events, unless [param allow_echo] is [code]true[/code]). Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. |
| 55 | If [param exact_match] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. |
| 56 | [b]Note:[/b] Due to keyboard ghosting, [method is_action_pressed] may return [code]false[/code] even if one of the action's keys is pressed. See [url=$DOCS_URL/tutorials/inputs/input_examples.html#keyboard-events]Input examples[/url] in the documentation for more information. |
| 57 | </description> |
| 58 | </method> |
| 59 | <method name="is_action_released" qualifiers="const"> |
| 60 | <return type="bool" /> |
| 61 | <param index="0" name="action" type="StringName" /> |
| 62 | <param index="1" name="exact_match" type="bool" default="false" /> |
| 63 | <description> |
| 64 | Returns [code]true[/code] if the given action matches this event and is released (i.e. not pressed). Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. |
| 65 | If [param exact_match] is [code]false[/code], it ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. |
| 66 | </description> |
| 67 | </method> |
| 68 | <method name="is_action_type" qualifiers="const"> |
| 69 | <return type="bool" /> |
| 70 | <description> |
| 71 | Returns [code]true[/code] if this input event's type is one that can be assigned to an input action: [InputEventKey], [InputEventMouseButton], [InputEventJoypadButton], [InputEventJoypadMotion], [InputEventAction]. Returns [code]false[/code] for all other input event types. |
| 72 | </description> |
| 73 | </method> |
| 74 | <method name="is_canceled" qualifiers="const"> |
| 75 | <return type="bool" /> |
| 76 | <description> |
| 77 | Returns [code]true[/code] if this input event has been canceled. |
| 78 | </description> |
| 79 | </method> |
| 80 | <method name="is_echo" qualifiers="const" keywords="is_repeat"> |
| 81 | <return type="bool" /> |
| 82 | <description> |
| 83 | Returns [code]true[/code] if this input event is an echo event (only for events of type [InputEventKey]). An echo event is a repeated key event sent when the user is holding down the key. Any other event type returns [code]false[/code]. |
| 84 | [b]Note:[/b] The rate at which echo events are sent is typically around 20 events per second (after holding down the key for roughly half a second). However, the key repeat delay/speed can be changed by the user or disabled entirely in the operating system settings. To ensure your project works correctly on all configurations, do not assume the user has a specific key repeat configuration in your project's behavior. |
| 85 | </description> |
| 86 | </method> |
| 87 | <method name="is_match" qualifiers="const"> |
| 88 | <return type="bool" /> |
| 89 | <param index="0" name="event" type="InputEvent" /> |
| 90 | <param index="1" name="exact_match" type="bool" default="true" /> |
| 91 | <description> |
| 92 | Returns [code]true[/code] if the specified [param event] matches this event. Only valid for action events, which include key ([InputEventKey]), button ([InputEventMouseButton] or [InputEventJoypadButton]), axis [InputEventJoypadMotion], and action ([InputEventAction]) events. |
| 93 | If [param exact_match] is [code]false[/code], the check ignores additional input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. |
| 94 | [b]Note:[/b] This method only considers the event configuration (such as the keyboard key or the joypad axis), not state information like [method is_pressed], [method is_released], [method is_echo], or [method is_canceled]. |
| 95 | </description> |
| 96 | </method> |
| 97 | <method name="is_pressed" qualifiers="const"> |
| 98 | <return type="bool" /> |
| 99 | <description> |
| 100 | Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. |
| 101 | [b]Note:[/b] Due to keyboard ghosting, [method is_pressed] may return [code]false[/code] even if one of the action's keys is pressed. See [url=$DOCS_URL/tutorials/inputs/input_examples.html#keyboard-events]Input examples[/url] in the documentation for more information. |
| 102 | </description> |
| 103 | </method> |
| 104 | <method name="is_released" qualifiers="const"> |
| 105 | <return type="bool" /> |
| 106 | <description> |
| 107 | Returns [code]true[/code] if this input event is released. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. |
| 108 | </description> |
| 109 | </method> |
| 110 | <method name="xformed_by" qualifiers="const"> |
| 111 | <return type="InputEvent" /> |
| 112 | <param index="0" name="xform" type="Transform2D" /> |
| 113 | <param index="1" name="local_ofs" type="Vector2" default="Vector2(0, 0)" /> |
| 114 | <description> |
| 115 | Returns a copy of the given input event which has been offset by [param local_ofs] and transformed by [param xform]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture] and [InputEventPanGesture]. |
| 116 | </description> |
| 117 | </method> |
| 118 | </methods> |
| 119 | <members> |
| 120 | <member name="device" type="int" setter="set_device" getter="get_device" default="0"> |
| 121 | The event's device ID. |
| 122 | [b]Note:[/b] [member device] can be negative for special use cases that don't refer to devices physically present on the system. See [constant DEVICE_ID_EMULATION]. |
| 123 | </member> |
| 124 | </members> |
| 125 | <constants> |
| 126 | <constant name="DEVICE_ID_EMULATION" value="-1"> |
| 127 | Device ID used for emulated mouse input from a touchscreen, or for emulated touch input from a mouse. This can be used to distinguish emulated mouse input from physical mouse input, or emulated touch input from physical touch input. |
| 128 | </constant> |
| 129 | </constants> |
| 130 | </class> |