class_inputmap.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. Singleton that manages :ref:`InputEventAction<class_InputEventAction>`.
  11. Description
  12. -----------
  13. 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_method__input>`.
  14. Tutorials
  15. ---------
  16. - `InputEvent: InputMap <../tutorials/inputs/inputevent.html#inputmap>`__
  17. Methods
  18. -------
  19. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`action_add_event<class_InputMap_method_action_add_event>` **(** :ref:`StringName<class_StringName>` action, :ref:`InputEvent<class_InputEvent>` event **)** |
  21. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`action_erase_event<class_InputMap_method_action_erase_event>` **(** :ref:`StringName<class_StringName>` action, :ref:`InputEvent<class_InputEvent>` event **)** |
  23. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`action_erase_events<class_InputMap_method_action_erase_events>` **(** :ref:`StringName<class_StringName>` action **)** |
  25. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`float<class_float>` | :ref:`action_get_deadzone<class_InputMap_method_action_get_deadzone>` **(** :ref:`StringName<class_StringName>` action **)** |
  27. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Array<class_Array>` | :ref:`action_get_events<class_InputMap_method_action_get_events>` **(** :ref:`StringName<class_StringName>` action **)** |
  29. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`action_has_event<class_InputMap_method_action_has_event>` **(** :ref:`StringName<class_StringName>` action, :ref:`InputEvent<class_InputEvent>` event **)** |
  31. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`action_set_deadzone<class_InputMap_method_action_set_deadzone>` **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` deadzone **)** |
  33. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`add_action<class_InputMap_method_add_action>` **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` deadzone=0.5 **)** |
  35. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`erase_action<class_InputMap_method_erase_action>` **(** :ref:`StringName<class_StringName>` action **)** |
  37. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`event_is_action<class_InputMap_method_event_is_action>` **(** :ref:`InputEvent<class_InputEvent>` event, :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const| |
  39. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Array<class_Array>` | :ref:`get_actions<class_InputMap_method_get_actions>` **(** **)** |
  41. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`has_action<class_InputMap_method_has_action>` **(** :ref:`StringName<class_StringName>` action **)** |const| |
  43. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`load_from_project_settings<class_InputMap_method_load_from_project_settings>` **(** **)** |
  45. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. Method Descriptions
  47. -------------------
  48. .. _class_InputMap_method_action_add_event:
  49. - void **action_add_event** **(** :ref:`StringName<class_StringName>` action, :ref:`InputEvent<class_InputEvent>` event **)**
  50. Adds an :ref:`InputEvent<class_InputEvent>` to an action. This :ref:`InputEvent<class_InputEvent>` will trigger the action.
  51. ----
  52. .. _class_InputMap_method_action_erase_event:
  53. - void **action_erase_event** **(** :ref:`StringName<class_StringName>` action, :ref:`InputEvent<class_InputEvent>` event **)**
  54. Removes an :ref:`InputEvent<class_InputEvent>` from an action.
  55. ----
  56. .. _class_InputMap_method_action_erase_events:
  57. - void **action_erase_events** **(** :ref:`StringName<class_StringName>` action **)**
  58. Removes all events from an action.
  59. ----
  60. .. _class_InputMap_method_action_get_deadzone:
  61. - :ref:`float<class_float>` **action_get_deadzone** **(** :ref:`StringName<class_StringName>` action **)**
  62. Returns a deadzone value for the action.
  63. ----
  64. .. _class_InputMap_method_action_get_events:
  65. - :ref:`Array<class_Array>` **action_get_events** **(** :ref:`StringName<class_StringName>` action **)**
  66. Returns an array of :ref:`InputEvent<class_InputEvent>`\ s associated with a given action.
  67. \ **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>`.
  68. ----
  69. .. _class_InputMap_method_action_has_event:
  70. - :ref:`bool<class_bool>` **action_has_event** **(** :ref:`StringName<class_StringName>` action, :ref:`InputEvent<class_InputEvent>` event **)**
  71. Returns ``true`` if the action has the given :ref:`InputEvent<class_InputEvent>` associated with it.
  72. ----
  73. .. _class_InputMap_method_action_set_deadzone:
  74. - void **action_set_deadzone** **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` deadzone **)**
  75. Sets a deadzone value for the action.
  76. ----
  77. .. _class_InputMap_method_add_action:
  78. - void **add_action** **(** :ref:`StringName<class_StringName>` action, :ref:`float<class_float>` deadzone=0.5 **)**
  79. Adds an empty action to the ``InputMap`` with a configurable ``deadzone``.
  80. An :ref:`InputEvent<class_InputEvent>` can then be added to this action with :ref:`action_add_event<class_InputMap_method_action_add_event>`.
  81. ----
  82. .. _class_InputMap_method_erase_action:
  83. - void **erase_action** **(** :ref:`StringName<class_StringName>` action **)**
  84. Removes an action from the ``InputMap``.
  85. ----
  86. .. _class_InputMap_method_event_is_action:
  87. - :ref:`bool<class_bool>` **event_is_action** **(** :ref:`InputEvent<class_InputEvent>` event, :ref:`StringName<class_StringName>` action, :ref:`bool<class_bool>` exact_match=false **)** |const|
  88. 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.
  89. 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.
  90. ----
  91. .. _class_InputMap_method_get_actions:
  92. - :ref:`Array<class_Array>` **get_actions** **(** **)**
  93. Returns an array of all actions in the ``InputMap``.
  94. ----
  95. .. _class_InputMap_method_has_action:
  96. - :ref:`bool<class_bool>` **has_action** **(** :ref:`StringName<class_StringName>` action **)** |const|
  97. Returns ``true`` if the ``InputMap`` has a registered action with the given name.
  98. ----
  99. .. _class_InputMap_method_load_from_project_settings:
  100. - void **load_from_project_settings** **(** **)**
  101. Clears all :ref:`InputEventAction<class_InputEventAction>` in the ``InputMap`` and load it anew from :ref:`ProjectSettings<class_ProjectSettings>`.
  102. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  103. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  104. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  105. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  106. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  107. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`