class_input.rst 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Input.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Input:
  6. Input
  7. =====
  8. **Inherits:** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`InputDefault<class_InputDefault>`
  10. **Category:** Core
  11. Brief Description
  12. -----------------
  13. A Singleton that deals with inputs.
  14. Methods
  15. -------
  16. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`action_press<class_Input_method_action_press>` **(** :ref:`String<class_String>` action, :ref:`float<class_float>` strength=1.0 **)** |
  18. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`action_release<class_Input_method_action_release>` **(** :ref:`String<class_String>` action **)** |
  20. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`add_joy_mapping<class_Input_method_add_joy_mapping>` **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)** |
  22. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Vector3<class_Vector3>` | :ref:`get_accelerometer<class_Input_method_get_accelerometer>` **(** **)** const |
  24. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`get_action_strength<class_Input_method_get_action_strength>` **(** :ref:`String<class_String>` action **)** const |
  26. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_Array>` | :ref:`get_connected_joypads<class_Input_method_get_connected_joypads>` **(** **)** |
  28. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`CursorShape<enum_Input_CursorShape>` | :ref:`get_current_cursor_shape<class_Input_method_get_current_cursor_shape>` **(** **)** const |
  30. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Vector3<class_Vector3>` | :ref:`get_gravity<class_Input_method_get_gravity>` **(** **)** const |
  32. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Vector3<class_Vector3>` | :ref:`get_gyroscope<class_Input_method_get_gyroscope>` **(** **)** const |
  34. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :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 |
  36. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :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 **)** |
  38. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`String<class_String>` | :ref:`get_joy_axis_string<class_Input_method_get_joy_axis_string>` **(** :ref:`int<class_int>` axis_index **)** |
  40. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :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 **)** |
  42. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`String<class_String>` | :ref:`get_joy_button_string<class_Input_method_get_joy_button_string>` **(** :ref:`int<class_int>` button_index **)** |
  44. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`String<class_String>` | :ref:`get_joy_guid<class_Input_method_get_joy_guid>` **(** :ref:`int<class_int>` device **)** const |
  46. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`String<class_String>` | :ref:`get_joy_name<class_Input_method_get_joy_name>` **(** :ref:`int<class_int>` device **)** |
  48. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_joy_vibration_duration<class_Input_method_get_joy_vibration_duration>` **(** :ref:`int<class_int>` device **)** |
  50. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector2<class_Vector2>` | :ref:`get_joy_vibration_strength<class_Input_method_get_joy_vibration_strength>` **(** :ref:`int<class_int>` device **)** |
  52. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Vector2<class_Vector2>` | :ref:`get_last_mouse_speed<class_Input_method_get_last_mouse_speed>` **(** **)** const |
  54. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Vector3<class_Vector3>` | :ref:`get_magnetometer<class_Input_method_get_magnetometer>` **(** **)** const |
  56. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_mouse_button_mask<class_Input_method_get_mouse_button_mask>` **(** **)** const |
  58. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`MouseMode<enum_Input_MouseMode>` | :ref:`get_mouse_mode<class_Input_method_get_mouse_mode>` **(** **)** const |
  60. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`is_action_just_pressed<class_Input_method_is_action_just_pressed>` **(** :ref:`String<class_String>` action **)** const |
  62. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`is_action_just_released<class_Input_method_is_action_just_released>` **(** :ref:`String<class_String>` action **)** const |
  64. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`is_action_pressed<class_Input_method_is_action_pressed>` **(** :ref:`String<class_String>` action **)** const |
  66. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :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 |
  68. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`is_joy_known<class_Input_method_is_joy_known>` **(** :ref:`int<class_int>` device **)** |
  70. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`bool<class_bool>` | :ref:`is_key_pressed<class_Input_method_is_key_pressed>` **(** :ref:`int<class_int>` scancode **)** const |
  72. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_mouse_button_pressed<class_Input_method_is_mouse_button_pressed>` **(** :ref:`int<class_int>` button **)** const |
  74. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | 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 **)** |
  76. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`parse_input_event<class_Input_method_parse_input_event>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |
  78. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`remove_joy_mapping<class_Input_method_remove_joy_mapping>` **(** :ref:`String<class_String>` guid **)** |
  80. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | 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 ) **)** |
  82. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`set_default_cursor_shape<class_Input_method_set_default_cursor_shape>` **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)** |
  84. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`set_mouse_mode<class_Input_method_set_mouse_mode>` **(** :ref:`MouseMode<enum_Input_MouseMode>` mode **)** |
  86. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`set_use_accumulated_input<class_Input_method_set_use_accumulated_input>` **(** :ref:`bool<class_bool>` enable **)** |
  88. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | 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 **)** |
  90. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`stop_joy_vibration<class_Input_method_stop_joy_vibration>` **(** :ref:`int<class_int>` device **)** |
  92. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`vibrate_handheld<class_Input_method_vibrate_handheld>` **(** :ref:`int<class_int>` duration_ms=500 **)** |
  94. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`warp_mouse_position<class_Input_method_warp_mouse_position>` **(** :ref:`Vector2<class_Vector2>` to **)** |
  96. +--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. Signals
  98. -------
  99. .. _class_Input_signal_joy_connection_changed:
  100. - **joy_connection_changed** **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected **)**
  101. Emitted when a joypad device has been connected or disconnected.
  102. Enumerations
  103. ------------
  104. .. _enum_Input_MouseMode:
  105. .. _class_Input_constant_MOUSE_MODE_VISIBLE:
  106. .. _class_Input_constant_MOUSE_MODE_HIDDEN:
  107. .. _class_Input_constant_MOUSE_MODE_CAPTURED:
  108. .. _class_Input_constant_MOUSE_MODE_CONFINED:
  109. enum **MouseMode**:
  110. - **MOUSE_MODE_VISIBLE** = **0** --- Makes the mouse cursor visible if it is hidden.
  111. - **MOUSE_MODE_HIDDEN** = **1** --- Makes the mouse cursor hidden if it is visible.
  112. - **MOUSE_MODE_CAPTURED** = **2** --- Captures the mouse. The mouse will be hidden and unable to leave the game window, but it will still register movement and mouse button presses. On Windows and Linux, the mouse will use raw input mode, which means the reported movement will be unaffected by the OS' mouse acceleration settings.
  113. - **MOUSE_MODE_CONFINED** = **3** --- Makes the mouse cursor visible but confines it to the game window.
  114. ----
  115. .. _enum_Input_CursorShape:
  116. .. _class_Input_constant_CURSOR_ARROW:
  117. .. _class_Input_constant_CURSOR_IBEAM:
  118. .. _class_Input_constant_CURSOR_POINTING_HAND:
  119. .. _class_Input_constant_CURSOR_CROSS:
  120. .. _class_Input_constant_CURSOR_WAIT:
  121. .. _class_Input_constant_CURSOR_BUSY:
  122. .. _class_Input_constant_CURSOR_DRAG:
  123. .. _class_Input_constant_CURSOR_CAN_DROP:
  124. .. _class_Input_constant_CURSOR_FORBIDDEN:
  125. .. _class_Input_constant_CURSOR_VSIZE:
  126. .. _class_Input_constant_CURSOR_HSIZE:
  127. .. _class_Input_constant_CURSOR_BDIAGSIZE:
  128. .. _class_Input_constant_CURSOR_FDIAGSIZE:
  129. .. _class_Input_constant_CURSOR_MOVE:
  130. .. _class_Input_constant_CURSOR_VSPLIT:
  131. .. _class_Input_constant_CURSOR_HSPLIT:
  132. .. _class_Input_constant_CURSOR_HELP:
  133. enum **CursorShape**:
  134. - **CURSOR_ARROW** = **0** --- Arrow cursor. Standard, default pointing cursor.
  135. - **CURSOR_IBEAM** = **1** --- I-beam cursor. Usually used to show where the text cursor will appear when the mouse is clicked.
  136. - **CURSOR_POINTING_HAND** = **2** --- Pointing hand cursor. Usually used to indicate the pointer is over a link or other interactable item.
  137. - **CURSOR_CROSS** = **3** --- Cross cursor. Typically appears over regions in which a drawing operation can be performed or for selections.
  138. - **CURSOR_WAIT** = **4** --- Wait cursor. Indicates that the application is busy performing an operation.
  139. - **CURSOR_BUSY** = **5** --- Busy cursor. See :ref:`CURSOR_WAIT<class_Input_constant_CURSOR_WAIT>`.
  140. - **CURSOR_DRAG** = **6** --- Drag cursor. Usually displayed when dragging something.
  141. - **CURSOR_CAN_DROP** = **7** --- Can drop cursor. Usually displayed when dragging something to indicate that it can be dropped at the current position.
  142. - **CURSOR_FORBIDDEN** = **8** --- Forbidden cursor. Indicates that the current action is forbidden (for example, when dragging something) or that the control at a position is disabled.
  143. - **CURSOR_VSIZE** = **9** --- Vertical resize mouse cursor. A double headed vertical arrow. It tells the user they can resize the window or the panel vertically.
  144. - **CURSOR_HSIZE** = **10** --- Horizontal resize mouse cursor. A double headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
  145. - **CURSOR_BDIAGSIZE** = **11** --- 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.
  146. - **CURSOR_FDIAGSIZE** = **12** --- 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.
  147. - **CURSOR_MOVE** = **13** --- Move cursor. Indicates that something can be moved.
  148. - **CURSOR_VSPLIT** = **14** --- Vertical split mouse cursor. On Windows, it's the same as :ref:`CURSOR_VSIZE<class_Input_constant_CURSOR_VSIZE>`.
  149. - **CURSOR_HSPLIT** = **15** --- Horizontal split mouse cursor. On Windows, it's the same as :ref:`CURSOR_HSIZE<class_Input_constant_CURSOR_HSIZE>`.
  150. - **CURSOR_HELP** = **16** --- Help cursor. Usually a question mark.
  151. Description
  152. -----------
  153. 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 Project Settings / Input Map tab. Or be set with :ref:`InputMap<class_InputMap>`.
  154. Tutorials
  155. ---------
  156. - :doc:`../tutorials/inputs/index`
  157. Method Descriptions
  158. -------------------
  159. .. _class_Input_method_action_press:
  160. - void **action_press** **(** :ref:`String<class_String>` action, :ref:`float<class_float>` strength=1.0 **)**
  161. This will simulate pressing the specified action.
  162. The strength can be used for non-boolean actions, it's ranged between 0 and 1 representing the intensity of the given action.
  163. **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.
  164. ----
  165. .. _class_Input_method_action_release:
  166. - void **action_release** **(** :ref:`String<class_String>` action **)**
  167. If the specified action is already pressed, this will release it.
  168. ----
  169. .. _class_Input_method_add_joy_mapping:
  170. - void **add_joy_mapping** **(** :ref:`String<class_String>` mapping, :ref:`bool<class_bool>` update_existing=false **)**
  171. Add a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
  172. ----
  173. .. _class_Input_method_get_accelerometer:
  174. - :ref:`Vector3<class_Vector3>` **get_accelerometer** **(** **)** const
  175. If the device has an accelerometer, this will return the acceleration. Otherwise, it returns an empty :ref:`Vector3<class_Vector3>`.
  176. 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.
  177. ----
  178. .. _class_Input_method_get_action_strength:
  179. - :ref:`float<class_float>` **get_action_strength** **(** :ref:`String<class_String>` action **)** const
  180. 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.
  181. ----
  182. .. _class_Input_method_get_connected_joypads:
  183. - :ref:`Array<class_Array>` **get_connected_joypads** **(** **)**
  184. Returns an :ref:`Array<class_Array>` containing the device IDs of all currently connected joypads.
  185. ----
  186. .. _class_Input_method_get_current_cursor_shape:
  187. - :ref:`CursorShape<enum_Input_CursorShape>` **get_current_cursor_shape** **(** **)** const
  188. ----
  189. .. _class_Input_method_get_gravity:
  190. - :ref:`Vector3<class_Vector3>` **get_gravity** **(** **)** const
  191. If the device has an accelerometer, this will return the gravity. Otherwise, it returns an empty :ref:`Vector3<class_Vector3>`.
  192. ----
  193. .. _class_Input_method_get_gyroscope:
  194. - :ref:`Vector3<class_Vector3>` **get_gyroscope** **(** **)** const
  195. If the device has a gyroscope, this will return the rate of rotation in rad/s around a device's x, y, and z axis. Otherwise, it returns an empty :ref:`Vector3<class_Vector3>`.
  196. ----
  197. .. _class_Input_method_get_joy_axis:
  198. - :ref:`float<class_float>` **get_joy_axis** **(** :ref:`int<class_int>` device, :ref:`int<class_int>` axis **)** const
  199. Returns the current value of the joypad axis at given index (see ``JOY_*`` constants in :ref:`@GlobalScope<class_@GlobalScope>`)
  200. ----
  201. .. _class_Input_method_get_joy_axis_index_from_string:
  202. - :ref:`int<class_int>` **get_joy_axis_index_from_string** **(** :ref:`String<class_String>` axis **)**
  203. Returns the index of the provided axis name.
  204. ----
  205. .. _class_Input_method_get_joy_axis_string:
  206. - :ref:`String<class_String>` **get_joy_axis_string** **(** :ref:`int<class_int>` axis_index **)**
  207. Receives a ``JOY_AXIS_*`` Enum and returns its equivalent name as a string.
  208. ----
  209. .. _class_Input_method_get_joy_button_index_from_string:
  210. - :ref:`int<class_int>` **get_joy_button_index_from_string** **(** :ref:`String<class_String>` button **)**
  211. Returns the index of the provided button name.
  212. ----
  213. .. _class_Input_method_get_joy_button_string:
  214. - :ref:`String<class_String>` **get_joy_button_string** **(** :ref:`int<class_int>` button_index **)**
  215. Receives a ``JOY_BUTTON_*`` Enum and returns its equivalent name as a string.
  216. ----
  217. .. _class_Input_method_get_joy_guid:
  218. - :ref:`String<class_String>` **get_joy_guid** **(** :ref:`int<class_int>` device **)** const
  219. Returns a SDL2 compatible device guid on platforms that use gamepad remapping. Returns "Default Gamepad" otherwise.
  220. ----
  221. .. _class_Input_method_get_joy_name:
  222. - :ref:`String<class_String>` **get_joy_name** **(** :ref:`int<class_int>` device **)**
  223. Returns the name of the joypad at the specified device index
  224. ----
  225. .. _class_Input_method_get_joy_vibration_duration:
  226. - :ref:`float<class_float>` **get_joy_vibration_duration** **(** :ref:`int<class_int>` device **)**
  227. Returns the duration of the current vibration effect in seconds.
  228. ----
  229. .. _class_Input_method_get_joy_vibration_strength:
  230. - :ref:`Vector2<class_Vector2>` **get_joy_vibration_strength** **(** :ref:`int<class_int>` device **)**
  231. Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor.
  232. ----
  233. .. _class_Input_method_get_last_mouse_speed:
  234. - :ref:`Vector2<class_Vector2>` **get_last_mouse_speed** **(** **)** const
  235. Returns the mouse speed for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion.
  236. ----
  237. .. _class_Input_method_get_magnetometer:
  238. - :ref:`Vector3<class_Vector3>` **get_magnetometer** **(** **)** const
  239. If the device has a magnetometer, this will return the magnetic field strength in micro-Tesla for all axes.
  240. ----
  241. .. _class_Input_method_get_mouse_button_mask:
  242. - :ref:`int<class_int>` **get_mouse_button_mask** **(** **)** const
  243. Returns mouse buttons as a bitmask. If multiple mouse buttons are pressed at the same time the bits are added together.
  244. ----
  245. .. _class_Input_method_get_mouse_mode:
  246. - :ref:`MouseMode<enum_Input_MouseMode>` **get_mouse_mode** **(** **)** const
  247. Returns the mouse mode. See the constants for more information.
  248. ----
  249. .. _class_Input_method_is_action_just_pressed:
  250. - :ref:`bool<class_bool>` **is_action_just_pressed** **(** :ref:`String<class_String>` action **)** const
  251. 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.
  252. This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
  253. ----
  254. .. _class_Input_method_is_action_just_released:
  255. - :ref:`bool<class_bool>` **is_action_just_released** **(** :ref:`String<class_String>` action **)** const
  256. Returns ``true`` when the user stops pressing the action event, meaning it's ``true`` only on the frame that the user released the button.
  257. ----
  258. .. _class_Input_method_is_action_pressed:
  259. - :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`String<class_String>` action **)** const
  260. Returns ``true`` if you are pressing the action event. Note that if an action has multiple buttons asigned 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.
  261. ----
  262. .. _class_Input_method_is_joy_button_pressed:
  263. - :ref:`bool<class_bool>` **is_joy_button_pressed** **(** :ref:`int<class_int>` device, :ref:`int<class_int>` button **)** const
  264. Returns ``true`` if you are pressing the joypad button. (see ``JOY_*`` constants in :ref:`@GlobalScope<class_@GlobalScope>`)
  265. ----
  266. .. _class_Input_method_is_joy_known:
  267. - :ref:`bool<class_bool>` **is_joy_known** **(** :ref:`int<class_int>` device **)**
  268. Returns ``true`` if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in the ``JOY_*`` constants (see :ref:`@GlobalScope<class_@GlobalScope>`). Unknown joypads are not expected to match these constants, but you can still retrieve events from them.
  269. ----
  270. .. _class_Input_method_is_key_pressed:
  271. - :ref:`bool<class_bool>` **is_key_pressed** **(** :ref:`int<class_int>` scancode **)** const
  272. Returns ``true`` if you are pressing the key. You can pass ``KEY_*``, which are pre-defined constants listed in :ref:`@GlobalScope<class_@GlobalScope>`.
  273. ----
  274. .. _class_Input_method_is_mouse_button_pressed:
  275. - :ref:`bool<class_bool>` **is_mouse_button_pressed** **(** :ref:`int<class_int>` button **)** const
  276. Returns ``true`` if you are pressing the mouse button. You can pass ``BUTTON_*``, which are pre-defined constants listed in :ref:`@GlobalScope<class_@GlobalScope>`.
  277. ----
  278. .. _class_Input_method_joy_connection_changed:
  279. - void **joy_connection_changed** **(** :ref:`int<class_int>` device, :ref:`bool<class_bool>` connected, :ref:`String<class_String>` name, :ref:`String<class_String>` guid **)**
  280. ----
  281. .. _class_Input_method_parse_input_event:
  282. - void **parse_input_event** **(** :ref:`InputEvent<class_InputEvent>` event **)**
  283. 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.
  284. Example:
  285. ::
  286. var a = InputEventAction.new()
  287. a.action = "ui_cancel"
  288. a.pressed = true
  289. Input.parse_input_event(a)
  290. ----
  291. .. _class_Input_method_remove_joy_mapping:
  292. - void **remove_joy_mapping** **(** :ref:`String<class_String>` guid **)**
  293. Removes all mappings from the internal db that match the given uid.
  294. ----
  295. .. _class_Input_method_set_custom_mouse_cursor:
  296. - 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 ) **)**
  297. 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 enum ``CURSOR_*`` for the list of shapes.
  298. ``image``'s size must be lower than 256x256.
  299. ``hotspot`` must be within ``image``'s size.
  300. ----
  301. .. _class_Input_method_set_default_cursor_shape:
  302. - void **set_default_cursor_shape** **(** :ref:`CursorShape<enum_Input_CursorShape>` shape=0 **)**
  303. Sets the default cursor shape to be used in the viewport instead of :ref:`CURSOR_ARROW<class_Input_constant_CURSOR_ARROW>`.
  304. **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.
  305. **Note:** This method generates an :ref:`InputEventMouseMotion<class_InputEventMouseMotion>` to update cursor immediately.
  306. ----
  307. .. _class_Input_method_set_mouse_mode:
  308. - void **set_mouse_mode** **(** :ref:`MouseMode<enum_Input_MouseMode>` mode **)**
  309. Set the mouse mode. See the constants for more information.
  310. ----
  311. .. _class_Input_method_set_use_accumulated_input:
  312. - void **set_use_accumulated_input** **(** :ref:`bool<class_bool>` enable **)**
  313. Whether to accumulate similar input events sent by the operating system. Defaults to ``true``.
  314. ----
  315. .. _class_Input_method_start_joy_vibration:
  316. - 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 **)**
  317. 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).
  318. Note that not every hardware is compatible with long effect durations, it is recommended to restart an effect if in need to play it for more than a few seconds.
  319. ----
  320. .. _class_Input_method_stop_joy_vibration:
  321. - void **stop_joy_vibration** **(** :ref:`int<class_int>` device **)**
  322. Stops the vibration of the joypad.
  323. ----
  324. .. _class_Input_method_vibrate_handheld:
  325. - void **vibrate_handheld** **(** :ref:`int<class_int>` duration_ms=500 **)**
  326. Vibrate Android and iOS devices.
  327. **Note:** It needs VIBRATE permission for Android at export settings. iOS does not support duration.
  328. ----
  329. .. _class_Input_method_warp_mouse_position:
  330. - void **warp_mouse_position** **(** :ref:`Vector2<class_Vector2>` to **)**
  331. Sets the mouse position to the specified vector.