Search Results for

    Show / Hide Table of Contents

    Class Input

    The user input handling service.

    Inheritance
    System.Object
    Input
    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
    ActionMappings

    GetActionConfigByName(String)

    Gets the first action configuration by name.

    Declaration
    [Unmanaged]
    public static ActionConfig GetActionConfigByName(string name)
    Parameters
    System.String name

    The name of the action config.

    Returns
    ActionConfig

    The first Action configuration with the name. Empty configuration if not found.

    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
    ActionMappings

    GetAllActionConfigsByName(String)

    Gets all the action configurations by name.

    Declaration
    [Unmanaged]
    public static ActionConfig[] GetAllActionConfigsByName(string name)
    Parameters
    System.String name

    The name of the action config.

    Returns
    ActionConfig[]

    The Action configurations with the name.

    GetAllAxisConfigsByName(String)

    Gets all the axis configurations by name.

    Declaration
    [Unmanaged]
    public static AxisConfig[] GetAllAxisConfigsByName(string name)
    Parameters
    System.String name

    The name of the axis config.

    Returns
    AxisConfig[]

    The axis configurations with the name.

    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
    AxisMappings

    GetAxisConfigByName(String)

    Gets the first axis configurations by name.

    Declaration
    [Unmanaged]
    public static AxisConfig GetAxisConfigByName(string name)
    Parameters
    System.String name

    The name of the axis config.

    Returns
    AxisConfig

    The first Axis configuration with the name. Empty configuration if not found.

    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
    AxisMappings

    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

    SetActionConfigByName(String, ActionConfig, Boolean)

    Sets the action configuration by name.

    Declaration
    [Unmanaged]
    public static void SetActionConfigByName(string name, ActionConfig config, bool all = false)
    Parameters
    System.String name

    The name of the action config.

    ActionConfig config

    The action configuration to set. Leave the config name empty to use set name.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetActionConfigByName(String, GamepadButton, InputGamepadIndex, Boolean)

    Sets the action configuration gamepad button by name and index.

    Declaration
    [Unmanaged]
    public static void SetActionConfigByName(string name, GamepadButton gamepadButton, InputGamepadIndex gamepadIndex, bool all = false)
    Parameters
    System.String 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.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetActionConfigByName(String, KeyboardKeys, Boolean)

    Sets the action configuration keyboard key by name.

    Declaration
    [Unmanaged]
    public static void SetActionConfigByName(string name, KeyboardKeys key, bool all = false)
    Parameters
    System.String name

    The name of the action config.

    KeyboardKeys key

    The key to set.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetActionConfigByName(String, MouseButton, Boolean)

    Sets the action configuration mouse button by name.

    Declaration
    [Unmanaged]
    public static void SetActionConfigByName(string name, MouseButton mouseButton, bool all = false)
    Parameters
    System.String name

    The name of the action config.

    MouseButton mouseButton

    The mouse button to set.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetAxisConfigByName(String, AxisConfig, Boolean)

    Sets the axis configuration keyboard key by name and type.

    Declaration
    [Unmanaged]
    public static void SetAxisConfigByName(string name, AxisConfig config, bool all = false)
    Parameters
    System.String name

    The name of the action config.

    AxisConfig config

    The configuration to set. Leave the config name empty to use set name.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetAxisConfigByName(String, InputAxisType, GamepadButton, GamepadButton, InputGamepadIndex, Boolean)

    Sets the axis configuration gamepad buttons by name, type, and index.

    Declaration
    [Unmanaged]
    public static void SetAxisConfigByName(string name, InputAxisType inputType, GamepadButton positiveButton, GamepadButton negativeButton, InputGamepadIndex gamepadIndex, bool all = false)
    Parameters
    System.String 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.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetAxisConfigByName(String, InputAxisType, KeyboardKeys, KeyboardKeys, Boolean)

    Sets the axis configuration keyboard key buttons by name and type.

    Declaration
    [Unmanaged]
    public static void SetAxisConfigByName(string name, InputAxisType inputType, KeyboardKeys positiveButton, KeyboardKeys negativeButton, bool all = false)
    Parameters
    System.String 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.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetAxisConfigByName(String, InputAxisType, Single, Single, Single, Single, Boolean, Boolean)

    Sets the axis configuration accessories by name, and type.

    Declaration
    [Unmanaged]
    public static void SetAxisConfigByName(string name, InputAxisType inputType, float gravity, float deadZone, float sensitivity, float scale, bool snap, bool all = false)
    Parameters
    System.String name

    The name of the action config.

    InputAxisType inputType

    The type to sort by.

    System.Single gravity

    The gravity to set.

    System.Single deadZone

    The dead zone to set.

    System.Single sensitivity

    The sensitivity to set.

    System.Single scale

    The scale to set.

    System.Boolean snap

    The snap to set.

    System.Boolean all

    Whether to set only the first config found or all of them.

    SetInputMappingFromSettings(JsonAssetReference<InputSettings>)

    Sets and overwrites the Action and Axis mappings with the values from a new InputSettings.

    Declaration
    [Unmanaged]
    public static void SetInputMappingFromSettings(JsonAssetReference<InputSettings> settings)
    Parameters
    JsonAssetReference<InputSettings> settings

    The input settings.

    SetInputMappingToDefaultSettings()

    Sets and overwrites the Action and Axis mappings with the values from the InputSettings in GameSettings.

    Declaration
    [Unmanaged]
    public static void SetInputMappingToDefaultSettings()

    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
    InputEvent

    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
    InputAxis

    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>

    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat