Skip to content

KernelAPI reference

Class HeadlessInputBackend

Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Game lifecycle and time

An input backend tests drive by hand: device events sent with Send are delivered at the next drain, in order; key labels can be set as a keyboard layout would print them; rumbles and text-input switches are recorded.

C#
public sealed class HeadlessInputBackend : IInputBackend, IKeyLabels, IGamepadRumble, ITextInputControl

Inheritance

object ← HeadlessInputBackend

Implements

IInputBackend, IKeyLabels, IGamepadRumble, ITextInputControl

Constructors

HeadlessInputBackend()

C#
public HeadlessInputBackend()

Properties

Labels

The labels KeyLabel reports, as a layout would print them; keys not in it report null.

C#
public Dictionary<Key, string> Labels { get; }

Property Value

Dictionary<Key, string>

Rumbles

Every Rumble call, in order.

C#
public List<(DeviceId Pad, float Low, float High, double Seconds)> Rumbles { get; }

Property Value

List<(DeviceId Pad, float Low, float High, double Seconds)>

TextInput

Whether text input is on, and the caret it was turned on with.

C#
public (bool Active, RectF Caret) TextInput { get; }

Property Value

(bool Active, RectF Caret)

Methods

Drain(List<InputEvent>)

Moves every event since the previous call into events, oldest first.

C#
public void Drain(List<InputEvent> events)

Parameters

events List<InputEvent>

KeyLabel(Key)

The key’s label in the current layout, or null when the backend cannot tell (the US name is used then).

C#
public string? KeyLabel(Key key)

Parameters

key Key

Returns

string?

Rumble(DeviceId, float, float, double)

Records the call; every pad can rumble here.

C#
public bool Rumble(DeviceId pad, float low, float high, double seconds)

Parameters

pad DeviceId

low float

high float

seconds double

Returns

bool

Send(InputEvent)

Queues an event for the next drain.

C#
public HeadlessInputBackend Send(InputEvent e)

Parameters

e InputEvent

Returns

HeadlessInputBackend

Start(RectF)

Turns text input on; caret is where the text being edited is, in virtual canvas pixels, so an input method can place its candidate list next to it.

C#
public void Start(RectF caret)

Parameters

caret RectF

Stop()

Turns text input off.

C#
public void Stop()