InputEvent

Category: Built-In Types

Brief Description

Built-in input event data.

Member Functions

bool is_action ( String action )
bool is_action_pressed ( String action )
bool is_action_released ( String action )
bool is_echo ( )
bool is_pressed ( )
void set_as_action ( String action, bool pressed )

Member Variables

  • int ID - Event identifier, positive integer increased at each new event.
  • int device - Device identifier.
  • int type - Type of event (one of the [InputEvent] constants).

Numeric Constants

  • NONE = 0 — Empty input event.
  • KEY = 1 — Key event.
  • MOUSE_MOTION = 2 — Mouse motion event.
  • MOUSE_BUTTON = 3 — Mouse button event.
  • JOYSTICK_MOTION = 4 — Joystick motion event.
  • JOYSTICK_BUTTON = 5 — Joystick button event.
  • SCREEN_TOUCH = 6 — Screen touch event.
  • SCREEN_DRAG = 7 — Screen drag event.
  • ACTION = 8 — Pre-defined action event (see InputMap).

Description

Built-in input event data. InputEvent is a built-in engine datatype, given that it’s passed around and used so much. Depending on its type, the members contained can be different, so read the documentation well! Input events can also represent actions (editable from the project settings).

Member Function Description

Return if this input event matches a pre-defined action, no matter the type.

Return whether the given action is being pressed (and is not an echo event for KEY events). Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.

Return whether the given action is released (i.e. not pressed). Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.

Return if this input event is an echo event (only for events of type KEY, it will return false for other types).

  • bool is_pressed ( )

Return if this input event is pressed. Not relevant for the event types MOUSE_MOTION, SCREEN_DRAG and NONE.

  • void set_as_action ( String action, bool pressed )

Change the input event to an action event of the given name, regardless of its initial type, with the pressed status passed as argument.