Class VirtualInput

Handles virtual input that allows you to receive virtual input events that hide the actual physical input, allowing you to easily change the input keys while being transparent to the external code.

Constructors

Accessors

  • get defaultConfiguration(): InputConfiguration
  • Retrieves the default input configuration that determines how physical keys map to virtual buttons.

    Returns InputConfiguration

    Statically registered buttons and axes will be registered with the default configuration. If the active configuration is changed, only procedurally registered buttons and axes will be available.

Methods

  • Returns normalized value for the specified input axis. Returned value will usually be in [-1.0, 1.0] range, but can be outside the range for devices with unbound axes (for example mouse).

    Parameters

    • virtualAxis: VirtualAxis
    • OptionaldeviceIndex: number

      Optional device index in case multiple input devices are available.

    Returns number

  • Check is the virtual button just getting pressed. This state is only active for one frame.

    Parameters

    • button: VirtualButton

      Virtual button identifier.

    • OptionaldeviceIndex: number

      Optional device index in case multiple input devices are available.

    Returns boolean

  • Check is the virtual button is being held. This state is active as long as the button is being held down, possibly for multiple frames.

    Parameters

    • button: VirtualButton

      Virtual button identifier.

    • OptionaldeviceIndex: number

      Optional device index in case multiple input devices are available.

    Returns boolean

  • Check is the virtual button just getting released. This state is only active for one frame.

    Parameters

    • button: VirtualButton

      Virtual button identifier.

    • OptionaldeviceIndex: number

      Optional device index in case multiple input devices are available.

    Returns boolean

Events

onButtonDown: Event<[VirtualButton, number], void>

Triggered when a virtual button is pressed.

onButtonUp: Event<[VirtualButton, number], void>

Triggered when a virtual button is released.

onButtonHeld: Event<[VirtualButton, number], void>

Triggered every frame when a virtual button is being held down.