class_input.rst 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Input.xml.
  6. .. _class_Input:
  7. Input
  8. =====
  9. **Inherits:** :ref:`Object<class_Object>`
  10. A singleton for handling inputs.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. The **Input** singleton handles key presses, mouse buttons and movement, gamepads, and input actions. Actions and their events can be set in the **Input Map** tab in **Project > Project Settings**, or with the :ref:`InputMap<class_InputMap>` class.
  15. \ **Note:** **Input**'s methods reflect the global input state and are not affected by :ref:`Control.accept_event<class_Control_method_accept_event>` or :ref:`Viewport.set_input_as_handled<class_Viewport_method_set_input_as_handled>`, as those methods only deal with the way input is propagated in the :ref:`SceneTree<class_SceneTree>`.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Inputs documentation index <../tutorials/inputs/index>`
  20. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  21. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +----------------------------------------+--------------------------------------------------------------------------+
  28. | :ref:`MouseMode<enum_Input_MouseMode>` | :ref:`mouse_mode<class_Input_property_mouse_mode>` |
  29. +----------------------------------------+--------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`use_accumulated_input<class_Input_property_use_accumulated_input>` |
  31. +----------------------------------------+--------------------------------------------------------------------------+
  32. .. rst-class:: classref-reftable-group
  33. Methods
  34. -------
  35. .. table::
  36. :widths: auto
  37. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`action_press<class_Input_method_action_press>` **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` strength=1.0 **)** |
  39. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`action_release<class_Input_method_action_release>` **(** :ref:`StringName<class_StringName>` action **)** |
  41. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`add_joy_mapping<class_Input_method_add_joy_mapping>` **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)** |
  43. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`flush_buffered_events<class_Input_method_flush_buffered_events>` **(** **)** |
  45. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector3<class_Vector3>` | :ref:`get_accelerometer<class_Input_method_get_accelerometer>` **(** **)** |const| |
  47. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`get_action_raw_strength<class_Input_method_get_action_raw_strength>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  49. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`get_action_strength<class_Input_method_get_action_strength>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  51. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`get_axis<class_Input_method_get_axis>` **(** :ref:`StringName<class_StringName>` negative_action, :ref:`StringName<class_StringName>` positive_action **)** |const| |
  53. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int[]<class_int>` | :ref:`get_connected_joypads<class_Input_method_get_connected_joypads>` **(** **)** |
  55. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`CursorShape<enum_Input_CursorShape>` | :ref:`get_current_cursor_shape<class_Input_method_get_current_cursor_shape>` **(** **)** |const| |
  57. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Vector3<class_Vector3>` | :ref:`get_gravity<class_Input_method_get_gravity>` **(** **)** |const| |
  59. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector3<class_Vector3>` | :ref:`get_gyroscope<class_Input_method_get_gyroscope>` **(** **)** |const| |
  61. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`float<class_float>` | :ref:`get_joy_axis<class_Input_method_get_joy_axis>` **(** :ref:`int<class_int>` device, :ref:`JoyAxis<enum_@GlobalScope_JoyAxis>` axis **)** |const| |
  63. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`String<class_String>` | :ref:`get_joy_guid<class_Input_method_get_joy_guid>` **(** :ref:`int<class_int>` device **)** |const| |
  65. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_joy_info<class_Input_method_get_joy_info>` **(** :ref:`int<class_int>` device **)** |const| |
  67. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`String<class_String>` | :ref:`get_joy_name<class_Input_method_get_joy_name>` **(** :ref:`int<class_int>` device **)** |
  69. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`float<class_float>` | :ref:`get_joy_vibration_duration<class_Input_method_get_joy_vibration_duration>` **(** :ref:`int<class_int>` device **)** |
  71. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Vector2<class_Vector2>` | :ref:`get_joy_vibration_strength<class_Input_method_get_joy_vibration_strength>` **(** :ref:`int<class_int>` device **)** |
  73. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Vector2<class_Vector2>` | :ref:`get_last_mouse_velocity<class_Input_method_get_last_mouse_velocity>` **(** **)** |
  75. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector3<class_Vector3>` | :ref:`get_magnetometer<class_Input_method_get_magnetometer>` **(** **)** |const| |
  77. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | |bitfield|\<:ref:`MouseButtonMask<enum_@GlobalScope_MouseButtonMask>`\> | :ref:`get_mouse_button_mask<class_Input_method_get_mouse_button_mask>` **(** **)** |const| |
  79. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Vector2<class_Vector2>` | :ref:`get_vector<class_Input_method_get_vector>` **(** :ref:`StringName<class_StringName>` negative_x, :ref:`StringName<class_StringName>` positive_x, :ref:`StringName<class_StringName>` negative_y, :ref:`StringName<class_StringName>` positive_y, :ref:`float<class_float>` deadzone=-1.0 **)** |const| |
  81. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`bool<class_bool>` | :ref:`is_action_just_pressed<class_Input_method_is_action_just_pressed>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  83. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`bool<class_bool>` | :ref:`is_action_just_released<class_Input_method_is_action_just_released>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  85. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`bool<class_bool>` | :ref:`is_action_pressed<class_Input_method_is_action_pressed>` **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  87. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`bool<class_bool>` | :ref:`is_anything_pressed<class_Input_method_is_anything_pressed>` **(** **)** |const| |
  89. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`bool<class_bool>` | :ref:`is_joy_button_pressed<class_Input_method_is_joy_button_pressed>` **(** :ref:`int<class_int>` device, :ref:`JoyButton<enum_@GlobalScope_JoyButton>` button **)** |const| |
  91. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`bool<class_bool>` | :ref:`is_joy_known<class_Input_method_is_joy_known>` **(** :ref:`int<class_int>` device **)** |
  93. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`bool<class_bool>` | :ref:`is_key_label_pressed<class_Input_method_is_key_label_pressed>` **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const| |
  95. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`is_key_pressed<class_Input_method_is_key_pressed>` **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const| |
  97. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`is_mouse_button_pressed<class_Input_method_is_mouse_button_pressed>` **(** :ref:`MouseButton<enum_@GlobalScope_MouseButton>` button **)** |const| |
  99. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`bool<class_bool>` | :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const| |
  101. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | void | :ref:`parse_input_event<class_Input_method_parse_input_event>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |
  103. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | void | :ref:`remove_joy_mapping<class_Input_method_remove_joy_mapping>` **(** :ref:`String<class_String>` guid **)** |
  105. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`set_accelerometer<class_Input_method_set_accelerometer>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  107. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | void | :ref:`set_custom_mouse_cursor<class_Input_method_set_custom_mouse_cursor>` **(** :ref:`Resource<class_Resource>` image, :ref:`CursorShape<enum_Input_CursorShape>` shape=0, :ref:`Vector2<class_Vector2>` hotspot=Vector2(0, 0) **)** |
  109. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`set_default_cursor_shape<class_Input_method_set_default_cursor_shape>` **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)** |
  111. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`set_gravity<class_Input_method_set_gravity>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  113. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`set_gyroscope<class_Input_method_set_gyroscope>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  115. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`set_magnetometer<class_Input_method_set_magnetometer>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  117. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`bool<class_bool>` | :ref:`should_ignore_device<class_Input_method_should_ignore_device>` **(** :ref:`int<class_int>` vendor_id, :ref:`int<class_int>` product_id **)** |const| |
  119. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | void | :ref:`start_joy_vibration<class_Input_method_start_joy_vibration>` **(** :ref:`int<class_int>` device, :ref:`float<class_float>` weak_magnitude, :ref:`float<class_float>` strong_magnitude, :ref:`float<class_float>` duration=0 **)** |
  121. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | void | :ref:`stop_joy_vibration<class_Input_method_stop_joy_vibration>` **(** :ref:`int<class_int>` device **)** |
  123. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | void | :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>` **(** :ref:`int<class_int>` duration_ms=500 **)** |
  125. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`warp_mouse<class_Input_method_warp_mouse>` **(** :ref:`Vector2<class_Vector2>` position **)** |
  127. +-------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. .. rst-class:: classref-section-separator
  129. ----
  130. .. rst-class:: classref-descriptions-group
  131. Signals
  132. -------
  133. .. _class_Input_signal_joy_connection_changed:
  134. .. rst-class:: classref-signal
  135. **joy_connection_changed** **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected **)**
  136. Emitted when a joypad device has been connected or disconnected.
  137. .. rst-class:: classref-section-separator
  138. ----
  139. .. rst-class:: classref-descriptions-group
  140. Enumerations
  141. ------------
  142. .. _enum_Input_MouseMode:
  143. .. rst-class:: classref-enumeration
  144. enum **MouseMode**:
  145. .. _class_Input_constant_MOUSE_MODE_VISIBLE:
  146. .. rst-class:: classref-enumeration-constant
  147. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_VISIBLE** = ``0``
  148. Makes the mouse cursor visible if it is hidden.
  149. .. _class_Input_constant_MOUSE_MODE_HIDDEN:
  150. .. rst-class:: classref-enumeration-constant
  151. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_HIDDEN** = ``1``
  152. Makes the mouse cursor hidden if it is visible.
  153. .. _class_Input_constant_MOUSE_MODE_CAPTURED:
  154. .. rst-class:: classref-enumeration-constant
  155. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CAPTURED** = ``2``
  156. Captures the mouse. The mouse will be hidden and its position locked at the center of the window manager's window.
  157. \ **Note:** If you want to process the mouse's movement in this mode, you need to use :ref:`InputEventMouseMotion.relative<class_InputEventMouseMotion_property_relative>`.
  158. .. _class_Input_constant_MOUSE_MODE_CONFINED:
  159. .. rst-class:: classref-enumeration-constant
  160. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CONFINED** = ``3``
  161. Confines the mouse cursor to the game window, and make it visible.
  162. .. _class_Input_constant_MOUSE_MODE_CONFINED_HIDDEN:
  163. .. rst-class:: classref-enumeration-constant
  164. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CONFINED_HIDDEN** = ``4``
  165. Confines the mouse cursor to the game window, and make it hidden.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _enum_Input_CursorShape:
  169. .. rst-class:: classref-enumeration
  170. enum **CursorShape**:
  171. .. _class_Input_constant_CURSOR_ARROW:
  172. .. rst-class:: classref-enumeration-constant
  173. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_ARROW** = ``0``
  174. Arrow cursor. Standard, default pointing cursor.
  175. .. _class_Input_constant_CURSOR_IBEAM:
  176. .. rst-class:: classref-enumeration-constant
  177. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_IBEAM** = ``1``
  178. I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked.
  179. .. _class_Input_constant_CURSOR_POINTING_HAND:
  180. .. rst-class:: classref-enumeration-constant
  181. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_POINTING_HAND** = ``2``
  182. Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item.
  183. .. _class_Input_constant_CURSOR_CROSS:
  184. .. rst-class:: classref-enumeration-constant
  185. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_CROSS** = ``3``
  186. Cross cursor. Typically appears over regions in which a drawing operation can be performed or for selections.
  187. .. _class_Input_constant_CURSOR_WAIT:
  188. .. rst-class:: classref-enumeration-constant
  189. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_WAIT** = ``4``
  190. Wait cursor. Indicates that the application is busy performing an operation. This cursor shape denotes that the application isn't usable during the operation (e.g. something is blocking its main thread).
  191. .. _class_Input_constant_CURSOR_BUSY:
  192. .. rst-class:: classref-enumeration-constant
  193. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_BUSY** = ``5``
  194. Busy cursor. Indicates that the application is busy performing an operation. This cursor shape denotes that the application is still usable during the operation.
  195. .. _class_Input_constant_CURSOR_DRAG:
  196. .. rst-class:: classref-enumeration-constant
  197. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_DRAG** = ``6``
  198. Drag cursor. Usually displayed when dragging something.
  199. \ **Note:** Windows lacks a dragging cursor, so :ref:`CURSOR_DRAG<class_Input_constant_CURSOR_DRAG>` is the same as :ref:`CURSOR_MOVE<class_Input_constant_CURSOR_MOVE>` for this platform.
  200. .. _class_Input_constant_CURSOR_CAN_DROP:
  201. .. rst-class:: classref-enumeration-constant
  202. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_CAN_DROP** = ``7``
  203. Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position.
  204. .. _class_Input_constant_CURSOR_FORBIDDEN:
  205. .. rst-class:: classref-enumeration-constant
  206. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_FORBIDDEN** = ``8``
  207. Forbidden cursor. Indicates that the current action is forbidden (for example, when dragging something) or that the control at a position is disabled.
  208. .. _class_Input_constant_CURSOR_VSIZE:
  209. .. rst-class:: classref-enumeration-constant
  210. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_VSIZE** = ``9``
  211. Vertical resize mouse cursor. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
  212. .. _class_Input_constant_CURSOR_HSIZE:
  213. .. rst-class:: classref-enumeration-constant
  214. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HSIZE** = ``10``
  215. Horizontal resize mouse cursor. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
  216. .. _class_Input_constant_CURSOR_BDIAGSIZE:
  217. .. rst-class:: classref-enumeration-constant
  218. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_BDIAGSIZE** = ``11``
  219. Window resize mouse cursor. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically.
  220. .. _class_Input_constant_CURSOR_FDIAGSIZE:
  221. .. rst-class:: classref-enumeration-constant
  222. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_FDIAGSIZE** = ``12``
  223. Window resize mouse cursor. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of :ref:`CURSOR_BDIAGSIZE<class_Input_constant_CURSOR_BDIAGSIZE>`. It tells the user they can resize the window or the panel both horizontally and vertically.
  224. .. _class_Input_constant_CURSOR_MOVE:
  225. .. rst-class:: classref-enumeration-constant
  226. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_MOVE** = ``13``
  227. Move cursor. Indicates that something can be moved.
  228. .. _class_Input_constant_CURSOR_VSPLIT:
  229. .. rst-class:: classref-enumeration-constant
  230. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_VSPLIT** = ``14``
  231. Vertical split mouse cursor. On Windows, it's the same as :ref:`CURSOR_VSIZE<class_Input_constant_CURSOR_VSIZE>`.
  232. .. _class_Input_constant_CURSOR_HSPLIT:
  233. .. rst-class:: classref-enumeration-constant
  234. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HSPLIT** = ``15``
  235. Horizontal split mouse cursor. On Windows, it's the same as :ref:`CURSOR_HSIZE<class_Input_constant_CURSOR_HSIZE>`.
  236. .. _class_Input_constant_CURSOR_HELP:
  237. .. rst-class:: classref-enumeration-constant
  238. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HELP** = ``16``
  239. Help cursor. Usually a question mark.
  240. .. rst-class:: classref-section-separator
  241. ----
  242. .. rst-class:: classref-descriptions-group
  243. Property Descriptions
  244. ---------------------
  245. .. _class_Input_property_mouse_mode:
  246. .. rst-class:: classref-property
  247. :ref:`MouseMode<enum_Input_MouseMode>` **mouse_mode**
  248. .. rst-class:: classref-property-setget
  249. - void **set_mouse_mode** **(** :ref:`MouseMode<enum_Input_MouseMode>` value **)**
  250. - :ref:`MouseMode<enum_Input_MouseMode>` **get_mouse_mode** **(** **)**
  251. Controls the mouse mode. See :ref:`MouseMode<enum_Input_MouseMode>` for more information.
  252. .. rst-class:: classref-item-separator
  253. ----
  254. .. _class_Input_property_use_accumulated_input:
  255. .. rst-class:: classref-property
  256. :ref:`bool<class_bool>` **use_accumulated_input**
  257. .. rst-class:: classref-property-setget
  258. - void **set_use_accumulated_input** **(** :ref:`bool<class_bool>` value **)**
  259. - :ref:`bool<class_bool>` **is_using_accumulated_input** **(** **)**
  260. If ``true``, similar input events sent by the operating system are accumulated. When input accumulation is enabled, all input events generated during a frame will be merged and emitted when the frame is done rendering. Therefore, this limits the number of input method calls per second to the rendering FPS.
  261. Input accumulation can be disabled to get slightly more precise/reactive input at the cost of increased CPU usage. In applications where drawing freehand lines is required, input accumulation should generally be disabled while the user is drawing the line to get results that closely follow the actual input.
  262. \ **Note:** Input accumulation is *enabled* by default.
  263. .. rst-class:: classref-section-separator
  264. ----
  265. .. rst-class:: classref-descriptions-group
  266. Method Descriptions
  267. -------------------
  268. .. _class_Input_method_action_press:
  269. .. rst-class:: classref-method
  270. void **action_press** **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` strength=1.0 **)**
  271. This will simulate pressing the specified action.
  272. The strength can be used for non-boolean actions, it's ranged between 0 and 1 representing the intensity of the given action.
  273. \ **Note:** This method will not cause any :ref:`Node._input<class_Node_private_method__input>` calls. It is intended to be used with :ref:`is_action_pressed<class_Input_method_is_action_pressed>` and :ref:`is_action_just_pressed<class_Input_method_is_action_just_pressed>`. If you want to simulate ``_input``, use :ref:`parse_input_event<class_Input_method_parse_input_event>` instead.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_Input_method_action_release:
  277. .. rst-class:: classref-method
  278. void **action_release** **(** :ref:`StringName<class_StringName>` action **)**
  279. If the specified action is already pressed, this will release it.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_Input_method_add_joy_mapping:
  283. .. rst-class:: classref-method
  284. void **add_joy_mapping** **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)**
  285. Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_Input_method_flush_buffered_events:
  289. .. rst-class:: classref-method
  290. void **flush_buffered_events** **(** **)**
  291. Sends all input events which are in the current buffer to the game loop. These events may have been buffered as a result of accumulated input (:ref:`use_accumulated_input<class_Input_property_use_accumulated_input>`) or agile input flushing (:ref:`ProjectSettings.input_devices/buffering/agile_event_flushing<class_ProjectSettings_property_input_devices/buffering/agile_event_flushing>`).
  292. The engine will already do this itself at key execution points (at least once per frame). However, this can be useful in advanced cases where you want precise control over the timing of event handling.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_Input_method_get_accelerometer:
  296. .. rst-class:: classref-method
  297. :ref:`Vector3<class_Vector3>` **get_accelerometer** **(** **)** |const|
  298. Returns the acceleration in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  299. Note this method returns an empty :ref:`Vector3<class_Vector3>` when running from the editor even when your device has an accelerometer. You must export your project to a supported device to read values from the accelerometer.
  300. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_Input_method_get_action_raw_strength:
  304. .. rst-class:: classref-method
  305. :ref:`float<class_float>` **get_action_raw_strength** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  306. Returns a value between 0 and 1 representing the raw intensity of the given action, ignoring the action's deadzone. In most cases, you should use :ref:`get_action_strength<class_Input_method_get_action_strength>` instead.
  307. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_Input_method_get_action_strength:
  311. .. rst-class:: classref-method
  312. :ref:`float<class_float>` **get_action_strength** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  313. Returns a value between 0 and 1 representing the intensity of the given action. In a joypad, for example, the further away the axis (analog sticks or L2, R2 triggers) is from the dead zone, the closer the value will be to 1. If the action is mapped to a control that has no axis such as the keyboard, the value returned will be 0 or 1.
  314. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_Input_method_get_axis:
  318. .. rst-class:: classref-method
  319. :ref:`float<class_float>` **get_axis** **(** :ref:`StringName<class_StringName>` negative_action, :ref:`StringName<class_StringName>` positive_action **)** |const|
  320. Get axis input by specifying two actions, one negative and one positive.
  321. This is a shorthand for writing ``Input.get_action_strength("positive_action") - Input.get_action_strength("negative_action")``.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_Input_method_get_connected_joypads:
  325. .. rst-class:: classref-method
  326. :ref:`int[]<class_int>` **get_connected_joypads** **(** **)**
  327. Returns an :ref:`Array<class_Array>` containing the device IDs of all currently connected joypads.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_Input_method_get_current_cursor_shape:
  331. .. rst-class:: classref-method
  332. :ref:`CursorShape<enum_Input_CursorShape>` **get_current_cursor_shape** **(** **)** |const|
  333. Returns the currently assigned cursor shape (see :ref:`CursorShape<enum_Input_CursorShape>`).
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_Input_method_get_gravity:
  337. .. rst-class:: classref-method
  338. :ref:`Vector3<class_Vector3>` **get_gravity** **(** **)** |const|
  339. Returns the gravity in m/s² of the device's accelerometer sensor, if the device has one. Otherwise, the method returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  340. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  341. .. rst-class:: classref-item-separator
  342. ----
  343. .. _class_Input_method_get_gyroscope:
  344. .. rst-class:: classref-method
  345. :ref:`Vector3<class_Vector3>` **get_gyroscope** **(** **)** |const|
  346. Returns the rotation rate in rad/s around a device's X, Y, and Z axes of the gyroscope sensor, if the device has one. Otherwise, the method returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  347. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  348. .. rst-class:: classref-item-separator
  349. ----
  350. .. _class_Input_method_get_joy_axis:
  351. .. rst-class:: classref-method
  352. :ref:`float<class_float>` **get_joy_axis** **(** :ref:`int<class_int>` device, :ref:`JoyAxis<enum_@GlobalScope_JoyAxis>` axis **)** |const|
  353. Returns the current value of the joypad axis at given index (see :ref:`JoyAxis<enum_@GlobalScope_JoyAxis>`).
  354. .. rst-class:: classref-item-separator
  355. ----
  356. .. _class_Input_method_get_joy_guid:
  357. .. rst-class:: classref-method
  358. :ref:`String<class_String>` **get_joy_guid** **(** :ref:`int<class_int>` device **)** |const|
  359. Returns a SDL2-compatible device GUID on platforms that use gamepad remapping, e.g. ``030000004c050000c405000000010000``. Returns ``"Default Gamepad"`` otherwise. Godot uses the `SDL2 game controller database <https://github.com/gabomdq/SDL_GameControllerDB>`__ to determine gamepad names and mappings based on this GUID.
  360. .. rst-class:: classref-item-separator
  361. ----
  362. .. _class_Input_method_get_joy_info:
  363. .. rst-class:: classref-method
  364. :ref:`Dictionary<class_Dictionary>` **get_joy_info** **(** :ref:`int<class_int>` device **)** |const|
  365. Returns a dictionary with extra platform-specific information about the device, e.g. the raw gamepad name from the OS or the Steam Input index.
  366. On Windows the dictionary contains the following fields:
  367. \ ``xinput_index``: The index of the controller in the XInput system.
  368. On Linux:
  369. \ ``raw_name``: The name of the controller as it came from the OS, before getting renamed by the godot controller database.
  370. \ ``vendor_id``: The USB vendor ID of the device.
  371. \ ``product_id``: The USB product ID of the device.
  372. \ ``steam_input_index``: The Steam Input gamepad index, if the device is not a Steam Input device this key won't be present.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_Input_method_get_joy_name:
  376. .. rst-class:: classref-method
  377. :ref:`String<class_String>` **get_joy_name** **(** :ref:`int<class_int>` device **)**
  378. Returns the name of the joypad at the specified device index, e.g. ``PS4 Controller``. Godot uses the `SDL2 game controller database <https://github.com/gabomdq/SDL_GameControllerDB>`__ to determine gamepad names.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_Input_method_get_joy_vibration_duration:
  382. .. rst-class:: classref-method
  383. :ref:`float<class_float>` **get_joy_vibration_duration** **(** :ref:`int<class_int>` device **)**
  384. Returns the duration of the current vibration effect in seconds.
  385. .. rst-class:: classref-item-separator
  386. ----
  387. .. _class_Input_method_get_joy_vibration_strength:
  388. .. rst-class:: classref-method
  389. :ref:`Vector2<class_Vector2>` **get_joy_vibration_strength** **(** :ref:`int<class_int>` device **)**
  390. Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
  391. .. rst-class:: classref-item-separator
  392. ----
  393. .. _class_Input_method_get_last_mouse_velocity:
  394. .. rst-class:: classref-method
  395. :ref:`Vector2<class_Vector2>` **get_last_mouse_velocity** **(** **)**
  396. Returns the last mouse velocity. To provide a precise and jitter-free velocity, mouse velocity is only calculated every 0.1s. Therefore, mouse velocity will lag mouse movements.
  397. .. rst-class:: classref-item-separator
  398. ----
  399. .. _class_Input_method_get_magnetometer:
  400. .. rst-class:: classref-method
  401. :ref:`Vector3<class_Vector3>` **get_magnetometer** **(** **)** |const|
  402. Returns the magnetic field strength in micro-Tesla for all axes of the device's magnetometer sensor, if the device has one. Otherwise, the method returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  403. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  404. .. rst-class:: classref-item-separator
  405. ----
  406. .. _class_Input_method_get_mouse_button_mask:
  407. .. rst-class:: classref-method
  408. |bitfield|\<:ref:`MouseButtonMask<enum_@GlobalScope_MouseButtonMask>`\> **get_mouse_button_mask** **(** **)** |const|
  409. Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together. Equivalent to :ref:`DisplayServer.mouse_get_button_state<class_DisplayServer_method_mouse_get_button_state>`.
  410. .. rst-class:: classref-item-separator
  411. ----
  412. .. _class_Input_method_get_vector:
  413. .. rst-class:: classref-method
  414. :ref:`Vector2<class_Vector2>` **get_vector** **(** :ref:`StringName<class_StringName>` negative_x, :ref:`StringName<class_StringName>` positive_x, :ref:`StringName<class_StringName>` negative_y, :ref:`StringName<class_StringName>` positive_y, :ref:`float<class_float>` deadzone=-1.0 **)** |const|
  415. Gets an input vector by specifying four actions for the positive and negative X and Y axes.
  416. This method is useful when getting vector input, such as from a joystick, directional pad, arrows, or WASD. The vector has its length limited to 1 and has a circular deadzone, which is useful for using vector input as movement.
  417. By default, the deadzone is automatically calculated from the average of the action deadzones. However, you can override the deadzone to be whatever you want (on the range of 0 to 1).
  418. .. rst-class:: classref-item-separator
  419. ----
  420. .. _class_Input_method_is_action_just_pressed:
  421. .. rst-class:: classref-method
  422. :ref:`bool<class_bool>` **is_action_just_pressed** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  423. Returns ``true`` when the user has *started* pressing the action event in the current frame or physics tick. It will only return ``true`` on the frame or tick that the user pressed down the button.
  424. This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
  425. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  426. \ **Note:** Returning ``true`` does not imply that the action is *still* pressed. An action can be pressed and released again rapidly, and ``true`` will still be returned so as not to miss input.
  427. \ **Note:** Due to keyboard ghosting, :ref:`is_action_just_pressed<class_Input_method_is_action_just_pressed>` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information.
  428. \ **Note:** During input handling (e.g. :ref:`Node._input<class_Node_private_method__input>`), use :ref:`InputEvent.is_action_pressed<class_InputEvent_method_is_action_pressed>` instead to query the action state of the current event.
  429. .. rst-class:: classref-item-separator
  430. ----
  431. .. _class_Input_method_is_action_just_released:
  432. .. rst-class:: classref-method
  433. :ref:`bool<class_bool>` **is_action_just_released** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  434. Returns ``true`` when the user *stops* pressing the action event in the current frame or physics tick. It will only return ``true`` on the frame or tick that the user releases the button.
  435. \ **Note:** Returning ``true`` does not imply that the action is *still* not pressed. An action can be released and pressed again rapidly, and ``true`` will still be returned so as not to miss input.
  436. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  437. \ **Note:** During input handling (e.g. :ref:`Node._input<class_Node_private_method__input>`), use :ref:`InputEvent.is_action_released<class_InputEvent_method_is_action_released>` instead to query the action state of the current event.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_Input_method_is_action_pressed:
  441. .. rst-class:: classref-method
  442. :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  443. Returns ``true`` if you are pressing the action event.
  444. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  445. \ **Note:** Due to keyboard ghosting, :ref:`is_action_pressed<class_Input_method_is_action_pressed>` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information.
  446. .. rst-class:: classref-item-separator
  447. ----
  448. .. _class_Input_method_is_anything_pressed:
  449. .. rst-class:: classref-method
  450. :ref:`bool<class_bool>` **is_anything_pressed** **(** **)** |const|
  451. Returns ``true`` if any action, key, joypad button, or mouse button is being pressed. This will also return ``true`` if any action is simulated via code by calling :ref:`action_press<class_Input_method_action_press>`.
  452. .. rst-class:: classref-item-separator
  453. ----
  454. .. _class_Input_method_is_joy_button_pressed:
  455. .. rst-class:: classref-method
  456. :ref:`bool<class_bool>` **is_joy_button_pressed** **(** :ref:`int<class_int>` device, :ref:`JoyButton<enum_@GlobalScope_JoyButton>` button **)** |const|
  457. Returns ``true`` if you are pressing the joypad button (see :ref:`JoyButton<enum_@GlobalScope_JoyButton>`).
  458. .. rst-class:: classref-item-separator
  459. ----
  460. .. _class_Input_method_is_joy_known:
  461. .. rst-class:: classref-method
  462. :ref:`bool<class_bool>` **is_joy_known** **(** :ref:`int<class_int>` device **)**
  463. Returns ``true`` if the system knows the specified device. This means that it sets all button and axis indices. Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
  464. .. rst-class:: classref-item-separator
  465. ----
  466. .. _class_Input_method_is_key_label_pressed:
  467. .. rst-class:: classref-method
  468. :ref:`bool<class_bool>` **is_key_label_pressed** **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const|
  469. Returns ``true`` if you are pressing the key with the ``keycode`` printed on it. You can pass a :ref:`Key<enum_@GlobalScope_Key>` constant or any Unicode character code.
  470. .. rst-class:: classref-item-separator
  471. ----
  472. .. _class_Input_method_is_key_pressed:
  473. .. rst-class:: classref-method
  474. :ref:`bool<class_bool>` **is_key_pressed** **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const|
  475. Returns ``true`` if you are pressing the Latin key in the current keyboard layout. You can pass a :ref:`Key<enum_@GlobalScope_Key>` constant.
  476. \ :ref:`is_key_pressed<class_Input_method_is_key_pressed>` is only recommended over :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` in non-game applications. This ensures that shortcut keys behave as expected depending on the user's keyboard layout, as keyboard shortcuts are generally dependent on the keyboard layout in non-game applications. If in doubt, use :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>`.
  477. \ **Note:** Due to keyboard ghosting, :ref:`is_key_pressed<class_Input_method_is_key_pressed>` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_Input_method_is_mouse_button_pressed:
  481. .. rst-class:: classref-method
  482. :ref:`bool<class_bool>` **is_mouse_button_pressed** **(** :ref:`MouseButton<enum_@GlobalScope_MouseButton>` button **)** |const|
  483. Returns ``true`` if you are pressing the mouse button specified with :ref:`MouseButton<enum_@GlobalScope_MouseButton>`.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_Input_method_is_physical_key_pressed:
  487. .. rst-class:: classref-method
  488. :ref:`bool<class_bool>` **is_physical_key_pressed** **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const|
  489. Returns ``true`` if you are pressing the key in the physical location on the 101/102-key US QWERTY keyboard. You can pass a :ref:`Key<enum_@GlobalScope_Key>` constant.
  490. \ :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` is recommended over :ref:`is_key_pressed<class_Input_method_is_key_pressed>` for in-game actions, as it will make :kbd:`W`/:kbd:`A`/:kbd:`S`/:kbd:`D` layouts work regardless of the user's keyboard layout. :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` will also ensure that the top row number keys work on any keyboard layout. If in doubt, use :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>`.
  491. \ **Note:** Due to keyboard ghosting, :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` may return ``false`` even if one of the action's keys is pressed. See `Input examples <../tutorials/inputs/input_examples.html#keyboard-events>`__ in the documentation for more information.
  492. .. rst-class:: classref-item-separator
  493. ----
  494. .. _class_Input_method_parse_input_event:
  495. .. rst-class:: classref-method
  496. void **parse_input_event** **(** :ref:`InputEvent<class_InputEvent>` event **)**
  497. Feeds an :ref:`InputEvent<class_InputEvent>` to the game. Can be used to artificially trigger input events from code. Also generates :ref:`Node._input<class_Node_private_method__input>` calls.
  498. \ **Example:**\
  499. .. tabs::
  500. .. code-tab:: gdscript
  501. var cancel_event = InputEventAction.new()
  502. cancel_event.action = "ui_cancel"
  503. cancel_event.pressed = true
  504. Input.parse_input_event(cancel_event)
  505. .. code-tab:: csharp
  506. var cancelEvent = new InputEventAction();
  507. cancelEvent.Action = "ui_cancel";
  508. cancelEvent.Pressed = true;
  509. Input.ParseInputEvent(cancelEvent);
  510. .. rst-class:: classref-item-separator
  511. ----
  512. .. _class_Input_method_remove_joy_mapping:
  513. .. rst-class:: classref-method
  514. void **remove_joy_mapping** **(** :ref:`String<class_String>` guid **)**
  515. Removes all mappings from the internal database that match the given GUID.
  516. .. rst-class:: classref-item-separator
  517. ----
  518. .. _class_Input_method_set_accelerometer:
  519. .. rst-class:: classref-method
  520. void **set_accelerometer** **(** :ref:`Vector3<class_Vector3>` value **)**
  521. Sets the acceleration value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
  522. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  523. .. rst-class:: classref-item-separator
  524. ----
  525. .. _class_Input_method_set_custom_mouse_cursor:
  526. .. rst-class:: classref-method
  527. void **set_custom_mouse_cursor** **(** :ref:`Resource<class_Resource>` image, :ref:`CursorShape<enum_Input_CursorShape>` shape=0, :ref:`Vector2<class_Vector2>` hotspot=Vector2(0, 0) **)**
  528. Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing ``null`` to the image parameter resets to the system cursor. See :ref:`CursorShape<enum_Input_CursorShape>` for the list of shapes.
  529. \ ``image``'s size must be lower than or equal to 256×256. To avoid rendering issues, sizes lower than or equal to 128×128 are recommended.
  530. \ ``hotspot`` must be within ``image``'s size.
  531. \ **Note:** :ref:`AnimatedTexture<class_AnimatedTexture>`\ s aren't supported as custom mouse cursors. If using an :ref:`AnimatedTexture<class_AnimatedTexture>`, only the first frame will be displayed.
  532. \ **Note:** The **Lossless**, **Lossy** or **Uncompressed** compression modes are recommended. The **Video RAM** compression mode can be used, but it will be decompressed on the CPU, which means loading times are slowed down and no memory is saved compared to lossless modes.
  533. \ **Note:** On the web platform, the maximum allowed cursor image size is 128×128. Cursor images larger than 32×32 will also only be displayed if the mouse cursor image is entirely located within the page for `security reasons <https://chromestatus.com/feature/5825971391299584>`__.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Input_method_set_default_cursor_shape:
  537. .. rst-class:: classref-method
  538. void **set_default_cursor_shape** **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)**
  539. Sets the default cursor shape to be used in the viewport instead of :ref:`CURSOR_ARROW<class_Input_constant_CURSOR_ARROW>`.
  540. \ **Note:** If you want to change the default cursor shape for :ref:`Control<class_Control>`'s nodes, use :ref:`Control.mouse_default_cursor_shape<class_Control_property_mouse_default_cursor_shape>` instead.
  541. \ **Note:** This method generates an :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` to update cursor immediately.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _class_Input_method_set_gravity:
  545. .. rst-class:: classref-method
  546. void **set_gravity** **(** :ref:`Vector3<class_Vector3>` value **)**
  547. Sets the gravity value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
  548. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  549. .. rst-class:: classref-item-separator
  550. ----
  551. .. _class_Input_method_set_gyroscope:
  552. .. rst-class:: classref-method
  553. void **set_gyroscope** **(** :ref:`Vector3<class_Vector3>` value **)**
  554. Sets the value of the rotation rate of the gyroscope sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
  555. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  556. .. rst-class:: classref-item-separator
  557. ----
  558. .. _class_Input_method_set_magnetometer:
  559. .. rst-class:: classref-method
  560. void **set_magnetometer** **(** :ref:`Vector3<class_Vector3>` value **)**
  561. Sets the value of the magnetic field of the magnetometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
  562. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  563. .. rst-class:: classref-item-separator
  564. ----
  565. .. _class_Input_method_should_ignore_device:
  566. .. rst-class:: classref-method
  567. :ref:`bool<class_bool>` **should_ignore_device** **(** :ref:`int<class_int>` vendor_id, :ref:`int<class_int>` product_id **)** |const|
  568. Queries whether an input device should be ignored or not. Devices can be ignored by setting the environment variable ``SDL_GAMECONTROLLER_IGNORE_DEVICES``. Read the `SDL documentation <https://wiki.libsdl.org/SDL2>`__ for more information.
  569. \ **Note:** Some 3rd party tools can contribute to the list of ignored devices. For example, *SteamInput* creates virtual devices from physical devices for remapping purposes. To avoid handling the same input device twice, the original device is added to the ignore list.
  570. .. rst-class:: classref-item-separator
  571. ----
  572. .. _class_Input_method_start_joy_vibration:
  573. .. rst-class:: classref-method
  574. void **start_joy_vibration** **(** :ref:`int<class_int>` device, :ref:`float<class_float>` weak_magnitude, :ref:`float<class_float>` strong_magnitude, :ref:`float<class_float>` duration=0 **)**
  575. Starts to vibrate the joypad. Joypads usually come with two rumble motors, a strong and a weak one. ``weak_magnitude`` is the strength of the weak motor (between 0 and 1) and ``strong_magnitude`` is the strength of the strong motor (between 0 and 1). ``duration`` is the duration of the effect in seconds (a duration of 0 will try to play the vibration indefinitely). The vibration can be stopped early by calling :ref:`stop_joy_vibration<class_Input_method_stop_joy_vibration>`.
  576. \ **Note:** Not every hardware is compatible with long effect durations; it is recommended to restart an effect if it has to be played for more than a few seconds.
  577. .. rst-class:: classref-item-separator
  578. ----
  579. .. _class_Input_method_stop_joy_vibration:
  580. .. rst-class:: classref-method
  581. void **stop_joy_vibration** **(** :ref:`int<class_int>` device **)**
  582. Stops the vibration of the joypad started with :ref:`start_joy_vibration<class_Input_method_start_joy_vibration>`.
  583. .. rst-class:: classref-item-separator
  584. ----
  585. .. _class_Input_method_vibrate_handheld:
  586. .. rst-class:: classref-method
  587. void **vibrate_handheld** **(** :ref:`int<class_int>` duration_ms=500 **)**
  588. Vibrate the handheld device for the specified duration in milliseconds.
  589. \ **Note:** This method is implemented on Android, iOS, and Web. It has no effect on other platforms.
  590. \ **Note:** For Android, :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>` requires enabling the ``VIBRATE`` permission in the export preset. Otherwise, :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>` will have no effect.
  591. \ **Note:** For iOS, specifying the duration is only supported in iOS 13 and later.
  592. \ **Note:** Some web browsers such as Safari and Firefox for Android do not support :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>`.
  593. .. rst-class:: classref-item-separator
  594. ----
  595. .. _class_Input_method_warp_mouse:
  596. .. rst-class:: classref-method
  597. void **warp_mouse** **(** :ref:`Vector2<class_Vector2>` position **)**
  598. Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the currently focused Window Manager game window.
  599. Mouse position is clipped to the limits of the screen resolution, or to the limits of the game window if :ref:`MouseMode<enum_Input_MouseMode>` is set to :ref:`MOUSE_MODE_CONFINED<class_Input_constant_MOUSE_MODE_CONFINED>` or :ref:`MOUSE_MODE_CONFINED_HIDDEN<class_Input_constant_MOUSE_MODE_CONFINED_HIDDEN>`.
  600. \ **Note:** :ref:`warp_mouse<class_Input_method_warp_mouse>` is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.
  601. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  602. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  603. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  604. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  605. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  606. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  607. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`