class_input.rst 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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 that deals with inputs.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A singleton that deals with inputs. This includes key presses, mouse buttons and movement, joypads, and input actions. Actions and their events can be set in the **Input Map** tab in the **Project > Project Settings**, or with the :ref:`InputMap<class_InputMap>` class.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`Inputs documentation index <../tutorials/inputs/index>`
  19. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  20. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/676>`__
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +----------------------------------------+--------------------------------------------------------------------------+
  27. | :ref:`MouseMode<enum_Input_MouseMode>` | :ref:`mouse_mode<class_Input_property_mouse_mode>` |
  28. +----------------------------------------+--------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`use_accumulated_input<class_Input_property_use_accumulated_input>` |
  30. +----------------------------------------+--------------------------------------------------------------------------+
  31. .. rst-class:: classref-reftable-group
  32. Methods
  33. -------
  34. .. table::
  35. :widths: auto
  36. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`action_press<class_Input_method_action_press>` **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` strength=1.0 **)** |
  38. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`action_release<class_Input_method_action_release>` **(** :ref:`StringName<class_StringName>` action **)** |
  40. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`add_joy_mapping<class_Input_method_add_joy_mapping>` **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)** |
  42. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`flush_buffered_events<class_Input_method_flush_buffered_events>` **(** **)** |
  44. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Vector3<class_Vector3>` | :ref:`get_accelerometer<class_Input_method_get_accelerometer>` **(** **)** |const| |
  46. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :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| |
  48. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :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| |
  50. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :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| |
  52. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int[]<class_int>` | :ref:`get_connected_joypads<class_Input_method_get_connected_joypads>` **(** **)** |
  54. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`CursorShape<enum_Input_CursorShape>` | :ref:`get_current_cursor_shape<class_Input_method_get_current_cursor_shape>` **(** **)** |const| |
  56. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Vector3<class_Vector3>` | :ref:`get_gravity<class_Input_method_get_gravity>` **(** **)** |const| |
  58. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Vector3<class_Vector3>` | :ref:`get_gyroscope<class_Input_method_get_gyroscope>` **(** **)** |const| |
  60. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :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| |
  62. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`String<class_String>` | :ref:`get_joy_guid<class_Input_method_get_joy_guid>` **(** :ref:`int<class_int>` device **)** |const| |
  64. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`String<class_String>` | :ref:`get_joy_name<class_Input_method_get_joy_name>` **(** :ref:`int<class_int>` device **)** |
  66. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`float<class_float>` | :ref:`get_joy_vibration_duration<class_Input_method_get_joy_vibration_duration>` **(** :ref:`int<class_int>` device **)** |
  68. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Vector2<class_Vector2>` | :ref:`get_joy_vibration_strength<class_Input_method_get_joy_vibration_strength>` **(** :ref:`int<class_int>` device **)** |
  70. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector2<class_Vector2>` | :ref:`get_last_mouse_velocity<class_Input_method_get_last_mouse_velocity>` **(** **)** |
  72. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Vector3<class_Vector3>` | :ref:`get_magnetometer<class_Input_method_get_magnetometer>` **(** **)** |const| |
  74. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`MouseButtonMask<enum_@GlobalScope_MouseButtonMask>` | :ref:`get_mouse_button_mask<class_Input_method_get_mouse_button_mask>` **(** **)** |const| |
  76. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :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| |
  78. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :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| |
  80. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :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| |
  82. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :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| |
  84. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_anything_pressed<class_Input_method_is_anything_pressed>` **(** **)** |const| |
  86. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :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| |
  88. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`bool<class_bool>` | :ref:`is_joy_known<class_Input_method_is_joy_known>` **(** :ref:`int<class_int>` device **)** |
  90. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`bool<class_bool>` | :ref:`is_key_label_pressed<class_Input_method_is_key_label_pressed>` **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const| |
  92. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`bool<class_bool>` | :ref:`is_key_pressed<class_Input_method_is_key_pressed>` **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const| |
  94. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`is_mouse_button_pressed<class_Input_method_is_mouse_button_pressed>` **(** :ref:`MouseButton<enum_@GlobalScope_MouseButton>` button **)** |const| |
  96. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const| |
  98. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`parse_input_event<class_Input_method_parse_input_event>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |
  100. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`remove_joy_mapping<class_Input_method_remove_joy_mapping>` **(** :ref:`String<class_String>` guid **)** |
  102. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`set_accelerometer<class_Input_method_set_accelerometer>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  104. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | 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) **)** |
  106. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`set_default_cursor_shape<class_Input_method_set_default_cursor_shape>` **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)** |
  108. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`set_gravity<class_Input_method_set_gravity>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  110. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`set_gyroscope<class_Input_method_set_gyroscope>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  112. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_magnetometer<class_Input_method_set_magnetometer>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  114. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | 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 **)** |
  116. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`stop_joy_vibration<class_Input_method_stop_joy_vibration>` **(** :ref:`int<class_int>` device **)** |
  118. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>` **(** :ref:`int<class_int>` duration_ms=500 **)** |
  120. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`warp_mouse<class_Input_method_warp_mouse>` **(** :ref:`Vector2<class_Vector2>` position **)** |
  122. +-----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. .. rst-class:: classref-section-separator
  124. ----
  125. .. rst-class:: classref-descriptions-group
  126. Signals
  127. -------
  128. .. _class_Input_signal_joy_connection_changed:
  129. .. rst-class:: classref-signal
  130. **joy_connection_changed** **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected **)**
  131. Emitted when a joypad device has been connected or disconnected.
  132. .. rst-class:: classref-section-separator
  133. ----
  134. .. rst-class:: classref-descriptions-group
  135. Enumerations
  136. ------------
  137. .. _enum_Input_MouseMode:
  138. .. rst-class:: classref-enumeration
  139. enum **MouseMode**:
  140. .. _class_Input_constant_MOUSE_MODE_VISIBLE:
  141. .. rst-class:: classref-enumeration-constant
  142. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_VISIBLE** = ``0``
  143. Makes the mouse cursor visible if it is hidden.
  144. .. _class_Input_constant_MOUSE_MODE_HIDDEN:
  145. .. rst-class:: classref-enumeration-constant
  146. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_HIDDEN** = ``1``
  147. Makes the mouse cursor hidden if it is visible.
  148. .. _class_Input_constant_MOUSE_MODE_CAPTURED:
  149. .. rst-class:: classref-enumeration-constant
  150. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CAPTURED** = ``2``
  151. Captures the mouse. The mouse will be hidden and its position locked at the center of the window manager's window.
  152. \ **Note:** If you want to process the mouse's movement in this mode, you need to use :ref:`InputEventMouseMotion.relative<class_InputEventMouseMotion_property_relative>`.
  153. .. _class_Input_constant_MOUSE_MODE_CONFINED:
  154. .. rst-class:: classref-enumeration-constant
  155. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CONFINED** = ``3``
  156. Confines the mouse cursor to the game window, and make it visible.
  157. .. _class_Input_constant_MOUSE_MODE_CONFINED_HIDDEN:
  158. .. rst-class:: classref-enumeration-constant
  159. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CONFINED_HIDDEN** = ``4``
  160. Confines the mouse cursor to the game window, and make it hidden.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _enum_Input_CursorShape:
  164. .. rst-class:: classref-enumeration
  165. enum **CursorShape**:
  166. .. _class_Input_constant_CURSOR_ARROW:
  167. .. rst-class:: classref-enumeration-constant
  168. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_ARROW** = ``0``
  169. Arrow cursor. Standard, default pointing cursor.
  170. .. _class_Input_constant_CURSOR_IBEAM:
  171. .. rst-class:: classref-enumeration-constant
  172. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_IBEAM** = ``1``
  173. I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked.
  174. .. _class_Input_constant_CURSOR_POINTING_HAND:
  175. .. rst-class:: classref-enumeration-constant
  176. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_POINTING_HAND** = ``2``
  177. Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item.
  178. .. _class_Input_constant_CURSOR_CROSS:
  179. .. rst-class:: classref-enumeration-constant
  180. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_CROSS** = ``3``
  181. Cross cursor. Typically appears over regions in which a drawing operation can be performed or for selections.
  182. .. _class_Input_constant_CURSOR_WAIT:
  183. .. rst-class:: classref-enumeration-constant
  184. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_WAIT** = ``4``
  185. 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).
  186. .. _class_Input_constant_CURSOR_BUSY:
  187. .. rst-class:: classref-enumeration-constant
  188. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_BUSY** = ``5``
  189. Busy cursor. Indicates that the application is busy performing an operation. This cursor shape denotes that the application is still usable during the operation.
  190. .. _class_Input_constant_CURSOR_DRAG:
  191. .. rst-class:: classref-enumeration-constant
  192. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_DRAG** = ``6``
  193. Drag cursor. Usually displayed when dragging something.
  194. \ **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.
  195. .. _class_Input_constant_CURSOR_CAN_DROP:
  196. .. rst-class:: classref-enumeration-constant
  197. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_CAN_DROP** = ``7``
  198. Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position.
  199. .. _class_Input_constant_CURSOR_FORBIDDEN:
  200. .. rst-class:: classref-enumeration-constant
  201. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_FORBIDDEN** = ``8``
  202. Forbidden cursor. Indicates that the current action is forbidden (for example, when dragging something) or that the control at a position is disabled.
  203. .. _class_Input_constant_CURSOR_VSIZE:
  204. .. rst-class:: classref-enumeration-constant
  205. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_VSIZE** = ``9``
  206. Vertical resize mouse cursor. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
  207. .. _class_Input_constant_CURSOR_HSIZE:
  208. .. rst-class:: classref-enumeration-constant
  209. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HSIZE** = ``10``
  210. Horizontal resize mouse cursor. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
  211. .. _class_Input_constant_CURSOR_BDIAGSIZE:
  212. .. rst-class:: classref-enumeration-constant
  213. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_BDIAGSIZE** = ``11``
  214. 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.
  215. .. _class_Input_constant_CURSOR_FDIAGSIZE:
  216. .. rst-class:: classref-enumeration-constant
  217. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_FDIAGSIZE** = ``12``
  218. 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.
  219. .. _class_Input_constant_CURSOR_MOVE:
  220. .. rst-class:: classref-enumeration-constant
  221. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_MOVE** = ``13``
  222. Move cursor. Indicates that something can be moved.
  223. .. _class_Input_constant_CURSOR_VSPLIT:
  224. .. rst-class:: classref-enumeration-constant
  225. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_VSPLIT** = ``14``
  226. Vertical split mouse cursor. On Windows, it's the same as :ref:`CURSOR_VSIZE<class_Input_constant_CURSOR_VSIZE>`.
  227. .. _class_Input_constant_CURSOR_HSPLIT:
  228. .. rst-class:: classref-enumeration-constant
  229. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HSPLIT** = ``15``
  230. Horizontal split mouse cursor. On Windows, it's the same as :ref:`CURSOR_HSIZE<class_Input_constant_CURSOR_HSIZE>`.
  231. .. _class_Input_constant_CURSOR_HELP:
  232. .. rst-class:: classref-enumeration-constant
  233. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HELP** = ``16``
  234. Help cursor. Usually a question mark.
  235. .. rst-class:: classref-section-separator
  236. ----
  237. .. rst-class:: classref-descriptions-group
  238. Property Descriptions
  239. ---------------------
  240. .. _class_Input_property_mouse_mode:
  241. .. rst-class:: classref-property
  242. :ref:`MouseMode<enum_Input_MouseMode>` **mouse_mode**
  243. .. rst-class:: classref-property-setget
  244. - void **set_mouse_mode** **(** :ref:`MouseMode<enum_Input_MouseMode>` value **)**
  245. - :ref:`MouseMode<enum_Input_MouseMode>` **get_mouse_mode** **(** **)**
  246. Controls the mouse mode. See :ref:`MouseMode<enum_Input_MouseMode>` for more information.
  247. .. rst-class:: classref-item-separator
  248. ----
  249. .. _class_Input_property_use_accumulated_input:
  250. .. rst-class:: classref-property
  251. :ref:`bool<class_bool>` **use_accumulated_input**
  252. .. rst-class:: classref-property-setget
  253. - void **set_use_accumulated_input** **(** :ref:`bool<class_bool>` value **)**
  254. - :ref:`bool<class_bool>` **is_using_accumulated_input** **(** **)**
  255. 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.
  256. 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.
  257. \ **Note:** Input accumulation is *enabled* by default.
  258. .. rst-class:: classref-section-separator
  259. ----
  260. .. rst-class:: classref-descriptions-group
  261. Method Descriptions
  262. -------------------
  263. .. _class_Input_method_action_press:
  264. .. rst-class:: classref-method
  265. void **action_press** **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` strength=1.0 **)**
  266. This will simulate pressing the specified action.
  267. The strength can be used for non-boolean actions, it's ranged between 0 and 1 representing the intensity of the given action.
  268. \ **Note:** This method will not cause any :ref:`Node._input<class_Node_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.
  269. .. rst-class:: classref-item-separator
  270. ----
  271. .. _class_Input_method_action_release:
  272. .. rst-class:: classref-method
  273. void **action_release** **(** :ref:`StringName<class_StringName>` action **)**
  274. If the specified action is already pressed, this will release it.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_Input_method_add_joy_mapping:
  278. .. rst-class:: classref-method
  279. void **add_joy_mapping** **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)**
  280. Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
  281. .. rst-class:: classref-item-separator
  282. ----
  283. .. _class_Input_method_flush_buffered_events:
  284. .. rst-class:: classref-method
  285. void **flush_buffered_events** **(** **)**
  286. 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>`).
  287. 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.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_Input_method_get_accelerometer:
  291. .. rst-class:: classref-method
  292. :ref:`Vector3<class_Vector3>` **get_accelerometer** **(** **)** |const|
  293. 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>`.
  294. 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.
  295. \ **Note:** This method only works on iOS, Android, and UWP. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_Input_method_get_action_raw_strength:
  299. .. rst-class:: classref-method
  300. :ref:`float<class_float>` **get_action_raw_strength** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  301. 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.
  302. 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.
  303. .. rst-class:: classref-item-separator
  304. ----
  305. .. _class_Input_method_get_action_strength:
  306. .. rst-class:: classref-method
  307. :ref:`float<class_float>` **get_action_strength** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  308. 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 as the keyboard, the value returned will be 0 or 1.
  309. 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.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_Input_method_get_axis:
  313. .. rst-class:: classref-method
  314. :ref:`float<class_float>` **get_axis** **(** :ref:`StringName<class_StringName>` negative_action, :ref:`StringName<class_StringName>` positive_action **)** |const|
  315. Get axis input by specifying two actions, one negative and one positive.
  316. This is a shorthand for writing ``Input.get_action_strength("positive_action") - Input.get_action_strength("negative_action")``.
  317. .. rst-class:: classref-item-separator
  318. ----
  319. .. _class_Input_method_get_connected_joypads:
  320. .. rst-class:: classref-method
  321. :ref:`int[]<class_int>` **get_connected_joypads** **(** **)**
  322. Returns an :ref:`Array<class_Array>` containing the device IDs of all currently connected joypads.
  323. .. rst-class:: classref-item-separator
  324. ----
  325. .. _class_Input_method_get_current_cursor_shape:
  326. .. rst-class:: classref-method
  327. :ref:`CursorShape<enum_Input_CursorShape>` **get_current_cursor_shape** **(** **)** |const|
  328. Returns the currently assigned cursor shape (see :ref:`CursorShape<enum_Input_CursorShape>`).
  329. .. rst-class:: classref-item-separator
  330. ----
  331. .. _class_Input_method_get_gravity:
  332. .. rst-class:: classref-method
  333. :ref:`Vector3<class_Vector3>` **get_gravity** **(** **)** |const|
  334. 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>`.
  335. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_Input_method_get_gyroscope:
  339. .. rst-class:: classref-method
  340. :ref:`Vector3<class_Vector3>` **get_gyroscope** **(** **)** |const|
  341. 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>`.
  342. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_Input_method_get_joy_axis:
  346. .. rst-class:: classref-method
  347. :ref:`float<class_float>` **get_joy_axis** **(** :ref:`int<class_int>` device, :ref:`JoyAxis<enum_@GlobalScope_JoyAxis>` axis **)** |const|
  348. Returns the current value of the joypad axis at given index (see :ref:`JoyAxis<enum_@GlobalScope_JoyAxis>`).
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_Input_method_get_joy_guid:
  352. .. rst-class:: classref-method
  353. :ref:`String<class_String>` **get_joy_guid** **(** :ref:`int<class_int>` device **)** |const|
  354. Returns a SDL2-compatible device GUID on platforms that use gamepad remapping. Returns ``"Default Gamepad"`` otherwise.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_Input_method_get_joy_name:
  358. .. rst-class:: classref-method
  359. :ref:`String<class_String>` **get_joy_name** **(** :ref:`int<class_int>` device **)**
  360. Returns the name of the joypad at the specified device index.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_Input_method_get_joy_vibration_duration:
  364. .. rst-class:: classref-method
  365. :ref:`float<class_float>` **get_joy_vibration_duration** **(** :ref:`int<class_int>` device **)**
  366. Returns the duration of the current vibration effect in seconds.
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_Input_method_get_joy_vibration_strength:
  370. .. rst-class:: classref-method
  371. :ref:`Vector2<class_Vector2>` **get_joy_vibration_strength** **(** :ref:`int<class_int>` device **)**
  372. Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_Input_method_get_last_mouse_velocity:
  376. .. rst-class:: classref-method
  377. :ref:`Vector2<class_Vector2>` **get_last_mouse_velocity** **(** **)**
  378. 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.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_Input_method_get_magnetometer:
  382. .. rst-class:: classref-method
  383. :ref:`Vector3<class_Vector3>` **get_magnetometer** **(** **)** |const|
  384. 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>`.
  385. \ **Note:** This method only works on Android, iOS and UWP. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_Input_method_get_mouse_button_mask:
  389. .. rst-class:: classref-method
  390. :ref:`MouseButtonMask<enum_@GlobalScope_MouseButtonMask>` **get_mouse_button_mask** **(** **)** |const|
  391. 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>`.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _class_Input_method_get_vector:
  395. .. rst-class:: classref-method
  396. :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|
  397. Gets an input vector by specifying four actions for the positive and negative X and Y axes.
  398. 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.
  399. 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).
  400. .. rst-class:: classref-item-separator
  401. ----
  402. .. _class_Input_method_is_action_just_pressed:
  403. .. rst-class:: classref-method
  404. :ref:`bool<class_bool>` **is_action_just_pressed** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  405. Returns ``true`` when the user starts pressing the action event, meaning it's ``true`` only on the frame that the user pressed down the button.
  406. This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
  407. 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.
  408. \ **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.
  409. .. rst-class:: classref-item-separator
  410. ----
  411. .. _class_Input_method_is_action_just_released:
  412. .. rst-class:: classref-method
  413. :ref:`bool<class_bool>` **is_action_just_released** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  414. Returns ``true`` when the user stops pressing the action event, meaning it's ``true`` only on the frame that the user released the button.
  415. 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.
  416. .. rst-class:: classref-item-separator
  417. ----
  418. .. _class_Input_method_is_action_pressed:
  419. .. rst-class:: classref-method
  420. :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  421. Returns ``true`` if you are pressing the action event. Note that if an action has multiple buttons assigned and more than one of them is pressed, releasing one button will release the action, even if some other button assigned to this action is still pressed.
  422. 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.
  423. \ **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.
  424. .. rst-class:: classref-item-separator
  425. ----
  426. .. _class_Input_method_is_anything_pressed:
  427. .. rst-class:: classref-method
  428. :ref:`bool<class_bool>` **is_anything_pressed** **(** **)** |const|
  429. 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>`.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_Input_method_is_joy_button_pressed:
  433. .. rst-class:: classref-method
  434. :ref:`bool<class_bool>` **is_joy_button_pressed** **(** :ref:`int<class_int>` device, :ref:`JoyButton<enum_@GlobalScope_JoyButton>` button **)** |const|
  435. Returns ``true`` if you are pressing the joypad button (see :ref:`JoyButton<enum_@GlobalScope_JoyButton>`).
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_Input_method_is_joy_known:
  439. .. rst-class:: classref-method
  440. :ref:`bool<class_bool>` **is_joy_known** **(** :ref:`int<class_int>` device **)**
  441. 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.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_Input_method_is_key_label_pressed:
  445. .. rst-class:: classref-method
  446. :ref:`bool<class_bool>` **is_key_label_pressed** **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const|
  447. 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.
  448. .. rst-class:: classref-item-separator
  449. ----
  450. .. _class_Input_method_is_key_pressed:
  451. .. rst-class:: classref-method
  452. :ref:`bool<class_bool>` **is_key_pressed** **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const|
  453. Returns ``true`` if you are pressing the Latin key in the current keyboard layout. You can pass a :ref:`Key<enum_@GlobalScope_Key>` constant.
  454. \ :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>`.
  455. \ **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.
  456. .. rst-class:: classref-item-separator
  457. ----
  458. .. _class_Input_method_is_mouse_button_pressed:
  459. .. rst-class:: classref-method
  460. :ref:`bool<class_bool>` **is_mouse_button_pressed** **(** :ref:`MouseButton<enum_@GlobalScope_MouseButton>` button **)** |const|
  461. Returns ``true`` if you are pressing the mouse button specified with :ref:`MouseButton<enum_@GlobalScope_MouseButton>`.
  462. .. rst-class:: classref-item-separator
  463. ----
  464. .. _class_Input_method_is_physical_key_pressed:
  465. .. rst-class:: classref-method
  466. :ref:`bool<class_bool>` **is_physical_key_pressed** **(** :ref:`Key<enum_@GlobalScope_Key>` keycode **)** |const|
  467. 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.
  468. \ :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>`.
  469. \ **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.
  470. .. rst-class:: classref-item-separator
  471. ----
  472. .. _class_Input_method_parse_input_event:
  473. .. rst-class:: classref-method
  474. void **parse_input_event** **(** :ref:`InputEvent<class_InputEvent>` event **)**
  475. 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_method__input>` calls.
  476. \ **Example:**\
  477. .. tabs::
  478. .. code-tab:: gdscript
  479. var cancel_event = InputEventAction.new()
  480. cancel_event.action = "ui_cancel"
  481. cancel_event.pressed = true
  482. Input.parse_input_event(cancel_event)
  483. .. code-tab:: csharp
  484. var cancelEvent = new InputEventAction();
  485. cancelEvent.Action = "ui_cancel";
  486. cancelEvent.Pressed = true;
  487. Input.ParseInputEvent(cancelEvent);
  488. .. rst-class:: classref-item-separator
  489. ----
  490. .. _class_Input_method_remove_joy_mapping:
  491. .. rst-class:: classref-method
  492. void **remove_joy_mapping** **(** :ref:`String<class_String>` guid **)**
  493. Removes all mappings from the internal database that match the given GUID.
  494. .. rst-class:: classref-item-separator
  495. ----
  496. .. _class_Input_method_set_accelerometer:
  497. .. rst-class:: classref-method
  498. void **set_accelerometer** **(** :ref:`Vector3<class_Vector3>` value **)**
  499. 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.
  500. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  501. .. rst-class:: classref-item-separator
  502. ----
  503. .. _class_Input_method_set_custom_mouse_cursor:
  504. .. rst-class:: classref-method
  505. 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) **)**
  506. 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.
  507. \ ``image``'s size must be lower than 256×256.
  508. \ ``hotspot`` must be within ``image``'s size.
  509. \ **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.
  510. \ **Note:** Only images imported with the **Lossless**, **Lossy** or **Uncompressed** compression modes are supported. The **Video RAM** compression mode can't be used for custom cursors.
  511. \ **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>`__.
  512. .. rst-class:: classref-item-separator
  513. ----
  514. .. _class_Input_method_set_default_cursor_shape:
  515. .. rst-class:: classref-method
  516. void **set_default_cursor_shape** **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)**
  517. Sets the default cursor shape to be used in the viewport instead of :ref:`CURSOR_ARROW<class_Input_constant_CURSOR_ARROW>`.
  518. \ **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.
  519. \ **Note:** This method generates an :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` to update cursor immediately.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_Input_method_set_gravity:
  523. .. rst-class:: classref-method
  524. void **set_gravity** **(** :ref:`Vector3<class_Vector3>` value **)**
  525. 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.
  526. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  527. .. rst-class:: classref-item-separator
  528. ----
  529. .. _class_Input_method_set_gyroscope:
  530. .. rst-class:: classref-method
  531. void **set_gyroscope** **(** :ref:`Vector3<class_Vector3>` value **)**
  532. 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.
  533. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Input_method_set_magnetometer:
  537. .. rst-class:: classref-method
  538. void **set_magnetometer** **(** :ref:`Vector3<class_Vector3>` value **)**
  539. 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.
  540. \ **Note:** This value can be immediately overwritten by the hardware sensor value on Android and iOS.
  541. .. rst-class:: classref-item-separator
  542. ----
  543. .. _class_Input_method_start_joy_vibration:
  544. .. rst-class:: classref-method
  545. 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 **)**
  546. 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>`.
  547. \ **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.
  548. .. rst-class:: classref-item-separator
  549. ----
  550. .. _class_Input_method_stop_joy_vibration:
  551. .. rst-class:: classref-method
  552. void **stop_joy_vibration** **(** :ref:`int<class_int>` device **)**
  553. Stops the vibration of the joypad started with :ref:`start_joy_vibration<class_Input_method_start_joy_vibration>`.
  554. .. rst-class:: classref-item-separator
  555. ----
  556. .. _class_Input_method_vibrate_handheld:
  557. .. rst-class:: classref-method
  558. void **vibrate_handheld** **(** :ref:`int<class_int>` duration_ms=500 **)**
  559. Vibrate the handheld device for the specified duration in milliseconds.
  560. \ **Note:** This method is implemented on Android, iOS, and Web. It has no effect on other platforms.
  561. \ **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.
  562. \ **Note:** For iOS, specifying the duration is only supported in iOS 13 and later.
  563. \ **Note:** Some web browsers such as Safari and Firefox for Android do not support :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>`.
  564. .. rst-class:: classref-item-separator
  565. ----
  566. .. _class_Input_method_warp_mouse:
  567. .. rst-class:: classref-method
  568. void **warp_mouse** **(** :ref:`Vector2<class_Vector2>` position **)**
  569. 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.
  570. 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>`.
  571. \ **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.
  572. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  573. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  574. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  575. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  576. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  577. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`