Skip to content

InputAPI reference

Class BufferedInputBackend

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

A base for input backends of platforms whose system reports input as it happens or as per-frame state: a backend emits events (Emit) while it processes the system’s, and the engine drains them (Drain). It also answers the polled questions (IInputSource) from the same events, for code that reads a platform’s Input directly; there a press shorter than a frame reads as held until the next BeginFrame.

C#
public abstract class BufferedInputBackend : IInputBackend, IInputSource

Inheritance

object ← BufferedInputBackend

Implements

IInputBackend, IInputSource

Constructors

BufferedInputBackend()

Creates the backend with an empty queue.

C#
protected BufferedInputBackend()

Properties

LeftStick

Left stick, each axis in -1..1.

C#
public Vector2 LeftStick { get; }

Property Value

Vector2

PadConnected

Whether a gamepad is connected. Sources without gamepads keep the default.

C#
public bool PadConnected { get; }

Property Value

bool

PadStyle

The family of the connected gamepad, for button names in prompts; sources that cannot tell keep Xbox.

C#
public GamepadStyle PadStyle { get; }

Property Value

GamepadStyle

Pointer

The mouse over the virtual canvas; sources without one keep the default (not present).

C#
public PointerState Pointer { get; }

Property Value

PointerState

Pointers

Every pointer: the mouse while over the window, each finger or pen on the screen. Sources without pointers keep the default (none).

C#
public IReadOnlyList<PointerInfo> Pointers { get; }

Property Value

IReadOnlyList<PointerInfo>

State

The state of the devices this backend reported, as its polled view reads it.

C#
protected InputDevices State { get; }

Property Value

InputDevices

Methods

BeginFrame()

Starts a frame of the polled view: presses already released stop reading as held. Call before the frame’s events.

C#
public void BeginFrame()

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>

Emit(in InputEvent)

Queues e for the engine and applies it to the polled view.

C#
protected void Emit(in InputEvent e)

Parameters

e InputEvent

GetPadAxis(PadAxis)

Any gamepad axis. Sources that only know the left stick keep the default.

C#
public float GetPadAxis(PadAxis axis)

Parameters

axis PadAxis

Returns

float

IsKeyDown(Key)

Whether key is held.

C#
public bool IsKeyDown(Key key)

Parameters

key Key

Returns

bool

IsPadDown(PadButton)

Whether button is held on the gamepad.

C#
public bool IsPadDown(PadButton button)

Parameters

button PadButton

Returns

bool

ReleaseHeld(double)

Emits releases of every key, button and pointer button this backend reported held, as the window loses the focus (the system will not send them).

C#
protected void ReleaseHeld(double time)

Parameters

time double