Class Input
The user input handling service.
Inheritance
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public static class Input : Object
Properties
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
[Unmanaged]
public static ActionConfig[] ActionMappings { get; set; }
Property Value
ActionConfig[]
|
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
[Unmanaged]
public static AxisConfig[] AxisMappings { get; set; }
Property Value
AxisConfig[]
|
Gamepads
Gets the gamepads.
Declaration
[Unmanaged]
public static Gamepad[] Gamepads { get; }
Property Value
Gamepad[]
|
GamepadsCount
Gets the gamepads count.
Declaration
[Unmanaged]
public static int GamepadsCount { get; }
Property Value
System.Int32
|
InputText
Gets the text entered during the current frame (Unicode).
Declaration
[Unmanaged]
public static string InputText { get; }
Property Value
System.String
|
Keyboard
Gets the keyboard (null if platform does not support keyboard or it is not connected).
Declaration
[Unmanaged]
public static Keyboard Keyboard { get; }
Property Value
Keyboard
|
Mouse
Gets the mouse (null if platform does not support mouse or it is not connected).
Declaration
[Unmanaged]
public static Mouse Mouse { get; }
Property Value
Mouse
|
MousePosition
Gets or sets the mouse position in game window coordinates.
Declaration
[Unmanaged]
public static Float2 MousePosition { get; set; }
Property Value
Float2
|
MousePositionDelta
Gets the mouse position change during the last frame.
Declaration
[Unmanaged]
public static Float2 MousePositionDelta { get; }
Property Value
Float2
|
MouseScreenPosition
Gets or sets the mouse position in screen-space coordinates.
Declaration
[Unmanaged]
public static Float2 MouseScreenPosition { get; set; }
Property Value
Float2
|
MouseScrollDelta
Gets the mouse wheel change during the last frame.
Declaration
[Unmanaged]
public static float MouseScrollDelta { get; }
Property Value
System.Single
|
Methods
GetAction(String)
Gets the value of the virtual action identified by name. Use ActionMappings to get the current config.
Declaration
[Unmanaged]
public static bool GetAction(string name)
Parameters
System.String
name
The action name. |
Returns
System.Boolean
True if action has been triggered in the current frame (e.g. button pressed), otherwise false. |
See Also
GetActionState(String)
Gets the value of the virtual action identified by name. Use ActionMappings to get the current config.
Declaration
[Unmanaged]
public static InputActionState GetActionState(string name)
Parameters
System.String
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
GetAxis(String)
Gets the value of the virtual axis identified by name. Use AxisMappings to get the current config.
Declaration
[Unmanaged]
public static float GetAxis(string name)
Parameters
System.String
name
The action name. |
Returns
System.Single
The current axis value (e.g for gamepads it's in the range -1..1). Value is smoothed to reduce artifacts. |
See Also
GetAxisRaw(String)
Gets the raw value of the virtual axis identified by name with no smoothing filtering applied. Use AxisMappings to get the current config.
Declaration
[Unmanaged]
public static float GetAxisRaw(string name)
Parameters
System.String
name
The action name. |
Returns
System.Single
The current axis value (e.g for gamepads it's in the range -1..1). No smoothing applied. |
See Also
GetGamepad(Int32)
Gets the gamepads count.
Declaration
[Unmanaged]
public static Gamepad GetGamepad(int index)
Parameters
System.Int32
index
The gamepad index. |
Returns
Gamepad
The gamepad device or null if index is invalid. |
GetGamepadAxis(InputGamepadIndex, GamepadAxis)
Gets the gamepad axis value.
Declaration
[Unmanaged]
public static float GetGamepadAxis(InputGamepadIndex gamepad, GamepadAxis axis)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadAxis
axis
Gamepad axis to check |
Returns
System.Single
Axis value. |
GetGamepadAxis(Int32, GamepadAxis)
Gets the gamepad axis value.
Declaration
[Unmanaged]
public static float GetGamepadAxis(int gamepadIndex, GamepadAxis axis)
Parameters
System.Int32
gamepadIndex
The gamepad index |
GamepadAxis
axis
Gamepad axis to check |
Returns
System.Single
Axis value. |
GetGamepadButton(InputGamepadIndex, GamepadButton)
Gets the gamepad button state (true if being pressed during the current frame).
Declaration
[Unmanaged]
public static bool GetGamepadButton(InputGamepadIndex gamepad, GamepadButton button)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadButton
button
Gamepad button to check |
Returns
System.Boolean
True if user holds down the button, otherwise false. |
GetGamepadButton(Int32, GamepadButton)
Gets the gamepad button state (true if being pressed during the current frame).
Declaration
[Unmanaged]
public static bool GetGamepadButton(int gamepadIndex, GamepadButton button)
Parameters
System.Int32
gamepadIndex
The gamepad index |
GamepadButton
button
Gamepad button to check |
Returns
System.Boolean
True if user holds down the button, otherwise false. |
GetGamepadButtonDown(InputGamepadIndex, GamepadButton)
Gets the gamepad button down state (true if was pressed during the current frame).
Declaration
[Unmanaged]
public static bool GetGamepadButtonDown(InputGamepadIndex gamepad, GamepadButton button)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadButton
button
Gamepad button to check |
Returns
System.Boolean
True if user starts pressing down the button, otherwise false. |
GetGamepadButtonDown(Int32, GamepadButton)
Gets the gamepad button down state (true if was pressed during the current frame).
Declaration
[Unmanaged]
public static bool GetGamepadButtonDown(int gamepadIndex, GamepadButton button)
Parameters
System.Int32
gamepadIndex
The gamepad index |
GamepadButton
button
Gamepad button to check |
Returns
System.Boolean
True if user starts pressing down the button, otherwise false. |
GetGamepadButtonUp(InputGamepadIndex, GamepadButton)
Gets the gamepad button up state (true if was released during the current frame).
Declaration
[Unmanaged]
public static bool GetGamepadButtonUp(InputGamepadIndex gamepad, GamepadButton button)
Parameters
InputGamepadIndex
gamepad
The gamepad |
GamepadButton
button
Gamepad button to check |
Returns
System.Boolean
True if user releases the button, otherwise false. |
GetGamepadButtonUp(Int32, GamepadButton)
Gets the gamepad button up state (true if was released during the current frame).
Declaration
[Unmanaged]
public static bool GetGamepadButtonUp(int gamepadIndex, GamepadButton button)
Parameters
System.Int32
gamepadIndex
The gamepad index |
GamepadButton
button
Gamepad button to check |
Returns
System.Boolean
True if user releases the button, otherwise false. |
GetKey(KeyboardKeys)
Gets the key state (true if key is being pressed during this frame).
Declaration
[Unmanaged]
public static bool GetKey(KeyboardKeys key)
Parameters
KeyboardKeys
key
Key ID to check |
Returns
System.Boolean
True while the user holds down the key identified by id |
GetKeyDown(KeyboardKeys)
Gets the key 'down' state (true if key was pressed in this frame).
Declaration
[Unmanaged]
public static bool GetKeyDown(KeyboardKeys key)
Parameters
KeyboardKeys
key
Key ID to check |
Returns
System.Boolean
True during the frame the user starts pressing down the key |
GetKeyUp(KeyboardKeys)
Gets the key 'up' state (true if key was released in this frame).
Declaration
[Unmanaged]
public static bool GetKeyUp(KeyboardKeys key)
Parameters
KeyboardKeys
key
Key ID to check |
Returns
System.Boolean
True during the frame the user releases the key |
GetMouseButton(MouseButton)
Gets the mouse button state.
Declaration
[Unmanaged]
public static bool GetMouseButton(MouseButton button)
Parameters
MouseButton
button
Mouse button to check |
Returns
System.Boolean
True while the user holds down the button |
GetMouseButtonDown(MouseButton)
Gets the mouse button down state.
Declaration
[Unmanaged]
public static bool GetMouseButtonDown(MouseButton button)
Parameters
MouseButton
button
Mouse button to check |
Returns
System.Boolean
True during the frame the user starts pressing down the button |
GetMouseButtonUp(MouseButton)
Gets the mouse button up state.
Declaration
[Unmanaged]
public static bool GetMouseButtonUp(MouseButton button)
Parameters
MouseButton
button
Mouse button to check |
Returns
System.Boolean
True during the frame the user releases the button |
Events
ActionTriggered
Event fired when virtual input action is triggered. Called before scripts update. See ActionMappings to edit configuration.
Declaration
[Unmanaged]
public static event Action<string, InputActionState> ActionTriggered
Event Type
System.Action<System.String, InputActionState>
|
See Also
AxisValueChanged
Event fired when virtual input axis is changed. Called before scripts update. See AxisMappings to edit configuration.
Declaration
[Unmanaged]
public static event Action<string> AxisValueChanged
Event Type
System.Action<System.String>
|
See Also
CharInput
Event fired on character input.
Declaration
[Unmanaged]
public static event Action<char> CharInput
Event Type
System.Action<System.Char>
|
GamepadsChanged
Action called when gamepads collection gets changed (during input update).
Declaration
[Unmanaged]
public static event Action GamepadsChanged
Event Type
System.Action
|
KeyDown
Event fired on key pressed.
Declaration
[Unmanaged]
public static event Action<KeyboardKeys> KeyDown
Event Type
System.Action<KeyboardKeys>
|
KeyUp
Event fired on key released.
Declaration
[Unmanaged]
public static event Action<KeyboardKeys> KeyUp
Event Type
System.Action<KeyboardKeys>
|
MouseDoubleClick
Event fired when mouse button double clicks.
Declaration
[Unmanaged]
public static event Action<Float2, MouseButton> MouseDoubleClick
Event Type
System.Action<Float2, MouseButton>
|
MouseDown
Event fired when mouse button goes down.
Declaration
[Unmanaged]
public static event Action<Float2, MouseButton> MouseDown
Event Type
System.Action<Float2, MouseButton>
|
MouseLeave
Event fired when mouse leaves window.
Declaration
[Unmanaged]
public static event Action MouseLeave
Event Type
System.Action
|
MouseMove
Event fired when mouse moves.
Declaration
[Unmanaged]
public static event Action<Float2> MouseMove
Event Type
System.Action<Float2>
|
MouseUp
Event fired when mouse button goes up.
Declaration
[Unmanaged]
public static event Action<Float2, MouseButton> MouseUp
Event Type
System.Action<Float2, MouseButton>
|
MouseWheel
Event fired when mouse wheel is scrolling (wheel delta is normalized).
Declaration
[Unmanaged]
public static event Action<Float2, float> MouseWheel
Event Type
System.Action<Float2, System.Single>
|
TouchDown
Event fired when touch action begins.
Declaration
[Unmanaged]
public static event Action<Float2, int> TouchDown
Event Type
System.Action<Float2, System.Int32>
|
TouchMove
Event fired when touch action moves.
Declaration
[Unmanaged]
public static event Action<Float2, int> TouchMove
Event Type
System.Action<Float2, System.Int32>
|
TouchUp
Event fired when touch action ends.
Declaration
[Unmanaged]
public static event Action<Float2, int> TouchUp
Event Type
System.Action<Float2, System.Int32>
|