Class InputEvent
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Abstract base class of all types of input events. See _Input(InputEvent).
public class InputEvent : Resource, IDisposable
- Inheritance
-
InputEvent
- Implements
- Derived
- Inherited Members
Properties
Device
The event's device ID.
Note: This device ID will always be -1
for emulated mouse input from a touchscreen. This can be used to distinguish emulated mouse input from physical mouse input.
public int Device { get; set; }
Property Value
Methods
Accumulate(InputEvent)
Returns true
if the given input event and this input event can be added together (only for events of type InputEventMouseMotion).
The given input event's position, global position and speed will be copied. The resulting relative
is a sum of both events. Both events' modifiers have to be identical.
public bool Accumulate(InputEvent withEvent)
Parameters
withEvent
InputEvent
Returns
AsText()
Returns a string representation of the event.
public string AsText()
Returns
GetActionStrength(StringName, bool)
Returns a value between 0.0 and 1.0 depending on the given actions' state. Useful for getting the value of events of type InputEventJoypadMotion.
If exactMatch
is false
, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
public float GetActionStrength(StringName action, bool exactMatch = false)
Parameters
action
StringNameexactMatch
bool
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsAction(StringName, bool)
Returns true
if this input event matches a pre-defined action of any type.
If exactMatch
is false
, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
public bool IsAction(StringName action, bool exactMatch = false)
Parameters
action
StringNameexactMatch
bool
Returns
IsActionPressed(StringName, bool, bool)
Returns true
if the given action is being pressed (and is not an echo event for InputEventKey events, unless allowEcho
is true
). Not relevant for events of type InputEventMouseMotion or InputEventScreenDrag.
If exactMatch
is false
, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
Note: Due to keyboard ghosting, IsActionPressed(StringName, bool, bool) may return false
even if one of the action's keys is pressed. See Input examples in the documentation for more information.
public bool IsActionPressed(StringName action, bool allowEcho = false, bool exactMatch = false)
Parameters
action
StringNameallowEcho
boolexactMatch
bool
Returns
IsActionReleased(StringName, bool)
Returns true
if the given action is released (i.e. not pressed). Not relevant for events of type InputEventMouseMotion or InputEventScreenDrag.
If exactMatch
is false
, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
public bool IsActionReleased(StringName action, bool exactMatch = false)
Parameters
action
StringNameexactMatch
bool
Returns
IsActionType()
Returns true
if this input event's type is one that can be assigned to an input action.
public bool IsActionType()
Returns
IsCanceled()
Returns true
if this input event has been canceled.
public bool IsCanceled()
Returns
IsEcho()
Returns true
if this input event is an echo event (only for events of type InputEventKey). Any other event type returns false
.
public bool IsEcho()
Returns
IsMatch(InputEvent, bool)
Returns true
if the specified event
matches this event. Only valid for action events i.e key (InputEventKey), button (InputEventMouseButton or InputEventJoypadButton), axis InputEventJoypadMotion or action (InputEventAction) events.
If exactMatch
is false
, it ignores additional input modifiers for InputEventKey and InputEventMouseButton events, and the direction for InputEventJoypadMotion events.
public bool IsMatch(InputEvent @event, bool exactMatch = true)
Parameters
event
InputEventexactMatch
bool
Returns
IsPressed()
Returns true
if this input event is pressed. Not relevant for events of type InputEventMouseMotion or InputEventScreenDrag.
Note: Due to keyboard ghosting, IsPressed() may return false
even if one of the action's keys is pressed. See Input examples in the documentation for more information.
public bool IsPressed()
Returns
IsReleased()
Returns true
if this input event is released. Not relevant for events of type InputEventMouseMotion or InputEventScreenDrag.
public bool IsReleased()
Returns
XformedBy(Transform2D, Vector2?)
Returns a copy of the given input event which has been offset by localOfs
and transformed by xform
. Relevant for events of type InputEventMouseButton, InputEventMouseMotion, InputEventScreenTouch, InputEventScreenDrag, InputEventMagnifyGesture and InputEventPanGesture.
public InputEvent XformedBy(Transform2D xform, Vector2? localOfs = null)
Parameters
xform
Transform2DlocalOfs
Vector2?If the parameter is null, then the default value is
new Vector2(0, 0)
.