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.

Public

Constructors

VirtualInput

VirtualInput()

Methods

SetConfiguration

void SetConfiguration(const SPtr<InputConfiguration> &input)

Input configuration that determines how physical keys map to virtual buttons.

GetConfiguration

SPtr<InputConfiguration> GetConfiguration() const

staticGetOrCreateVirtualButton

static VirtualButton GetOrCreateVirtualButton(const String &name)

Creates a new virtual button associated with the name, or returns an existing button if it exists.

staticGetOrCreateVirtualAxis

static VirtualAxis GetOrCreateVirtualAxis(const String &name)

Creates a new virtual axis associated with the name, or returns an existing axis if it exists.

IsButtonDown

bool IsButtonDown(const VirtualButton &button, u32 deviceIndex = 0) const

Check is the virtual button just getting pressed.

This state is only active for one frame.

button
Virtual button identifier.
deviceIndex
Optional device index in case multiple input devices are available.

IsButtonUp

bool IsButtonUp(const VirtualButton &button, u32 deviceIndex = 0) const

Check is the virtual button just getting released.

This state is only active for one frame.

button
Virtual button identifier.
deviceIndex
Optional device index in case multiple input devices are available.

IsButtonHeld

bool IsButtonHeld(const VirtualButton &button, u32 deviceIndex = 0) const

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.

button
Virtual button identifier.
deviceIndex
Optional device index in case multiple input devices are available.

GetAxisValue

float GetAxisValue(const VirtualAxis &axis, u32 deviceIndex = 0) const

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).

axis
Virtual axis identifier.
deviceIndex
Optional device index in case multiple input devices are available.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Fields

OnButtonDown

Event<void (const VirtualButton &, u32)> OnButtonDown

Triggered when a virtual button is pressed.

OnButtonUp

Event<void (const VirtualButton &, u32)> OnButtonUp

Triggered when a virtual button is released.

OnButtonHeld

Event<void (const VirtualButton &, u32)> OnButtonHeld

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

Internal

Methods

UpdateInternal

void UpdateInternal()

Called once every frame.

Triggers button callbacks.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Methods

ButtonDown

void ButtonDown(const ButtonEvent &event)

Performs all logic related to a button press.

ButtonUp

void ButtonUp(const ButtonEvent &event)

Performs all logic related to a button release.

Fields

mInputConfiguration

SPtr<InputConfiguration> mInputConfiguration

mDevices

Vector<DeviceData> mDevices

mEvents

Queue<VirtualButtonEvent> mEvents

mActiveModifiers

u32 mActiveModifiers

tempButtons

Vector<VirtualButton> tempButtons

tempBtnDescs

Vector<VirtualButtonInformation> tempBtnDescs