class_inputmap.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/InputMap.xml.
  6. .. _class_InputMap:
  7. InputMap
  8. ========
  9. **Inherits:** :ref:`Object<class_Object>`
  10. A singleton that manages all :ref:`InputEventAction<class_InputEventAction>`\ s.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Manages all :ref:`InputEventAction<class_InputEventAction>` which can be created/modified from the project settings menu **Project > Project Settings > Input Map** or in code with :ref:`add_action()<class_InputMap_method_add_action>` and :ref:`action_add_event()<class_InputMap_method_action_add_event>`. See :ref:`Node._input()<class_Node_private_method__input>`.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - `Using InputEvent: InputMap <../tutorials/inputs/inputevent.html#inputmap>`__
  19. .. rst-class:: classref-reftable-group
  20. Methods
  21. -------
  22. .. table::
  23. :widths: auto
  24. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | |void| | :ref:`action_add_event<class_InputMap_method_action_add_event>`\ (\ action\: :ref:`StringName<class_StringName>`, event\: :ref:`InputEvent<class_InputEvent>`\ ) |
  26. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | |void| | :ref:`action_erase_event<class_InputMap_method_action_erase_event>`\ (\ action\: :ref:`StringName<class_StringName>`, event\: :ref:`InputEvent<class_InputEvent>`\ ) |
  28. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | |void| | :ref:`action_erase_events<class_InputMap_method_action_erase_events>`\ (\ action\: :ref:`StringName<class_StringName>`\ ) |
  30. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`action_get_deadzone<class_InputMap_method_action_get_deadzone>`\ (\ action\: :ref:`StringName<class_StringName>`\ ) |
  32. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Array<class_Array>`\[:ref:`InputEvent<class_InputEvent>`\] | :ref:`action_get_events<class_InputMap_method_action_get_events>`\ (\ action\: :ref:`StringName<class_StringName>`\ ) |
  34. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`action_has_event<class_InputMap_method_action_has_event>`\ (\ action\: :ref:`StringName<class_StringName>`, event\: :ref:`InputEvent<class_InputEvent>`\ ) |
  36. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | |void| | :ref:`action_set_deadzone<class_InputMap_method_action_set_deadzone>`\ (\ action\: :ref:`StringName<class_StringName>`, deadzone\: :ref:`float<class_float>`\ ) |
  38. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | |void| | :ref:`add_action<class_InputMap_method_add_action>`\ (\ action\: :ref:`StringName<class_StringName>`, deadzone\: :ref:`float<class_float>` = 0.2\ ) |
  40. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | |void| | :ref:`erase_action<class_InputMap_method_erase_action>`\ (\ action\: :ref:`StringName<class_StringName>`\ ) |
  42. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`event_is_action<class_InputMap_method_event_is_action>`\ (\ event\: :ref:`InputEvent<class_InputEvent>`, action\: :ref:`StringName<class_StringName>`, exact_match\: :ref:`bool<class_bool>` = false\ ) |const| |
  44. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`String<class_String>` | :ref:`get_action_description<class_InputMap_method_get_action_description>`\ (\ action\: :ref:`StringName<class_StringName>`\ ) |const| |
  46. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] | :ref:`get_actions<class_InputMap_method_get_actions>`\ (\ ) |
  48. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`has_action<class_InputMap_method_has_action>`\ (\ action\: :ref:`StringName<class_StringName>`\ ) |const| |
  50. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | |void| | :ref:`load_from_project_settings<class_InputMap_method_load_from_project_settings>`\ (\ ) |
  52. +------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. .. rst-class:: classref-section-separator
  54. ----
  55. .. rst-class:: classref-descriptions-group
  56. Method Descriptions
  57. -------------------
  58. .. _class_InputMap_method_action_add_event:
  59. .. rst-class:: classref-method
  60. |void| **action_add_event**\ (\ action\: :ref:`StringName<class_StringName>`, event\: :ref:`InputEvent<class_InputEvent>`\ ) :ref:`🔗<class_InputMap_method_action_add_event>`
  61. Adds an :ref:`InputEvent<class_InputEvent>` to an action. This :ref:`InputEvent<class_InputEvent>` will trigger the action.
  62. .. rst-class:: classref-item-separator
  63. ----
  64. .. _class_InputMap_method_action_erase_event:
  65. .. rst-class:: classref-method
  66. |void| **action_erase_event**\ (\ action\: :ref:`StringName<class_StringName>`, event\: :ref:`InputEvent<class_InputEvent>`\ ) :ref:`🔗<class_InputMap_method_action_erase_event>`
  67. Removes an :ref:`InputEvent<class_InputEvent>` from an action.
  68. .. rst-class:: classref-item-separator
  69. ----
  70. .. _class_InputMap_method_action_erase_events:
  71. .. rst-class:: classref-method
  72. |void| **action_erase_events**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_InputMap_method_action_erase_events>`
  73. Removes all events from an action.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _class_InputMap_method_action_get_deadzone:
  77. .. rst-class:: classref-method
  78. :ref:`float<class_float>` **action_get_deadzone**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_InputMap_method_action_get_deadzone>`
  79. Returns a deadzone value for the action.
  80. .. rst-class:: classref-item-separator
  81. ----
  82. .. _class_InputMap_method_action_get_events:
  83. .. rst-class:: classref-method
  84. :ref:`Array<class_Array>`\[:ref:`InputEvent<class_InputEvent>`\] **action_get_events**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_InputMap_method_action_get_events>`
  85. Returns an array of :ref:`InputEvent<class_InputEvent>`\ s associated with a given action.
  86. \ **Note:** When used in the editor (e.g. a tool script or :ref:`EditorPlugin<class_EditorPlugin>`), this method will return events for the editor action. If you want to access your project's input binds from the editor, read the ``input/*`` settings from :ref:`ProjectSettings<class_ProjectSettings>`.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_InputMap_method_action_has_event:
  90. .. rst-class:: classref-method
  91. :ref:`bool<class_bool>` **action_has_event**\ (\ action\: :ref:`StringName<class_StringName>`, event\: :ref:`InputEvent<class_InputEvent>`\ ) :ref:`🔗<class_InputMap_method_action_has_event>`
  92. Returns ``true`` if the action has the given :ref:`InputEvent<class_InputEvent>` associated with it.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_InputMap_method_action_set_deadzone:
  96. .. rst-class:: classref-method
  97. |void| **action_set_deadzone**\ (\ action\: :ref:`StringName<class_StringName>`, deadzone\: :ref:`float<class_float>`\ ) :ref:`🔗<class_InputMap_method_action_set_deadzone>`
  98. Sets a deadzone value for the action.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_InputMap_method_add_action:
  102. .. rst-class:: classref-method
  103. |void| **add_action**\ (\ action\: :ref:`StringName<class_StringName>`, deadzone\: :ref:`float<class_float>` = 0.2\ ) :ref:`🔗<class_InputMap_method_add_action>`
  104. Adds an empty action to the **InputMap** with a configurable ``deadzone``.
  105. An :ref:`InputEvent<class_InputEvent>` can then be added to this action with :ref:`action_add_event()<class_InputMap_method_action_add_event>`.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_InputMap_method_erase_action:
  109. .. rst-class:: classref-method
  110. |void| **erase_action**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_InputMap_method_erase_action>`
  111. Removes an action from the **InputMap**.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_InputMap_method_event_is_action:
  115. .. rst-class:: classref-method
  116. :ref:`bool<class_bool>` **event_is_action**\ (\ event\: :ref:`InputEvent<class_InputEvent>`, action\: :ref:`StringName<class_StringName>`, exact_match\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_InputMap_method_event_is_action>`
  117. Returns ``true`` if the given event is part of an existing action. This method ignores keyboard modifiers if the given :ref:`InputEvent<class_InputEvent>` is not pressed (for proper release detection). See :ref:`action_has_event()<class_InputMap_method_action_has_event>` if you don't want this behavior.
  118. If ``exact_match`` is ``false``, it ignores additional input modifiers for :ref:`InputEventKey<class_InputEventKey>` and :ref:`InputEventMouseButton<class_InputEventMouseButton>` events, and the direction for :ref:`InputEventJoypadMotion<class_InputEventJoypadMotion>` events.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_InputMap_method_get_action_description:
  122. .. rst-class:: classref-method
  123. :ref:`String<class_String>` **get_action_description**\ (\ action\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_InputMap_method_get_action_description>`
  124. Returns the human-readable description of the given action.
  125. .. rst-class:: classref-item-separator
  126. ----
  127. .. _class_InputMap_method_get_actions:
  128. .. rst-class:: classref-method
  129. :ref:`Array<class_Array>`\[:ref:`StringName<class_StringName>`\] **get_actions**\ (\ ) :ref:`🔗<class_InputMap_method_get_actions>`
  130. Returns an array of all actions in the **InputMap**.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_InputMap_method_has_action:
  134. .. rst-class:: classref-method
  135. :ref:`bool<class_bool>` **has_action**\ (\ action\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_InputMap_method_has_action>`
  136. Returns ``true`` if the **InputMap** has a registered action with the given name.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_InputMap_method_load_from_project_settings:
  140. .. rst-class:: classref-method
  141. |void| **load_from_project_settings**\ (\ ) :ref:`🔗<class_InputMap_method_load_from_project_settings>`
  142. Clears all :ref:`InputEventAction<class_InputEventAction>` in the **InputMap** and load it anew from :ref:`ProjectSettings<class_ProjectSettings>`.
  143. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  144. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  145. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  146. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  147. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  148. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  149. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  150. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  151. .. |void| replace:: :abbr:`void (No return value.)`