Class Input
The user input handling service.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Input/Input.h
Syntax
public class Input
Fields
ActionMappings
Maps a discrete button or key press events to a "friendly name" that will later be bound to event-driven behavior. The end effect is that pressing (and/or releasing) a key, mouse button, or keypad button.
Declaration
public static Array<ActionConfig> ActionMappings
Field Value
Array<ActionConfig>
|
ActionTriggered
Event fired when virtual input action is triggered. Called before scripts update. See ActionMappings to edit configuration.
Declaration
public static Delegate<StringView, InputActionState> ActionTriggered
Field Value
Delegate<StringView, InputActionState>
|
See Also
AxisMappings
Maps keyboard, controller, or mouse inputs to a "friendly name" that will later be bound to continuous game behavior, such as movement. The inputs mapped in AxisMappings are continuously polled, even if they are just reporting that their input value.
Declaration
public static Array<AxisConfig> AxisMappings
Field Value
Array<AxisConfig>
|
AxisValueChanged
Event fired when virtual input axis is changed. Called before scripts update. See AxisMappings to edit configuration.
Declaration
public static Delegate<StringView> AxisValueChanged
Field Value
Delegate<StringView>
|
See Also
CharInput
Event fired on character input.
Declaration
public static Delegate<Char> CharInput
Field Value
Delegate<Char>
|
KeyDown
Event fired on key pressed.
Declaration
public static Delegate<KeyboardKeys> KeyDown
Field Value
Delegate<KeyboardKeys>
|
KeyUp
Event fired on key released.
Declaration
public static Delegate<KeyboardKeys> KeyUp
Field Value
Delegate<KeyboardKeys>
|
MouseDoubleClick
Event fired when mouse button double clicks.
Declaration
public static Delegate<Float2, MouseButton> MouseDoubleClick
Field Value
Delegate<Float2, MouseButton>
|
MouseDown
Event fired when mouse button goes down.
Declaration
public static Delegate<Float2, MouseButton> MouseDown
Field Value
Delegate<Float2, MouseButton>
|
MouseLeave
Event fired when mouse leaves window.
Declaration
public static Action MouseLeave
Field Value
Action
|
MouseMove
Event fired when mouse moves.
Declaration
public static Delegate<Float2> MouseMove
Field Value
Delegate<Float2>
|
MouseUp
Event fired when mouse button goes up.
Declaration
public static Delegate<Float2, MouseButton> MouseUp
Field Value
Delegate<Float2, MouseButton>
|
MouseWheel
Event fired when mouse wheel is scrolling (wheel delta is normalized).
Declaration
public static Delegate<Float2, float> MouseWheel
Field Value
Delegate<Float2, float>
|
TouchDown
Event fired when touch action begins.
Declaration
public static Delegate<Float2, int32> TouchDown
Field Value
Delegate<Float2, int32>
|
TouchMove
Event fired when touch action moves.
Declaration
public static Delegate<Float2, int32> TouchMove
Field Value
Delegate<Float2, int32>
|
TouchUp
Event fired when touch action ends.
Declaration
public static Delegate<Float2, int32> TouchUp
Field Value
Delegate<Float2, int32>
|
Methods
GetAction(const StringView& name)
Gets the value of the virtual action identified by name. Use ActionMappings to get the current config.
Declaration
public static bool GetAction(const StringView& name)
Parameters
StringView
name
The action name. |
Returns
bool
True if action has been triggered in the current frame (e.g. button pressed), otherwise false. |
See Also
GetActionConfigByName(const StringView& name)
Gets the first action configuration by name.
Declaration
public static ActionConfig GetActionConfigByName(const StringView& name)
Parameters
StringView
name
The name of the action config. |
Returns
ActionConfig
The first Action configuration with the name. Empty configuration if not found. |
GetActionState(const StringView& name)
Gets the value of the virtual action identified by name. Use ActionMappings to get the current config.
Declaration
public static InputActionState GetActionState(const StringView& name)
Parameters
StringView
name
The action name. |
Returns
InputActionState
A InputActionPhase determining the current phase of the Action (e.g If it was just pressed, is being held or just released). |
See Also
GetAllActionConfigsByName(const StringView& name)
Gets all the action configurations by name.
Declaration
public static Array<ActionConfig> GetAllActionConfigsByName(const StringView& name)
Parameters
StringView
name
The name of the action config. |
Returns
Array<ActionConfig>
The Action configurations with the name. |
GetAllAxisConfigsByName(const StringView& name)
Gets all the axis configurations by name.
Declaration
public static Array<AxisConfig> GetAllAxisConfigsByName(const StringView& name)
Parameters
StringView
name
The name of the axis config. |
Returns
Array<AxisConfig>
The axis configurations with the name. |
GetAxis(const StringView& name)
Gets the value of the virtual axis identified by name. Use AxisMappings to get the current config.
Declaration
public static float GetAxis(const StringView& name)
Parameters
StringView
name
The action name. |
Returns
float
The current axis value (e.g for gamepads it's in the range -1..1). Value is smoothed to reduce artifacts. |
See Also
GetAxisConfigByName(const StringView& name)
Gets the first axis configurations by name.
Declaration
public static AxisConfig GetAxisConfigByName(const StringView& name)
Parameters
StringView
name
The name of the axis config. |
Returns
AxisConfig
The first Axis configuration with the name. Empty configuration if not found. |
GetAxisRaw(const StringView& name)
Gets the raw value of the virtual axis identified by name with no smoothing filtering applied. Use AxisMappings to get the current config.
Declaration
public static float GetAxisRaw(const StringView& name)
Parameters
StringView
name
The action name. |
Returns
float
The current axis value (e.g for gamepads it's in the range -1..1). No smoothing applied. |
See Also
GetGamepadAxis(InputGamepadIndex gamepad, GamepadAxis axis)
Gets the gamepad axis value.
Declaration
public static float GetGamepadAxis(InputGamepadIndex gamepad, GamepadAxis axis)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadAxis
axis
Gamepad axis to check |
Returns
float
Axis value. |
GetGamepadAxis(int32 gamepadIndex, GamepadAxis axis)
Gets the gamepad axis value.
Declaration
public static float GetGamepadAxis(int32 gamepadIndex, GamepadAxis axis)
Parameters
int32
gamepadIndex
The gamepad index |
GamepadAxis
axis
Gamepad axis to check |
Returns
float
Axis value. |
GetGamepadButton(InputGamepadIndex gamepad, GamepadButton button)
Gets the gamepad button state (true if being pressed during the current frame).
Declaration
public static bool GetGamepadButton(InputGamepadIndex gamepad, GamepadButton button)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadButton
button
Gamepad button to check |
Returns
bool
True if user holds down the button, otherwise false. |
GetGamepadButton(int32 gamepadIndex, GamepadButton button)
Gets the gamepad button state (true if being pressed during the current frame).
Declaration
public static bool GetGamepadButton(int32 gamepadIndex, GamepadButton button)
Parameters
int32
gamepadIndex
The gamepad index |
GamepadButton
button
Gamepad button to check |
Returns
bool
True if user holds down the button, otherwise false. |
GetGamepadButtonDown(InputGamepadIndex gamepad, GamepadButton button)
Gets the gamepad button down state (true if was pressed during the current frame).
Declaration
public static bool GetGamepadButtonDown(InputGamepadIndex gamepad, GamepadButton button)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadButton
button
Gamepad button to check |
Returns
bool
True if user starts pressing down the button, otherwise false. |
GetGamepadButtonDown(int32 gamepadIndex, GamepadButton button)
Gets the gamepad button down state (true if was pressed during the current frame).
Declaration
public static bool GetGamepadButtonDown(int32 gamepadIndex, GamepadButton button)
Parameters
int32
gamepadIndex
The gamepad index |
GamepadButton
button
Gamepad button to check |
Returns
bool
True if user starts pressing down the button, otherwise false. |
GetGamepadButtonUp(InputGamepadIndex gamepad, GamepadButton button)
Gets the gamepad button up state (true if was released during the current frame).
Declaration
public static bool GetGamepadButtonUp(InputGamepadIndex gamepad, GamepadButton button)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadButton
button
Gamepad button to check |
Returns
bool
True if user releases the button, otherwise false. |
GetGamepadButtonUp(int32 gamepadIndex, GamepadButton button)
Gets the gamepad button up state (true if was released during the current frame).
Declaration
public static bool GetGamepadButtonUp(int32 gamepadIndex, GamepadButton button)
Parameters
int32
gamepadIndex
The gamepad index |
GamepadButton
button
Gamepad button to check |
Returns
bool
True if user releases the button, otherwise false. |
GetInputText()
Gets the text entered during the current frame (Unicode).
Declaration
public static StringView GetInputText()
Returns
StringView
The input text (Unicode). |
GetKey(KeyboardKeys key)
Gets the key state (true if key is being pressed during this frame).
Declaration
public static bool GetKey(KeyboardKeys key)
Parameters
KeyboardKeys
key
Key ID to check |
Returns
bool
True while the user holds down the key identified by id |
GetKeyDown(KeyboardKeys key)
Gets the key 'down' state (true if key was pressed in this frame).
Declaration
public static bool GetKeyDown(KeyboardKeys key)
Parameters
KeyboardKeys
key
Key ID to check |
Returns
bool
True during the frame the user starts pressing down the key |
GetKeyUp(KeyboardKeys key)
Gets the key 'up' state (true if key was released in this frame).
Declaration
public static bool GetKeyUp(KeyboardKeys key)
Parameters
KeyboardKeys
key
Key ID to check |
Returns
bool
True during the frame the user releases the key |
GetMouseButton(MouseButton button)
Gets the mouse button state.
Declaration
public static bool GetMouseButton(MouseButton button)
Parameters
MouseButton
button
Mouse button to check |
Returns
bool
True while the user holds down the button |
GetMouseButtonDown(MouseButton button)
Gets the mouse button down state.
Declaration
public static bool GetMouseButtonDown(MouseButton button)
Parameters
MouseButton
button
Mouse button to check |
Returns
bool
True during the frame the user starts pressing down the button |
GetMouseButtonUp(MouseButton button)
Gets the mouse button up state.
Declaration
public static bool GetMouseButtonUp(MouseButton button)
Parameters
MouseButton
button
Mouse button to check |
Returns
bool
True during the frame the user releases the button |
GetMousePosition()
Gets the mouse position in game window coordinates.
Declaration
public static Float2 GetMousePosition()
Returns
Float2
Mouse cursor coordinates |
GetMousePositionDelta()
Gets the mouse position change during the last frame.
Declaration
public static Float2 GetMousePositionDelta()
Returns
Float2
Mouse cursor position delta |
GetMouseScreenPosition()
Gets the mouse position in screen-space coordinates.
Declaration
public static Float2 GetMouseScreenPosition()
Returns
Float2
Mouse cursor coordinates |
GetMouseScrollDelta()
Gets the mouse wheel change during the last frame.
Declaration
public static float GetMouseScrollDelta()
Returns
float
Mouse wheel value delta |
SetActionConfigByName(const StringView& name, ActionConfig& config, bool all=false)
Sets the action configuration by name.
Declaration
public static void SetActionConfigByName(const StringView& name, ActionConfig& config, bool all=false)
Parameters
StringView
name
The name of the action config. |
ActionConfig
config
The action configuration to set. Leave the config name empty to use set name. |
bool
all
Whether to set only the first config found or all of them. |
SetActionConfigByName(const StringView& name, const GamepadButton gamepadButton, InputGamepadIndex gamepadIndex, bool all=false)
Sets the action configuration gamepad button by name and index.
Declaration
public static void SetActionConfigByName(const StringView& name, const GamepadButton gamepadButton, InputGamepadIndex gamepadIndex, bool all=false)
Parameters
StringView
name
The name of the action config. |
GamepadButton
gamepadButton
The gamepad button to set. |
InputGamepadIndex
gamepadIndex
The gamepad index used to find the correct config. |
bool
all
Whether to set only the first config found or all of them. |
SetActionConfigByName(const StringView& name, const KeyboardKeys key, bool all=false)
Sets the action configuration keyboard key by name.
Declaration
public static void SetActionConfigByName(const StringView& name, const KeyboardKeys key, bool all=false)
Parameters
StringView
name
The name of the action config. |
KeyboardKeys
key
The key to set. |
bool
all
Whether to set only the first config found or all of them. |
SetActionConfigByName(const StringView& name, const MouseButton mouseButton, bool all=false)
Sets the action configuration mouse button by name.
Declaration
public static void SetActionConfigByName(const StringView& name, const MouseButton mouseButton, bool all=false)
Parameters
StringView
name
The name of the action config. |
MouseButton
mouseButton
The mouse button to set. |
bool
all
Whether to set only the first config found or all of them. |
SetAxisConfigByName(const StringView& name, AxisConfig& config, bool all=false)
Sets the axis configuration keyboard key by name and type.
Declaration
public static void SetAxisConfigByName(const StringView& name, AxisConfig& config, bool all=false)
Parameters
StringView
name
The name of the action config. |
AxisConfig
config
The configuration to set. Leave the config name empty to use set name. |
bool
all
Whether to set only the first config found or all of them. |
SetAxisConfigByName(const StringView& name, InputAxisType inputType, const float gravity, const float deadZone, const float sensitivity, const float scale, const bool snap, bool all=false)
Sets the axis configuration accessories by name, and type.
Declaration
public static void SetAxisConfigByName(const StringView& name, InputAxisType inputType, const float gravity, const float deadZone, const float sensitivity, const float scale, const bool snap, bool all=false)
Parameters
StringView
name
The name of the action config. |
InputAxisType
inputType
The type to sort by. |
float
gravity
The gravity to set. |
float
deadZone
The dead zone to set. |
float
sensitivity
The sensitivity to set. |
float
scale
The scale to set. |
bool
snap
The snap to set. |
bool
all
Whether to set only the first config found or all of them. |
SetAxisConfigByName(const StringView& name, InputAxisType inputType, const GamepadButton positiveButton, const GamepadButton negativeButton, InputGamepadIndex gamepadIndex, bool all=false)
Sets the axis configuration gamepad buttons by name, type, and index.
Declaration
public static void SetAxisConfigByName(const StringView& name, InputAxisType inputType, const GamepadButton positiveButton, const GamepadButton negativeButton, InputGamepadIndex gamepadIndex, bool all=false)
Parameters
StringView
name
The name of the action config. |
InputAxisType
inputType
The type to sort by. |
GamepadButton
positiveButton
The positive gamepad button. |
GamepadButton
negativeButton
The negative gamepad button. |
InputGamepadIndex
gamepadIndex
The gamepad index to sort by. |
bool
all
Whether to set only the first config found or all of them. |
SetAxisConfigByName(const StringView& name, InputAxisType inputType, const KeyboardKeys positiveButton, const KeyboardKeys negativeButton, bool all=false)
Sets the axis configuration keyboard key buttons by name and type.
Declaration
public static void SetAxisConfigByName(const StringView& name, InputAxisType inputType, const KeyboardKeys positiveButton, const KeyboardKeys negativeButton, bool all=false)
Parameters
StringView
name
The name of the action config. |
InputAxisType
inputType
The type to sort by. |
KeyboardKeys
positiveButton
The positive key button. |
KeyboardKeys
negativeButton
The negative key button. |
bool
all
Whether to set only the first config found or all of them. |
SetInputMappingFromSettings(const JsonAssetReference<class InputSettings>& settings)
Sets and overwrites the Action and Axis mappings with the values from a new InputSettings.
Declaration
public static void SetInputMappingFromSettings(const JsonAssetReference<class InputSettings>& settings)
Parameters
JsonAssetReference<class InputSettings>
settings
The input settings. |
SetInputMappingToDefaultSettings()
Sets and overwrites the Action and Axis mappings with the values from the InputSettings in GameSettings.
Declaration
public static void SetInputMappingToDefaultSettings()
SetMousePosition(const Float2& position)
Sets the mouse position in game window coordinates.
Declaration
public static void SetMousePosition(const Float2& position)
Parameters
Float2
position
Mouse position to set on |
SetMouseScreenPosition(const Float2& position)
Sets the mouse position in screen-space coordinates.
Declaration
public static void SetMouseScreenPosition(const Float2& position)
Parameters
Float2
position
Mouse position to set on |