Class InputMap
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Manages all InputEventAction which can be created/modified from the project settings menu Project > Project Settings > Input Map or in code with AddAction(StringName, float) and ActionAddEvent(StringName, InputEvent). See _Input(InputEvent).
public static class InputMap
- Inheritance
-
InputMap
- Inherited Members
Properties
Singleton
public static InputMapInstance Singleton { get; }
Property Value
Methods
ActionAddEvent(StringName, InputEvent)
Adds an InputEvent to an action. This InputEvent will trigger the action.
public static void ActionAddEvent(StringName action, InputEvent @event)
Parameters
action
StringNameevent
InputEvent
ActionEraseEvent(StringName, InputEvent)
Removes an InputEvent from an action.
public static void ActionEraseEvent(StringName action, InputEvent @event)
Parameters
action
StringNameevent
InputEvent
ActionEraseEvents(StringName)
Removes all events from an action.
public static void ActionEraseEvents(StringName action)
Parameters
action
StringName
ActionGetDeadzone(StringName)
Returns a deadzone value for the action.
public static float ActionGetDeadzone(StringName action)
Parameters
action
StringName
Returns
ActionGetEvents(StringName)
Returns an array of InputEvents associated with a given action.
Note: When used in the editor (e.g. a tool script or 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 ProjectSettings.
public static Array<InputEvent> ActionGetEvents(StringName action)
Parameters
action
StringName
Returns
ActionHasEvent(StringName, InputEvent)
Returns true
if the action has the given InputEvent associated with it.
public static bool ActionHasEvent(StringName action, InputEvent @event)
Parameters
action
StringNameevent
InputEvent
Returns
ActionSetDeadzone(StringName, float)
Sets a deadzone value for the action.
public static void ActionSetDeadzone(StringName action, float deadzone)
Parameters
action
StringNamedeadzone
float
AddAction(StringName, float)
Adds an empty action to the InputMap with a configurable deadzone
.
An InputEvent can then be added to this action with ActionAddEvent(StringName, InputEvent).
public static void AddAction(StringName action, float deadzone = 0.5)
Parameters
action
StringNamedeadzone
float
EraseAction(StringName)
Removes an action from the InputMap.
public static void EraseAction(StringName action)
Parameters
action
StringName
EventIsAction(InputEvent, StringName, bool)
Returns true
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 ActionHasEvent(StringName, InputEvent) if you don't want this behavior.
If exactMatch
is false
, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
public static bool EventIsAction(InputEvent @event, StringName action, bool exactMatch = false)
Parameters
event
InputEventaction
StringNameexactMatch
bool
Returns
GetActions()
Returns an array of all actions in the InputMap.
public static Array<StringName> GetActions()
Returns
HasAction(StringName)
Returns true
if the InputMap has a registered action with the given name.
public static bool HasAction(StringName action)
Parameters
action
StringName
Returns
LoadFromProjectSettings()
Clears all InputEventAction in the InputMap and load it anew from ProjectSettings.
public static void LoadFromProjectSettings()