Skip to content

InputAPI reference

Struct InputEvent

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

One thing that happened on an input device, in the order it happened, with the time it happened on the host’s monotonic clock. Backends deliver them (IInputBackend); the engine routes them through the input layers (UI, on-screen controls, then gameplay) and derives the polled state actions read from those no layer took. Build one with the static methods (KeyDown, PointerDown…).

C#
public readonly struct InputEvent : IEquatable<InputEvent>

Implements

IEquatable<InputEvent>

Properties

Axis

The gamepad axis of axis events.

C#
public PadAxis Axis { get; init; }

Property Value

PadAxis

Button

The gamepad button of button events.

C#
public PadButton Button { get; init; }

Property Value

PadButton

Device

The device it happened on.

C#
public DeviceId Device { get; init; }

Property Value

DeviceId

Info

The device of DeviceAdded.

C#
public InputDeviceInfo? Info { get; init; }

Property Value

InputDeviceInfo?

IsPress

Whether this is a press: a key-down that is not a repeat, a pointer-down or a gamepad button-down.

C#
public bool IsPress { get; }

Property Value

bool

Key

The key of key events.

C#
public Key Key { get; init; }

Property Value

Key

Kind

What happened.

C#
public InputEventKind Kind { get; init; }

Property Value

InputEventKind

Pointer

The pointer of pointer events: 0 for the mouse, the finger’s id for touches.

C#
public long Pointer { get; init; }

Property Value

long

PointerButton

The pointer button of pointer-down and pointer-up events.

C#
public PointerButton PointerButton { get; init; }

Property Value

PointerButton

PointerKind

The kind of pointer.

C#
public PointerKind PointerKind { get; init; }

Property Value

PointerKind

Position

The pointer’s position in virtual canvas pixels (may lie outside the canvas, in the letterbox).

C#
public Vector2 Position { get; init; }

Property Value

Vector2

Repeat

Whether a key-down is the system’s auto-repeat of a held key (it does not change what is held).

C#
public bool Repeat { get; init; }

Property Value

bool

ScreenPosition

The pointer’s position in the window’s pixels, for overlays drawn in screen pixels (touches; the mouse when known).

C#
public Vector2 ScreenPosition { get; init; }

Property Value

Vector2

Text

The text of text and composition events.

C#
public string? Text { get; init; }

Property Value

string?

Time

When, in seconds of the host’s monotonic clock (0 for scripted and polled events).

C#
public double Time { get; init; }

Property Value

double

Value

The axis value: sticks -1..1 (right and down positive), triggers 0..1.

C#
public float Value { get; init; }

Property Value

float

Wheel

How far the wheel turned: Y positive away from the player, X positive to the right, in notches.

C#
public Vector2 Wheel { get; init; }

Property Value

Vector2

Methods

Added(InputDeviceInfo, double)

A device was connected.

C#
public static InputEvent Added(InputDeviceInfo info, double time = 0)

Parameters

info InputDeviceInfo

time double

Returns

InputEvent

AxisMoved(DeviceId, PadAxis, float, double)

A gamepad axis moved.

C#
public static InputEvent AxisMoved(DeviceId device, PadAxis axis, float value, double time = 0)

Parameters

device DeviceId

axis PadAxis

value float

time double

Returns

InputEvent

ButtonDown(DeviceId, PadButton, double)

A gamepad button went down.

C#
public static InputEvent ButtonDown(DeviceId device, PadButton button, double time = 0)

Parameters

device DeviceId

button PadButton

time double

Returns

InputEvent

ButtonUp(DeviceId, PadButton, double)

A gamepad button went up.

C#
public static InputEvent ButtonUp(DeviceId device, PadButton button, double time = 0)

Parameters

device DeviceId

button PadButton

time double

Returns

InputEvent

Composition(DeviceId, string, double)

The text being composed changed.

C#
public static InputEvent Composition(DeviceId device, string text, double time = 0)

Parameters

device DeviceId

text string

time double

Returns

InputEvent

Equals(object)

C#
public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(InputEvent)

C#
public bool Equals(InputEvent other)

Parameters

other InputEvent

Returns

bool

GetHashCode()

C#
public override int GetHashCode()

Returns

int

KeyDown(DeviceId, Key, double, bool)

A key went down.

C#
public static InputEvent KeyDown(DeviceId device, Key key, double time = 0, bool repeat = false)

Parameters

device DeviceId

key Key

time double

repeat bool

Returns

InputEvent

KeyUp(DeviceId, Key, double)

A key went up.

C#
public static InputEvent KeyUp(DeviceId device, Key key, double time = 0)

Parameters

device DeviceId

key Key

time double

Returns

InputEvent

PointerDown(DeviceId, long, PointerKind, Vector2, PointerButton, double)

A pointer button went down or a finger touched.

C#
public static InputEvent PointerDown(DeviceId device, long pointer, PointerKind kind, Vector2 position, PointerButton button = PointerButton.Primary, double time = 0)

Parameters

device DeviceId

pointer long

kind PointerKind

position Vector2

button PointerButton

time double

Returns

InputEvent

PointerMove(DeviceId, long, PointerKind, Vector2, double)

A pointer moved.

C#
public static InputEvent PointerMove(DeviceId device, long pointer, PointerKind kind, Vector2 position, double time = 0)

Parameters

device DeviceId

pointer long

kind PointerKind

position Vector2

time double

Returns

InputEvent

PointerUp(DeviceId, long, PointerKind, Vector2, PointerButton, double)

A pointer button went up or a finger lifted.

C#
public static InputEvent PointerUp(DeviceId device, long pointer, PointerKind kind, Vector2 position, PointerButton button = PointerButton.Primary, double time = 0)

Parameters

device DeviceId

pointer long

kind PointerKind

position Vector2

button PointerButton

time double

Returns

InputEvent

Removed(DeviceId, double)

A device was disconnected.

C#
public static InputEvent Removed(DeviceId device, double time = 0)

Parameters

device DeviceId

time double

Returns

InputEvent

TextInput(DeviceId, string, double)

Text was entered.

C#
public static InputEvent TextInput(DeviceId device, string text, double time = 0)

Parameters

device DeviceId

text string

time double

Returns

InputEvent

ToString()

C#
public override string ToString()

Returns

string

WheelMoved(DeviceId, Vector2, Vector2, double)

The wheel turned.

C#
public static InputEvent WheelMoved(DeviceId device, Vector2 wheel, Vector2 position = default, double time = 0)

Parameters

device DeviceId

wheel Vector2

position Vector2

time double

Returns

InputEvent

Operators

operator ==(InputEvent, InputEvent)

C#
public static bool operator ==(InputEvent left, InputEvent right)

Parameters

left InputEvent

right InputEvent

Returns

bool

operator !=(InputEvent, InputEvent)

C#
public static bool operator !=(InputEvent left, InputEvent right)

Parameters

left InputEvent

right InputEvent

Returns

bool