class_input.rst 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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 tutorial 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:`String<class_String>` action, :ref:`float<class_float>` strength=1.0 **)** |
  38. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`action_release<class_Input_method_action_release>` **(** :ref:`String<class_String>` 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:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const| |
  48. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_action_strength<class_Input_method_get_action_strength>` **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const| |
  50. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`float<class_float>` | :ref:`get_axis<class_Input_method_get_axis>` **(** :ref:`String<class_String>` negative_action, :ref:`String<class_String>` positive_action **)** |const| |
  52. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Array<class_Array>` | :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:`int<class_int>` axis **)** |const| |
  62. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`get_joy_axis_index_from_string<class_Input_method_get_joy_axis_index_from_string>` **(** :ref:`String<class_String>` axis **)** |
  64. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`String<class_String>` | :ref:`get_joy_axis_string<class_Input_method_get_joy_axis_string>` **(** :ref:`int<class_int>` axis_index **)** |
  66. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`int<class_int>` | :ref:`get_joy_button_index_from_string<class_Input_method_get_joy_button_index_from_string>` **(** :ref:`String<class_String>` button **)** |
  68. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`String<class_String>` | :ref:`get_joy_button_string<class_Input_method_get_joy_button_string>` **(** :ref:`int<class_int>` button_index **)** |
  70. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`String<class_String>` | :ref:`get_joy_guid<class_Input_method_get_joy_guid>` **(** :ref:`int<class_int>` device **)** |const| |
  72. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`String<class_String>` | :ref:`get_joy_name<class_Input_method_get_joy_name>` **(** :ref:`int<class_int>` device **)** |
  74. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`float<class_float>` | :ref:`get_joy_vibration_duration<class_Input_method_get_joy_vibration_duration>` **(** :ref:`int<class_int>` device **)** |
  76. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`Vector2<class_Vector2>` | :ref:`get_joy_vibration_strength<class_Input_method_get_joy_vibration_strength>` **(** :ref:`int<class_int>` device **)** |
  78. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`Vector2<class_Vector2>` | :ref:`get_last_mouse_speed<class_Input_method_get_last_mouse_speed>` **(** **)** |
  80. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`Vector3<class_Vector3>` | :ref:`get_magnetometer<class_Input_method_get_magnetometer>` **(** **)** |const| |
  82. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`int<class_int>` | :ref:`get_mouse_button_mask<class_Input_method_get_mouse_button_mask>` **(** **)** |const| |
  84. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Vector2<class_Vector2>` | :ref:`get_vector<class_Input_method_get_vector>` **(** :ref:`String<class_String>` negative_x, :ref:`String<class_String>` positive_x, :ref:`String<class_String>` negative_y, :ref:`String<class_String>` positive_y, :ref:`float<class_float>` deadzone=-1.0 **)** |const| |
  86. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`bool<class_bool>` | :ref:`is_action_just_pressed<class_Input_method_is_action_just_pressed>` **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const| |
  88. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`bool<class_bool>` | :ref:`is_action_just_released<class_Input_method_is_action_just_released>` **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const| |
  90. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`bool<class_bool>` | :ref:`is_action_pressed<class_Input_method_is_action_pressed>` **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const| |
  92. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`bool<class_bool>` | :ref:`is_joy_button_pressed<class_Input_method_is_joy_button_pressed>` **(** :ref:`int<class_int>` device, :ref:`int<class_int>` button **)** |const| |
  94. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`is_joy_known<class_Input_method_is_joy_known>` **(** :ref:`int<class_int>` device **)** |
  96. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`is_key_pressed<class_Input_method_is_key_pressed>` **(** :ref:`int<class_int>` scancode **)** |const| |
  98. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`is_mouse_button_pressed<class_Input_method_is_mouse_button_pressed>` **(** :ref:`int<class_int>` button **)** |const| |
  100. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`is_physical_key_pressed<class_Input_method_is_physical_key_pressed>` **(** :ref:`int<class_int>` scancode **)** |const| |
  102. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`joy_connection_changed<class_Input_method_joy_connection_changed>` **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected, :ref:`String<class_String>` name, :ref:`String<class_String>` guid **)** |
  104. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`parse_input_event<class_Input_method_parse_input_event>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |
  106. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`remove_joy_mapping<class_Input_method_remove_joy_mapping>` **(** :ref:`String<class_String>` guid **)** |
  108. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`set_accelerometer<class_Input_method_set_accelerometer>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  110. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | 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 ) **)** |
  112. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | void | :ref:`set_default_cursor_shape<class_Input_method_set_default_cursor_shape>` **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)** |
  114. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_gravity<class_Input_method_set_gravity>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  116. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | void | :ref:`set_gyroscope<class_Input_method_set_gyroscope>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  118. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | void | :ref:`set_magnetometer<class_Input_method_set_magnetometer>` **(** :ref:`Vector3<class_Vector3>` value **)** |
  120. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :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| |
  122. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | 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 **)** |
  124. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`stop_joy_vibration<class_Input_method_stop_joy_vibration>` **(** :ref:`int<class_int>` device **)** |
  126. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>` **(** :ref:`int<class_int>` duration_ms=500 **)** |
  128. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`warp_mouse_position<class_Input_method_warp_mouse_position>` **(** :ref:`Vector2<class_Vector2>` to **)** |
  130. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. .. rst-class:: classref-section-separator
  132. ----
  133. .. rst-class:: classref-descriptions-group
  134. Signals
  135. -------
  136. .. _class_Input_signal_joy_connection_changed:
  137. .. rst-class:: classref-signal
  138. **joy_connection_changed** **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected **)**
  139. Emitted when a joypad device has been connected or disconnected.
  140. .. rst-class:: classref-section-separator
  141. ----
  142. .. rst-class:: classref-descriptions-group
  143. Enumerations
  144. ------------
  145. .. _enum_Input_MouseMode:
  146. .. rst-class:: classref-enumeration
  147. enum **MouseMode**:
  148. .. _class_Input_constant_MOUSE_MODE_VISIBLE:
  149. .. rst-class:: classref-enumeration-constant
  150. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_VISIBLE** = ``0``
  151. Makes the mouse cursor visible if it is hidden.
  152. .. _class_Input_constant_MOUSE_MODE_HIDDEN:
  153. .. rst-class:: classref-enumeration-constant
  154. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_HIDDEN** = ``1``
  155. Makes the mouse cursor hidden if it is visible.
  156. .. _class_Input_constant_MOUSE_MODE_CAPTURED:
  157. .. rst-class:: classref-enumeration-constant
  158. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CAPTURED** = ``2``
  159. Captures the mouse. The mouse will be hidden and its position locked at the center of the screen.
  160. \ **Note:** If you want to process the mouse's movement in this mode, you need to use :ref:`InputEventMouseMotion.relative<class_InputEventMouseMotion_property_relative>`.
  161. .. _class_Input_constant_MOUSE_MODE_CONFINED:
  162. .. rst-class:: classref-enumeration-constant
  163. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CONFINED** = ``3``
  164. Confines the mouse cursor to the game window, and make it visible.
  165. .. _class_Input_constant_MOUSE_MODE_CONFINED_HIDDEN:
  166. .. rst-class:: classref-enumeration-constant
  167. :ref:`MouseMode<enum_Input_MouseMode>` **MOUSE_MODE_CONFINED_HIDDEN** = ``4``
  168. Confines the mouse cursor to the game window, and make it hidden.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _enum_Input_CursorShape:
  172. .. rst-class:: classref-enumeration
  173. enum **CursorShape**:
  174. .. _class_Input_constant_CURSOR_ARROW:
  175. .. rst-class:: classref-enumeration-constant
  176. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_ARROW** = ``0``
  177. Arrow cursor. Standard, default pointing cursor.
  178. .. _class_Input_constant_CURSOR_IBEAM:
  179. .. rst-class:: classref-enumeration-constant
  180. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_IBEAM** = ``1``
  181. I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked.
  182. .. _class_Input_constant_CURSOR_POINTING_HAND:
  183. .. rst-class:: classref-enumeration-constant
  184. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_POINTING_HAND** = ``2``
  185. Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item.
  186. .. _class_Input_constant_CURSOR_CROSS:
  187. .. rst-class:: classref-enumeration-constant
  188. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_CROSS** = ``3``
  189. Cross cursor. Typically appears over regions in which a drawing operation can be performed or for selections.
  190. .. _class_Input_constant_CURSOR_WAIT:
  191. .. rst-class:: classref-enumeration-constant
  192. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_WAIT** = ``4``
  193. 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).
  194. .. _class_Input_constant_CURSOR_BUSY:
  195. .. rst-class:: classref-enumeration-constant
  196. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_BUSY** = ``5``
  197. Busy cursor. Indicates that the application is busy performing an operation. This cursor shape denotes that the application is still usable during the operation.
  198. .. _class_Input_constant_CURSOR_DRAG:
  199. .. rst-class:: classref-enumeration-constant
  200. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_DRAG** = ``6``
  201. Drag cursor. Usually displayed when dragging something.
  202. .. _class_Input_constant_CURSOR_CAN_DROP:
  203. .. rst-class:: classref-enumeration-constant
  204. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_CAN_DROP** = ``7``
  205. Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position.
  206. .. _class_Input_constant_CURSOR_FORBIDDEN:
  207. .. rst-class:: classref-enumeration-constant
  208. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_FORBIDDEN** = ``8``
  209. Forbidden cursor. Indicates that the current action is forbidden (for example, when dragging something) or that the control at a position is disabled.
  210. .. _class_Input_constant_CURSOR_VSIZE:
  211. .. rst-class:: classref-enumeration-constant
  212. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_VSIZE** = ``9``
  213. Vertical resize mouse cursor. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
  214. .. _class_Input_constant_CURSOR_HSIZE:
  215. .. rst-class:: classref-enumeration-constant
  216. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HSIZE** = ``10``
  217. Horizontal resize mouse cursor. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
  218. .. _class_Input_constant_CURSOR_BDIAGSIZE:
  219. .. rst-class:: classref-enumeration-constant
  220. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_BDIAGSIZE** = ``11``
  221. 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.
  222. .. _class_Input_constant_CURSOR_FDIAGSIZE:
  223. .. rst-class:: classref-enumeration-constant
  224. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_FDIAGSIZE** = ``12``
  225. 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.
  226. .. _class_Input_constant_CURSOR_MOVE:
  227. .. rst-class:: classref-enumeration-constant
  228. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_MOVE** = ``13``
  229. Move cursor. Indicates that something can be moved.
  230. .. _class_Input_constant_CURSOR_VSPLIT:
  231. .. rst-class:: classref-enumeration-constant
  232. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_VSPLIT** = ``14``
  233. Vertical split mouse cursor. On Windows, it's the same as :ref:`CURSOR_VSIZE<class_Input_constant_CURSOR_VSIZE>`.
  234. .. _class_Input_constant_CURSOR_HSPLIT:
  235. .. rst-class:: classref-enumeration-constant
  236. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HSPLIT** = ``15``
  237. Horizontal split mouse cursor. On Windows, it's the same as :ref:`CURSOR_HSIZE<class_Input_constant_CURSOR_HSIZE>`.
  238. .. _class_Input_constant_CURSOR_HELP:
  239. .. rst-class:: classref-enumeration-constant
  240. :ref:`CursorShape<enum_Input_CursorShape>` **CURSOR_HELP** = ``16``
  241. Help cursor. Usually a question mark.
  242. .. rst-class:: classref-section-separator
  243. ----
  244. .. rst-class:: classref-descriptions-group
  245. Property Descriptions
  246. ---------------------
  247. .. _class_Input_property_mouse_mode:
  248. .. rst-class:: classref-property
  249. :ref:`MouseMode<enum_Input_MouseMode>` **mouse_mode**
  250. .. rst-class:: classref-property-setget
  251. - void **set_mouse_mode** **(** :ref:`MouseMode<enum_Input_MouseMode>` value **)**
  252. - :ref:`MouseMode<enum_Input_MouseMode>` **get_mouse_mode** **(** **)**
  253. Controls the mouse mode. See :ref:`MouseMode<enum_Input_MouseMode>` for more information.
  254. .. rst-class:: classref-item-separator
  255. ----
  256. .. _class_Input_property_use_accumulated_input:
  257. .. rst-class:: classref-property
  258. :ref:`bool<class_bool>` **use_accumulated_input**
  259. .. rst-class:: classref-property-setget
  260. - void **set_use_accumulated_input** **(** :ref:`bool<class_bool>` value **)**
  261. - :ref:`bool<class_bool>` **is_using_accumulated_input** **(** **)**
  262. 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.
  263. 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.
  264. \ **Note:** Input accumulation is *enabled* by default. It is recommended to keep it enabled for games which don't require very reactive input, as this will decrease CPU usage.
  265. .. rst-class:: classref-section-separator
  266. ----
  267. .. rst-class:: classref-descriptions-group
  268. Method Descriptions
  269. -------------------
  270. .. _class_Input_method_action_press:
  271. .. rst-class:: classref-method
  272. void **action_press** **(** :ref:`String<class_String>` action, :ref:`float<class_float>` strength=1.0 **)**
  273. This will simulate pressing the specified action.
  274. The strength can be used for non-boolean actions, it's ranged between 0 and 1 representing the intensity of the given action.
  275. \ **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.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_Input_method_action_release:
  279. .. rst-class:: classref-method
  280. void **action_release** **(** :ref:`String<class_String>` action **)**
  281. If the specified action is already pressed, this will release it.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_Input_method_add_joy_mapping:
  285. .. rst-class:: classref-method
  286. void **add_joy_mapping** **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)**
  287. Adds a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_Input_method_flush_buffered_events:
  291. .. rst-class:: classref-method
  292. void **flush_buffered_events** **(** **)**
  293. 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>`).
  294. 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.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_Input_method_get_accelerometer:
  298. .. rst-class:: classref-method
  299. :ref:`Vector3<class_Vector3>` **get_accelerometer** **(** **)** |const|
  300. Returns the acceleration of the device's accelerometer sensor, if the device has one. Otherwise, the method returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  301. 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.
  302. \ **Note:** This method only works on iOS, Android, and UWP. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`. On Android the unit of measurement for each axis is m/s² while on iOS and UWP it's a multiple of the Earth's gravitational acceleration ``g`` (~9.81 m/s²).
  303. .. rst-class:: classref-item-separator
  304. ----
  305. .. _class_Input_method_get_action_raw_strength:
  306. .. rst-class:: classref-method
  307. :ref:`float<class_float>` **get_action_raw_strength** **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const|
  308. 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.
  309. If ``exact`` 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_action_strength:
  313. .. rst-class:: classref-method
  314. :ref:`float<class_float>` **get_action_strength** **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const|
  315. 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.
  316. If ``exact`` 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.
  317. .. rst-class:: classref-item-separator
  318. ----
  319. .. _class_Input_method_get_axis:
  320. .. rst-class:: classref-method
  321. :ref:`float<class_float>` **get_axis** **(** :ref:`String<class_String>` negative_action, :ref:`String<class_String>` positive_action **)** |const|
  322. Get axis input by specifying two actions, one negative and one positive.
  323. This is a shorthand for writing ``Input.get_action_strength("positive_action") - Input.get_action_strength("negative_action")``.
  324. .. rst-class:: classref-item-separator
  325. ----
  326. .. _class_Input_method_get_connected_joypads:
  327. .. rst-class:: classref-method
  328. :ref:`Array<class_Array>` **get_connected_joypads** **(** **)**
  329. Returns an :ref:`Array<class_Array>` containing the device IDs of all currently connected joypads.
  330. .. rst-class:: classref-item-separator
  331. ----
  332. .. _class_Input_method_get_current_cursor_shape:
  333. .. rst-class:: classref-method
  334. :ref:`CursorShape<enum_Input_CursorShape>` **get_current_cursor_shape** **(** **)** |const|
  335. Returns the currently assigned cursor shape (see :ref:`CursorShape<enum_Input_CursorShape>`).
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_Input_method_get_gravity:
  339. .. rst-class:: classref-method
  340. :ref:`Vector3<class_Vector3>` **get_gravity** **(** **)** |const|
  341. Returns the gravity of the device's accelerometer 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>`. On Android the unit of measurement for each axis is m/s² while on iOS it's a multiple of the Earth's gravitational acceleration ``g`` (~9.81 m/s²).
  343. .. rst-class:: classref-item-separator
  344. ----
  345. .. _class_Input_method_get_gyroscope:
  346. .. rst-class:: classref-method
  347. :ref:`Vector3<class_Vector3>` **get_gyroscope** **(** **)** |const|
  348. 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>`.
  349. \ **Note:** This method only works on Android and iOS. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_Input_method_get_joy_axis:
  353. .. rst-class:: classref-method
  354. :ref:`float<class_float>` **get_joy_axis** **(** :ref:`int<class_int>` device, :ref:`int<class_int>` axis **)** |const|
  355. Returns the current value of the joypad axis at given index (see :ref:`JoystickList<enum_@GlobalScope_JoystickList>`).
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_Input_method_get_joy_axis_index_from_string:
  359. .. rst-class:: classref-method
  360. :ref:`int<class_int>` **get_joy_axis_index_from_string** **(** :ref:`String<class_String>` axis **)**
  361. Returns the index of the provided axis name.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_Input_method_get_joy_axis_string:
  365. .. rst-class:: classref-method
  366. :ref:`String<class_String>` **get_joy_axis_string** **(** :ref:`int<class_int>` axis_index **)**
  367. Receives a :ref:`JoystickList<enum_@GlobalScope_JoystickList>` axis and returns its equivalent name as a string.
  368. .. rst-class:: classref-item-separator
  369. ----
  370. .. _class_Input_method_get_joy_button_index_from_string:
  371. .. rst-class:: classref-method
  372. :ref:`int<class_int>` **get_joy_button_index_from_string** **(** :ref:`String<class_String>` button **)**
  373. Returns the index of the provided button name.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_Input_method_get_joy_button_string:
  377. .. rst-class:: classref-method
  378. :ref:`String<class_String>` **get_joy_button_string** **(** :ref:`int<class_int>` button_index **)**
  379. Receives a gamepad button from :ref:`JoystickList<enum_@GlobalScope_JoystickList>` and returns its equivalent name as a string.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_Input_method_get_joy_guid:
  383. .. rst-class:: classref-method
  384. :ref:`String<class_String>` **get_joy_guid** **(** :ref:`int<class_int>` device **)** |const|
  385. 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.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_Input_method_get_joy_name:
  389. .. rst-class:: classref-method
  390. :ref:`String<class_String>` **get_joy_name** **(** :ref:`int<class_int>` device **)**
  391. 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.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _class_Input_method_get_joy_vibration_duration:
  395. .. rst-class:: classref-method
  396. :ref:`float<class_float>` **get_joy_vibration_duration** **(** :ref:`int<class_int>` device **)**
  397. Returns the duration of the current vibration effect in seconds.
  398. .. rst-class:: classref-item-separator
  399. ----
  400. .. _class_Input_method_get_joy_vibration_strength:
  401. .. rst-class:: classref-method
  402. :ref:`Vector2<class_Vector2>` **get_joy_vibration_strength** **(** :ref:`int<class_int>` device **)**
  403. Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
  404. .. rst-class:: classref-item-separator
  405. ----
  406. .. _class_Input_method_get_last_mouse_speed:
  407. .. rst-class:: classref-method
  408. :ref:`Vector2<class_Vector2>` **get_last_mouse_speed** **(** **)**
  409. Returns the last mouse speed. To provide a precise and jitter-free speed, mouse speed is only calculated every 0.1s. Therefore, mouse speed will lag mouse movements.
  410. .. rst-class:: classref-item-separator
  411. ----
  412. .. _class_Input_method_get_magnetometer:
  413. .. rst-class:: classref-method
  414. :ref:`Vector3<class_Vector3>` **get_magnetometer** **(** **)** |const|
  415. 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>`.
  416. \ **Note:** This method only works on Android, iOS and UWP. On other platforms, it always returns :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`.
  417. .. rst-class:: classref-item-separator
  418. ----
  419. .. _class_Input_method_get_mouse_button_mask:
  420. .. rst-class:: classref-method
  421. :ref:`int<class_int>` **get_mouse_button_mask** **(** **)** |const|
  422. Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time, the bits are added together.
  423. .. rst-class:: classref-item-separator
  424. ----
  425. .. _class_Input_method_get_vector:
  426. .. rst-class:: classref-method
  427. :ref:`Vector2<class_Vector2>` **get_vector** **(** :ref:`String<class_String>` negative_x, :ref:`String<class_String>` positive_x, :ref:`String<class_String>` negative_y, :ref:`String<class_String>` positive_y, :ref:`float<class_float>` deadzone=-1.0 **)** |const|
  428. Gets an input vector by specifying four actions for the positive and negative X and Y axes.
  429. 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.
  430. 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).
  431. .. rst-class:: classref-item-separator
  432. ----
  433. .. _class_Input_method_is_action_just_pressed:
  434. .. rst-class:: classref-method
  435. :ref:`bool<class_bool>` **is_action_just_pressed** **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const|
  436. 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.
  437. This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
  438. If ``exact`` 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.
  439. \ **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.
  440. \ **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.
  441. .. rst-class:: classref-item-separator
  442. ----
  443. .. _class_Input_method_is_action_just_released:
  444. .. rst-class:: classref-method
  445. :ref:`bool<class_bool>` **is_action_just_released** **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const|
  446. 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.
  447. If ``exact`` 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.
  448. \ **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.
  449. .. rst-class:: classref-item-separator
  450. ----
  451. .. _class_Input_method_is_action_pressed:
  452. .. rst-class:: classref-method
  453. :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`String<class_String>` action, :ref:`bool<class_bool>` exact=false **)** |const|
  454. 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.
  455. If ``exact`` 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.
  456. \ **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.
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_Input_method_is_joy_button_pressed:
  460. .. rst-class:: classref-method
  461. :ref:`bool<class_bool>` **is_joy_button_pressed** **(** :ref:`int<class_int>` device, :ref:`int<class_int>` button **)** |const|
  462. Returns ``true`` if you are pressing the joypad button (see :ref:`JoystickList<enum_@GlobalScope_JoystickList>`).
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_Input_method_is_joy_known:
  466. .. rst-class:: classref-method
  467. :ref:`bool<class_bool>` **is_joy_known** **(** :ref:`int<class_int>` device **)**
  468. Returns ``true`` if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in :ref:`JoystickList<enum_@GlobalScope_JoystickList>`. Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
  469. .. rst-class:: classref-item-separator
  470. ----
  471. .. _class_Input_method_is_key_pressed:
  472. .. rst-class:: classref-method
  473. :ref:`bool<class_bool>` **is_key_pressed** **(** :ref:`int<class_int>` scancode **)** |const|
  474. Returns ``true`` if you are pressing the key in the current keyboard layout. You can pass a :ref:`KeyList<enum_@GlobalScope_KeyList>` constant.
  475. \ :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>`.
  476. \ **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.
  477. .. rst-class:: classref-item-separator
  478. ----
  479. .. _class_Input_method_is_mouse_button_pressed:
  480. .. rst-class:: classref-method
  481. :ref:`bool<class_bool>` **is_mouse_button_pressed** **(** :ref:`int<class_int>` button **)** |const|
  482. Returns ``true`` if you are pressing the mouse button specified with :ref:`ButtonList<enum_@GlobalScope_ButtonList>`.
  483. .. rst-class:: classref-item-separator
  484. ----
  485. .. _class_Input_method_is_physical_key_pressed:
  486. .. rst-class:: classref-method
  487. :ref:`bool<class_bool>` **is_physical_key_pressed** **(** :ref:`int<class_int>` scancode **)** |const|
  488. 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:`KeyList<enum_@GlobalScope_KeyList>` constant.
  489. \ :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 W/A/S/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>`.
  490. \ **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.
  491. .. rst-class:: classref-item-separator
  492. ----
  493. .. _class_Input_method_joy_connection_changed:
  494. .. rst-class:: classref-method
  495. void **joy_connection_changed** **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected, :ref:`String<class_String>` name, :ref:`String<class_String>` guid **)**
  496. Notifies the **Input** singleton that a connection has changed, to update the state for the ``device`` index.
  497. This is used internally and should not have to be called from user scripts. See :ref:`joy_connection_changed<class_Input_signal_joy_connection_changed>` for the signal emitted when this is triggered internally.
  498. .. rst-class:: classref-item-separator
  499. ----
  500. .. _class_Input_method_parse_input_event:
  501. .. rst-class:: classref-method
  502. void **parse_input_event** **(** :ref:`InputEvent<class_InputEvent>` event **)**
  503. 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.
  504. Example:
  505. ::
  506. var a = InputEventAction.new()
  507. a.action = "ui_cancel"
  508. a.pressed = true
  509. Input.parse_input_event(a)
  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:** 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.
  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 HTML5. 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_position:
  596. .. rst-class:: classref-method
  597. void **warp_mouse_position** **(** :ref:`Vector2<class_Vector2>` to **)**
  598. Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the 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>`.
  600. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  601. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  602. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  603. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`