Skip to content

InputAPI reference

Class InputDevices

Namespace: MicroEngine.Input
Assembly: MicroEngine.Input.dll
Guide: Input

The state of every device, derived from the events no input layer took: which keys and buttons are held, where the axes, the pointers and the wheel are, and which devices are connected. A press that started and ended between two updates still reads as held until an update has sampled it (EndSample): taps expire by updates, never by drawn frames. Players read it through views limited to their devices (View).

C#
public sealed class InputDevices

Inheritance

object ← InputDevices

Constructors

InputDevices()

C#
public InputDevices()

Properties

Devices

The connected devices, in the order they connected.

C#
public IReadOnlyList<InputDeviceInfo> Devices { get; }

Property Value

IReadOnlyList<InputDeviceInfo>

Methods

Apply(in InputEvent)

Applies one event. An event of a device that was never announced announces it first as a generic device of the event’s kind, so a backend’s own ids always work.

C#
public void Apply(in InputEvent e)

Parameters

e InputEvent

EndSample()

Ends a sample: presses that were already released stop reading as held, the wheel starts again from 0 and lifted fingers go. Called once after every update has read the devices.

C#
public void EndSample()

Find(DeviceId)

The device’s description, or null when it is not connected.

C#
public InputDeviceInfo? Find(DeviceId id)

Parameters

id DeviceId

Returns

InputDeviceInfo?

HeldReleases(DeviceId, double)

The events that would release what device holds now: an up for every key and gamepad button held, axes back to 0, and an up for every held pointer button (a cancel for fingers and pens). A backend sends them when the system will not (the window lost the focus).

C#
public IEnumerable<InputEvent> HeldReleases(DeviceId device, double time = 0)

Parameters

device DeviceId

time double

Returns

IEnumerable<InputEvent>

ReleaseAll()

Releases everything held on every device (the window lost focus, the game was suspended).

C#
public void ReleaseAll()

View(Func<DeviceId, bool>)

The state of the devices owns accepts, read as one polled source: a key or button is down when any of them has it down, the axis with the largest deflection wins, the pointer is the one that moved last.

C#
public IInputSource View(Func<DeviceId, bool> owns)

Parameters

owns Func<DeviceId, bool>

Returns

IInputSource

Connected

Raised when a device connects (also those present at start), after it was added.

C#
public event Action<InputDeviceInfo>? Connected

Event Type

Action<InputDeviceInfo>?

Disconnected

Raised when a device disconnects, after it was removed.

C#
public event Action<InputDeviceInfo>? Disconnected

Event Type

Action<InputDeviceInfo>?