Show / Hide Table of Contents

Class InputDevice

Input device instances expose access to underlying physical input devices such as mouse, keyboard, game pads etc. Users can either poll axis values or button state from an Input device or add event listeners reacting on value or state changes, no matter how the underlying physical device provides axis or button data. Additionally users can define their own axes by specifying calculation rules how to generate values from existing axes or buttons.

Inheritance
System.Object
InputDevice
GamePadDevice
KeyboardDevice
MouseDevice
SixDOFDevice
TouchDevice
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Engine.Core
Assembly: Fusee.Engine.Core.dll
Syntax
public class InputDevice

Properties

AxesCount

Gets number of axes supported by this device.

Declaration
public int AxesCount { get; }
Property Value
Type Description
System.Int32

The axes count.

AxisDesc

Gets a description of the axis. This value can be used in user setup-dialogs or to match axes of devices of different categories.

Declaration
public IEnumerable<AxisDescription> AxisDesc { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<AxisDescription>

The description of the axis.

ButtonCount

Gets the number of buttons supported by this device.

Declaration
public int ButtonCount { get; }
Property Value
Type Description
System.Int32

The button count.

ButtonDesc

Gets the name of the button. This value can be used in user setup-dialogs or to match buttons of devices of different categories.

Declaration
public IEnumerable<ButtonDescription> ButtonDesc { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<ButtonDescription>

The name of the button.

Category

Gets the category of this device. Device categories define a minimal common set of buttons and axes which are identical across all devices sharing the same category.

Declaration
public DeviceCategory Category { get; }
Property Value
Type Description
DeviceCategory

The device category.

Desc

Gets the human readable description of this device. This parameter can be used in user dialogs to identify devices.

Declaration
public string Desc { get; }
Property Value
Type Description
System.String

The device description.

Id

Gets an identifier. Implementors take care that this id is unique across all devices managed by a driver.

Declaration
public string Id { get; }
Property Value
Type Description
System.String

The identifier.

IsConnected

Gets and sets a value indicating whether this device is connected.

Declaration
public bool IsConnected { get; }
Property Value
Type Description
System.Boolean

true if this device is connected; otherwise, false.

NewAxisID

Gets the new next possible new axis identifier. Use this when calling RegisterCalculatedAxis(AxisDescription, InputDevice.AxisValueCalculator, Single).

Declaration
public int NewAxisID { get; }
Property Value
Type Description
System.Int32

The new axis identifier.

Methods

GetAxis(Int32)

Gets the value currently present at the given axis. In respect to the axis deadzone.

Declaration
public float GetAxis(int axisId)
Parameters
Type Name Description
System.Int32 axisId

The axis' Id as specified in AxisDesc.

Returns
Type Description
System.Single

The value currently set on the axis.

Remarks

See AxisDescription to get information about how to interpret the values returned by a given axis.

GetAxisDeadzone(Int32)

Gets the value currently set for the axis deadzone.

Declaration
public float GetAxisDeadzone(int axisId)
Parameters
Type Name Description
System.Int32 axisId

The axis' Id as specified in AxisDesc.

Returns
Type Description
System.Single

GetAxisDescription(Int32)

Retrieves a description for the given axis

Declaration
public AxisDescription GetAxisDescription(int axisId)
Parameters
Type Name Description
System.Int32 axisId

The axis identifier.

Returns
Type Description
AxisDescription

A description of the axis.

GetAxisRaw(Int32)

Gets the value currently present at the given axis. Without considering the deadzone.

Declaration
public float GetAxisRaw(int axisId)
Parameters
Type Name Description
System.Int32 axisId

The axis' Id as specified in AxisDesc.

Returns
Type Description
System.Single

The value currently set on the axis.

Remarks

See AxisDescription to get information about how to interpret the values returned by a given axis.

GetButton(Int32)

Gets the current state of the given button.

Declaration
public bool GetButton(int buttonId)
Parameters
Type Name Description
System.Int32 buttonId

The buttonId of the button as specified in ButtonDesc.

Returns
Type Description
System.Boolean

true if the button is currently pressed. false, if the button is currently released.

GetButtonDescription(Int32)

Retrieves a description for the given button.

Declaration
public ButtonDescription GetButtonDescription(int buttonId)
Parameters
Type Name Description
System.Int32 buttonId

The axis identifier.

Returns
Type Description
ButtonDescription

A description of the axis.

IsButtonDown(Int32)

Determines whether the button was pressed down right before or during the current frame. This value is true only for one frame even if the button is pressed longer than one frame.

Declaration
public bool IsButtonDown(int buttonId)
Parameters
Type Name Description
System.Int32 buttonId

The button identifier.

Returns
Type Description
System.Boolean

true if the button was pressed during this frame and is still pressed down. false, if the button is released or if it was pressed some frames ago.

IsButtonUp(Int32)

Determines whether the button was released right before or during the current frame. This value is true only for one frame even if the button is released longer than one frame.

Declaration
public bool IsButtonUp(int buttonId)
Parameters
Type Name Description
System.Int32 buttonId

The button identifier.

Returns
Type Description
System.Boolean

true if the button was released during this frame and is still released. false, if the button is pressed or if it was released some frames ago.

PostRender()

Clears the button presses after rendering an image.

Declaration
public void PostRender()

RegisterCalculatedAxis(AxisDescription, InputDevice.AxisValueCalculator, Single)

Registers a calculated axis. Calculated axes behave like axes exposed by the underlying hardware device but can be calculated from one or more existing axes or buttons.

Declaration
public void RegisterCalculatedAxis(AxisDescription calculatedAxisDescription, InputDevice.AxisValueCalculator calculator, float initialValue = 0F)
Parameters
Type Name Description
AxisDescription calculatedAxisDescription

The axis description for the new calculated axis.

InputDevice.AxisValueCalculator calculator

The calculator method performing the calculation once per frame.

System.Single initialValue

The initial value for the new axis.

Remarks

To register your own axis you need to provide a working InputDevice.AxisValueCalculator. This method is called whenever the axis value needs to be present. Any state the calculation depends upon should be queried from existing axes presented by the input device or "statically" stored in the closure around the calculator. The methods

    RegisterSingleButtonAxis(Int32, AxisDirection, Single, Single, Int32, String) RegisterTwoButtonAxis(Int32, Int32, AxisDirection, Single, Single, Int32, String) RegisterVelocityAxis(Int32, Int32, Int32, String, AxisDirection)

    RegisterSingleButtonAxis(Int32, AxisDirection, Single, Single, Int32, String)

    Registers a calculated axis from a button. The axis' value changes between 0 and 1 as the user hits the button or releases it. The time it takes to change the value can be set.

    Declaration
    public AxisDescription RegisterSingleButtonAxis(int origButtonId, AxisDirection direction = AxisDirection.Unknown, float rampUpTime = 0.2F, float rampDownTime = 0.2F, int buttonAxisId = 0, string name = null)
    Parameters
    Type Name Description
    System.Int32 origButtonId

    The original button identifier.

    AxisDirection direction

    The direction the new axis is heading towards.

    System.Single rampUpTime

    The time it takes to change the value from 0 to 1 (in seconds).

    System.Single rampDownTime

    The time it takes to change the value from 1 to 0 (in seconds).

    System.Int32 buttonAxisId

    The new identifier of the button axis. Note this value must be bigger than all existing axis Ids. Leave this value zero to have a new identifier calculated automatically.

    System.String name

    The name of the new axis.

    Returns
    Type Description
    AxisDescription

    The axis description of the newly created calculated axis.

    Remarks

    Button axes are useful to simulate a trigger or thrust panel with the help of individual buttons. There is a user-definable acceleration and deceleration period, so a simulation resulting on this input delivers a feeling of inertance.

    RegisterTwoButtonAxis(Int32, Int32, AxisDirection, Single, Single, Int32, String)

    Registers a calculated axis from two buttons. The axis' value changes between -1 and 1 as the user hits the button or releases it. The time it takes to change the value can be set.

    Declaration
    public AxisDescription RegisterTwoButtonAxis(int origButtonIdNegative, int origButtonIdPositive, AxisDirection direction = AxisDirection.Unknown, float rampUpTime = 0.15F, float rampDownTime = 0.35F, int buttonAxisId = 0, string name = null)
    Parameters
    Type Name Description
    System.Int32 origButtonIdNegative

    The original button identifier for negative movements.

    System.Int32 origButtonIdPositive

    The original button identifier for positive movements.

    AxisDirection direction

    The direction the new axis is heading towards.

    System.Single rampUpTime

    The time it takes to change the value from 0 to 1 (or -1) (in seconds) when one of the buttons is pushed.

    System.Single rampDownTime

    The time it takes to change the value from -1 of 1 back to 0 (in seconds) when a pushed button is released.

    System.Int32 buttonAxisId

    The new identifier of the button axis. Note this value must be bigger than all existing axis Ids. Leave this value zero to have a new identifier calculated automatically.

    System.String name

    The name of the new axis.

    Returns
    Type Description
    AxisDescription

    The axis description of the newly created calculated axis.

    Remarks

    Button axes are useful to simulate one axis of a joypad or a joystick with the help of two individual buttons. One button acts as pushing the joystick into the positive direction along the given axis by animating the axis' value to 1 and the a second button acts as pushing the joystick into the negative direction by animating the value to -1. Releasing both buttons will animate the value to 0. Pushing both buttons simultaneously will stop the animation and keep the value at its current amount. There is a user-definable acceleration and deceleration period, so a simulation resulting on this input delivers a feeling of inertance.

    RegisterVelocityAxis(Int32, Int32, Int32, String, AxisDirection)

    Registers a calculated axis exhibiting the derivative after the time (Velocity) of the value on the specified original axis.

    Declaration
    public AxisDescription RegisterVelocityAxis(int origAxisId, int triggerButtonId = 0, int velocityAxisId = 0, string name = null, AxisDirection direction = AxisDirection.Unknown)
    Parameters
    Type Name Description
    System.Int32 origAxisId

    The original axis identifier.

    System.Int32 triggerButtonId

    If a valid id is passed, the derived axis only produces values if the specified button is pressed. The velocity is only calculated based on the axis value when the trigger button is pressed. This allows touch velocities to always start with a speed of zero when the touch starts (e.g. the button identifying that a touchpoint has contact). Otherwise touch velocities would become huge between two click-like touches on different screen locations. If this parameter is 0 (zero), the derived axis will always be calculated based on the original axis only.

    System.Int32 velocityAxisId

    The derived axis identifier. Note this value must be bigger than all existing axis Ids. Leave this value zero to have a new identifier calculated automatically.

    System.String name

    The name of the new axis.

    AxisDirection direction

    The direction of the new axis.

    Returns
    Type Description
    AxisDescription

    The axis description of the newly created calculated axis.

    Remarks

    A derived axis is helpful if you have a device delivering absolute positional values but you need the current speed of the axis. Imagine a mouse where the speed of the mouse over the screen is important rather than the absolute position.

    SetAxisDeadzone(Int32, Single)

    Sets the deadzone for the given axis.

    Declaration
    public void SetAxisDeadzone(int axisId, float value)
    Parameters
    Type Name Description
    System.Int32 axisId

    The axis' Id as specified in AxisDesc.

    System.Single value

    Events

    AxisValueChanged

    Occurs when the value of a given axis has changed.

    Declaration
    public event EventHandler<AxisValueChangedArgs> AxisValueChanged
    Event Type
    Type Description
    System.EventHandler<AxisValueChangedArgs>

    ButtonValueChanged

    Occurs when the value of a given button has changed.

    Declaration
    public event EventHandler<ButtonValueChangedArgs> ButtonValueChanged
    Event Type
    Type Description
    System.EventHandler<ButtonValueChangedArgs>
    Generated by DocFX
    GitHub Repo
    Back to top