godot/doc/classes/InputMap.xml
EricEzaM 0e5c6e0d55 Allow checking for exact matches with Action events.
Added additional param to action related methods to test for exactness.
If "p_exact_match" is true, then the action will only be "matched" if the provided input event *exactly* matches with the action event.

Before:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* Is Action Pressed = True

Now:
You can still do the above, however you can optionally check that the input is exactly what the action event is:
* Action Event = KEY_S
* Input Event = KEY_CONTROL + KEY_S
* p_exact_match = True
* Is Action Pressed = False
* If the Input Event was only KEY_S, then the result would be true.

Usage:

```gdscript
Input.is_action_pressed(action_name: String, exact_match: bool)
Input.is_action_pressed("my_action", true)

InputMap.event_is_action(p_event, "my_action", true)

func _input(event: InputEvent):
  event.is_action_pressed("my_action", false, true) # false = "allow_echo", true = "exact_match"
  event.is_action("my_action", true)
```

Co-authored-by: Eric M <itsjusteza@gmail.com>
2021-07-30 15:35:39 +02:00

145 lines
4.7 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<class name="InputMap" inherits="Object" version="3.4">
<brief_description>
Singleton that manages [InputEventAction].
</brief_description>
<description>
Manages all [InputEventAction] which can be created/modified from the project settings menu [b]Project &gt; Project Settings &gt; Input Map[/b] or in code with [method add_action] and [method action_add_event]. See [method Node._input].
</description>
<tutorials>
<link>https://docs.godotengine.org/en/3.3/tutorials/inputs/inputevent.html#inputmap</link>
</tutorials>
<methods>
<method name="action_add_event">
<return type="void">
</return>
<argument index="0" name="action" type="String">
</argument>
<argument index="1" name="event" type="InputEvent">
</argument>
<description>
Adds an [InputEvent] to an action. This [InputEvent] will trigger the action.
</description>
</method>
<method name="action_erase_event">
<return type="void">
</return>
<argument index="0" name="action" type="String">
</argument>
<argument index="1" name="event" type="InputEvent">
</argument>
<description>
Removes an [InputEvent] from an action.
</description>
</method>
<method name="action_erase_events">
<return type="void">
</return>
<argument index="0" name="action" type="String">
</argument>
<description>
Removes all events from an action.
</description>
</method>
<method name="action_get_deadzone">
<return type="float">
</return>
<argument index="0" name="action" type="String">
</argument>
<description>
Returns a deadzone value for the action.
</description>
</method>
<method name="action_has_event">
<return type="bool">
</return>
<argument index="0" name="action" type="String">
</argument>
<argument index="1" name="event" type="InputEvent">
</argument>
<description>
Returns [code]true[/code] if the action has the given [InputEvent] associated with it.
</description>
</method>
<method name="action_set_deadzone">
<return type="void">
</return>
<argument index="0" name="action" type="String">
</argument>
<argument index="1" name="deadzone" type="float">
</argument>
<description>
Sets a deadzone value for the action.
</description>
</method>
<method name="add_action">
<return type="void">
</return>
<argument index="0" name="action" type="String">
</argument>
<argument index="1" name="deadzone" type="float" default="0.5">
</argument>
<description>
Adds an empty action to the [InputMap] with a configurable [code]deadzone[/code].
An [InputEvent] can then be added to this action with [method action_add_event].
</description>
</method>
<method name="erase_action">
<return type="void">
</return>
<argument index="0" name="action" type="String">
</argument>
<description>
Removes an action from the [InputMap].
</description>
</method>
<method name="event_is_action" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="event" type="InputEvent">
</argument>
<argument index="1" name="action" type="String">
</argument>
<argument index="2" name="exact_match" type="bool" default="false">
</argument>
<description>
Returns [code]true[/code] if the given event is part of an existing action. This method ignores keyboard modifiers if the given [InputEvent] is not pressed (for proper release detection). See [method action_has_event] if you don't want this behavior.
If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events.
</description>
</method>
<method name="get_action_list">
<return type="Array">
</return>
<argument index="0" name="action" type="String">
</argument>
<description>
Returns an array of [InputEvent]s associated with a given action.
</description>
</method>
<method name="get_actions">
<return type="Array">
</return>
<description>
Returns an array of all actions in the [InputMap].
</description>
</method>
<method name="has_action" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="action" type="String">
</argument>
<description>
Returns [code]true[/code] if the [InputMap] has a registered action with the given name.
</description>
</method>
<method name="load_from_globals">
<return type="void">
</return>
<description>
Clears all [InputEventAction] in the [InputMap] and load it anew from [ProjectSettings].
</description>
</method>
</methods>
<constants>
</constants>
</class>