2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2021-11-05 14:02:42 +00:00
<class name= "InputMap" inherits= "Object" version= "3.5" >
2017-09-12 20:42:36 +00:00
<brief_description >
2017-10-15 22:07:13 +00:00
Singleton that manages [InputEventAction].
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2019-06-21 23:04:47 +00:00
Manages all [InputEventAction] which can be created/modified from the project settings menu [b]Project > Project Settings > Input Map[/b] or in code with [method add_action] and [method action_add_event]. See [method Node._input].
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2021-11-15 16:11:20 +00:00
<link > $DOCS_URL/tutorials/inputs/inputevent.html#inputmap</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
<method name= "action_add_event" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "action" type= "String" />
<argument index= "1" name= "event" type= "InputEvent" />
2017-09-12 20:42:36 +00:00
<description >
2017-10-15 22:07:13 +00:00
Adds an [InputEvent] to an action. This [InputEvent] will trigger the action.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "action_erase_event" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "action" type= "String" />
<argument index= "1" name= "event" type= "InputEvent" />
2017-09-12 20:42:36 +00:00
<description >
2017-10-15 22:07:13 +00:00
Removes an [InputEvent] from an action.
2017-09-12 20:42:36 +00:00
</description>
</method>
2018-05-12 07:38:00 +00:00
<method name= "action_erase_events" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "action" type= "String" />
2018-05-12 07:38:00 +00:00
<description >
2018-08-19 04:29:12 +00:00
Removes all events from an action.
2018-05-12 07:38:00 +00:00
</description>
</method>
2021-07-02 04:02:28 +00:00
<method name= "action_get_deadzone" >
2021-07-30 13:28:05 +00:00
<return type= "float" />
<argument index= "0" name= "action" type= "String" />
2021-07-02 04:02:28 +00:00
<description >
Returns a deadzone value for the action.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "action_has_event" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "action" type= "String" />
<argument index= "1" name= "event" type= "InputEvent" />
2017-09-12 20:42:36 +00:00
<description >
2018-08-19 04:29:12 +00:00
Returns [code]true[/code] if the action has the given [InputEvent] associated with it.
2017-09-12 20:42:36 +00:00
</description>
</method>
2018-05-12 07:38:00 +00:00
<method name= "action_set_deadzone" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "action" type= "String" />
<argument index= "1" name= "deadzone" type= "float" />
2018-05-12 07:38:00 +00:00
<description >
2020-01-10 18:46:41 +00:00
Sets a deadzone value for the action.
2018-05-12 07:38:00 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "add_action" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "action" type= "String" />
<argument index= "1" name= "deadzone" type= "float" default= "0.5" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
Adds an empty action to the [InputMap] with a configurable [code]deadzone[/code].
2018-05-12 07:38:00 +00:00
An [InputEvent] can then be added to this action with [method action_add_event].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "erase_action" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "action" type= "String" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
Removes an action from the [InputMap].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "event_is_action" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "event" type= "InputEvent" />
<argument index= "1" name= "action" type= "String" />
<argument index= "2" name= "exact_match" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2019-01-07 09:02:04 +00:00
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.
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>
2020-12-13 14:22:42 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_action_list" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
<argument index= "0" name= "action" type= "String" />
2017-09-12 20:42:36 +00:00
<description >
2017-10-15 22:07:13 +00:00
Returns an array of [InputEvent]s associated with a given action.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_actions" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
Returns an array of all actions in the [InputMap].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "has_action" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "action" type= "String" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
Returns [code]true[/code] if the [InputMap] has a registered action with the given name.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "load_from_globals" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
Clears all [InputEventAction] in the [InputMap] and load it anew from [ProjectSettings].
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<constants >
</constants>
</class>