class_input.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Input:
  4. Input
  5. =====
  6. **Inherits:** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`InputDefault<class_inputdefault>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Member Functions
  12. ----------------
  13. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | :ref:`bool<class_bool>` | :ref:`is_key_pressed<class_Input_is_key_pressed>` **(** :ref:`int<class_int>` scancode **)** |
  15. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`is_mouse_button_pressed<class_Input_is_mouse_button_pressed>` **(** :ref:`int<class_int>` button **)** |
  17. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`is_joy_button_pressed<class_Input_is_joy_button_pressed>` **(** :ref:`int<class_int>` device, :ref:`int<class_int>` button **)** |
  19. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`is_action_pressed<class_Input_is_action_pressed>` **(** :ref:`String<class_string>` action **)** |
  21. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`add_joy_mapping<class_Input_add_joy_mapping>` **(** :ref:`String<class_string>` mapping, :ref:`bool<class_bool>` update_existing=false **)** |
  23. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`remove_joy_mapping<class_Input_remove_joy_mapping>` **(** :ref:`String<class_string>` guid **)** |
  25. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`is_joy_known<class_Input_is_joy_known>` **(** :ref:`int<class_int>` device **)** |
  27. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`get_joy_axis<class_Input_get_joy_axis>` **(** :ref:`int<class_int>` device, :ref:`int<class_int>` axis **)** |
  29. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`String<class_string>` | :ref:`get_joy_name<class_Input_get_joy_name>` **(** :ref:`int<class_int>` device **)** |
  31. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`String<class_string>` | :ref:`get_joy_guid<class_Input_get_joy_guid>` **(** :ref:`int<class_int>` device **)** const |
  33. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Vector3<class_vector3>` | :ref:`get_accelerometer<class_Input_get_accelerometer>` **(** **)** |
  35. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Vector2<class_vector2>` | :ref:`get_mouse_speed<class_Input_get_mouse_speed>` **(** **)** const |
  37. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_mouse_button_mask<class_Input_get_mouse_button_mask>` **(** **)** const |
  39. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_mouse_mode<class_Input_set_mouse_mode>` **(** :ref:`int<class_int>` mode **)** |
  41. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_mouse_mode<class_Input_get_mouse_mode>` **(** **)** const |
  43. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`warp_mouse_pos<class_Input_warp_mouse_pos>` **(** :ref:`Vector2<class_vector2>` to **)** |
  45. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`action_press<class_Input_action_press>` **(** :ref:`String<class_string>` action **)** |
  47. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`action_release<class_Input_action_release>` **(** :ref:`String<class_string>` action **)** |
  49. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_custom_mouse_cursor<class_Input_set_custom_mouse_cursor>` **(** :ref:`Texture<class_texture>` image, :ref:`Vector2<class_vector2>` hotspot=Vector2(0,0) **)** |
  51. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. Signals
  53. -------
  54. - **joy_connection_changed** **(** :ref:`int<class_int>` index, :ref:`bool<class_bool>` connected **)**
  55. Numeric Constants
  56. -----------------
  57. - **MOUSE_MODE_VISIBLE** = **0**
  58. - **MOUSE_MODE_HIDDEN** = **1**
  59. - **MOUSE_MODE_CAPTURED** = **2**
  60. Member Function Description
  61. ---------------------------
  62. .. _class_Input_is_key_pressed:
  63. - :ref:`bool<class_bool>` **is_key_pressed** **(** :ref:`int<class_int>` scancode **)**
  64. .. _class_Input_is_mouse_button_pressed:
  65. - :ref:`bool<class_bool>` **is_mouse_button_pressed** **(** :ref:`int<class_int>` button **)**
  66. Returns true or false depending on whether mouse button is pressed or not. You can pass BUTTON\_\*, which are pre-defined constants listed in :ref:`@Global Scope<class_@global scope>`.
  67. .. _class_Input_is_joy_button_pressed:
  68. - :ref:`bool<class_bool>` **is_joy_button_pressed** **(** :ref:`int<class_int>` device, :ref:`int<class_int>` button **)**
  69. Returns if the joystick button at the given index is currently pressed. (see JOY\_\* constants in :ref:`@Global Scope<class_@global scope>`)
  70. .. _class_Input_is_action_pressed:
  71. - :ref:`bool<class_bool>` **is_action_pressed** **(** :ref:`String<class_string>` action **)**
  72. .. _class_Input_add_joy_mapping:
  73. - void **add_joy_mapping** **(** :ref:`String<class_string>` mapping, :ref:`bool<class_bool>` update_existing=false **)**
  74. Add a new mapping entry (in SDL2 format) to the mapping database. Optionally update already connected devices.
  75. .. _class_Input_remove_joy_mapping:
  76. - void **remove_joy_mapping** **(** :ref:`String<class_string>` guid **)**
  77. Removes all mappings from the internal db that match the given uid.
  78. .. _class_Input_is_joy_known:
  79. - :ref:`bool<class_bool>` **is_joy_known** **(** :ref:`int<class_int>` device **)**
  80. Returns if the specified device is known by the system. This means that it sets all button and axis indices exactly as defined in the JOY\_\* constants (see :ref:`@Global Scope<class_@global scope>`). Unknown joysticks are not expected to match these constants, but you can still retrieve events from them.
  81. .. _class_Input_get_joy_axis:
  82. - :ref:`float<class_float>` **get_joy_axis** **(** :ref:`int<class_int>` device, :ref:`int<class_int>` axis **)**
  83. Returns the current value of the joystick axis at given index (see JOY\_\* constants in :ref:`@Global Scope<class_@global scope>`)
  84. .. _class_Input_get_joy_name:
  85. - :ref:`String<class_string>` **get_joy_name** **(** :ref:`int<class_int>` device **)**
  86. Returns the name of the joystick at the specified device index
  87. .. _class_Input_get_joy_guid:
  88. - :ref:`String<class_string>` **get_joy_guid** **(** :ref:`int<class_int>` device **)** const
  89. Returns a SDL2 compatible device guid on platforms that use gamepad remapping. Returns "Default Gamepad" otherwise.
  90. .. _class_Input_get_accelerometer:
  91. - :ref:`Vector3<class_vector3>` **get_accelerometer** **(** **)**
  92. .. _class_Input_get_mouse_speed:
  93. - :ref:`Vector2<class_vector2>` **get_mouse_speed** **(** **)** const
  94. .. _class_Input_get_mouse_button_mask:
  95. - :ref:`int<class_int>` **get_mouse_button_mask** **(** **)** const
  96. .. _class_Input_set_mouse_mode:
  97. - void **set_mouse_mode** **(** :ref:`int<class_int>` mode **)**
  98. .. _class_Input_get_mouse_mode:
  99. - :ref:`int<class_int>` **get_mouse_mode** **(** **)** const
  100. .. _class_Input_warp_mouse_pos:
  101. - void **warp_mouse_pos** **(** :ref:`Vector2<class_vector2>` to **)**
  102. .. _class_Input_action_press:
  103. - void **action_press** **(** :ref:`String<class_string>` action **)**
  104. .. _class_Input_action_release:
  105. - void **action_release** **(** :ref:`String<class_string>` action **)**
  106. .. _class_Input_set_custom_mouse_cursor:
  107. - void **set_custom_mouse_cursor** **(** :ref:`Texture<class_texture>` image, :ref:`Vector2<class_vector2>` hotspot=Vector2(0,0) **)**