Skip to content

Class InputActionRouter

Namespace: Apogee.Input
Assembly: Apogee.Input.dll

Turns the player's input into the actions of an that fire in the active contexts, and says how far analog actions are pushed. Of the bindings on an input whose modifiers are all held, the one with the most modifiers wins, so Shift+Tab isn't also Tab, and a key still fires while running with Shift. A key with a hold binding fires its press on a quick release instead; a key with a double tap waits a moment for the second tap before firing its press. feeds it from SDL; , , and feed it by hand, with explicit times (seconds, any origin), for tests and replays. Call once a frame to raise , and after the frame's logic ran.

public sealed class InputActionRouter : EngineObject

Inheritance

object ← EngineObject ← InputActionRouter

Inherited Members

EngineObject.IsAdopted, EngineObject.Handle, EngineObject.IsDestroyed, EngineObject.Class, EngineObject.Adopt(), EngineObject.TryGet(SlotHandle, out EngineObject), EngineObject.Destroy(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Fields

DeadZone

Stick and trigger travel that is ignored at rest; the rest scales to 0..1.

public const float DeadZone = 0.2

Field Value

float

DoubleTapSeconds

How long a second tap may take.

public const double DoubleTapSeconds = 0.3

Field Value

double

HoldSeconds

How long a key is held before its hold binding fires.

public const double HoldSeconds = 0.4

Field Value

double

PressAt

An axis past this acts as a pressed button, and is released below .

public const float PressAt = 0.5

Field Value

float

ReleaseAt

public const float ReleaseAt = 0.4

Field Value

float

Properties

ActionFired

public Signal<string> ActionFired { get; }

Property Value

Signal<string>

Captured

The binding text of what was pressed while was on.

public Signal<string> Captured { get; }

Property Value

Signal<string>

Class

What the registry knows about this object's class.

public override ClassInfo Class { get; }

Property Value

ClassInfo

Contexts

The active contexts (a situation); none ignores every input. A game sets them every frame from what the player is doing.

public string[] Contexts { get; set; }

Property Value

string[]

IsGamepadLast

True when the last input pressed was on a gamepad (the labels then name its buttons).

public bool IsGamepadLast { get; }

Property Value

bool

Map

The actions to route. The router takes the map over: it lives as long as the router does.

public InputActionMap? Map { get; set; }

Property Value

InputActionMap?

Methods

Axis(string, float, double)

An axis moves: Joy LX, Joy LY, Joy RX, Joy RY (-1..1), Joy LT, Joy RT (0..1), or the mouse's motion in pixels since the last event (Mouse X, Mouse Y), which adds up until .

public void Axis(string axis, float value, double time)

Parameters

axis string

value float

time double

EndFrame()

The frame's logic has read the mouse's motion: it starts again from zero.

public void EndFrame()

GetDown()

The inputs that are down, sorted.

public string[] GetDown()

Returns

string[]

GetLabel(string)

What to press for an action, as the player's keyboard names it (Z on AZERTY for a W binding), or its gamepad button when the gamepad was used last; an en dash when it is unbound.

public string GetLabel(string action)

Parameters

action string

Returns

string

GetStrength(string)

How far an action is pushed: 0 to 1 for keys, buttons, sticks and triggers (the largest of its bindings), more for the mouse's motion; 0 outside its contexts.

public float GetStrength(string action)

Parameters

action string

Returns

float

InContext(string)

public bool InContext(string action)

Parameters

action string

Returns

bool

IsHeld(string)

public bool IsHeld(string action)

Parameters

action string

Returns

bool

LabelBinding(string)

A binding as the player reads it: Hold Ctrl+Left mouse, Pad A, and a key by what it types on their keyboard layout.

public static string LabelBinding(string text)

Parameters

text string

Returns

string

Listen()

Rebinding: the next key (with the modifiers held), mouse button, wheel step, gamepad button or stick or trigger pushed past half way is not routed; gets its binding text (Shift+F, Joy LY-) at the next , and listening ends. A modifier key alone does not count: it waits for the key it goes with.

public void Listen()

Poll(double)

Fires what time has made due (a hold that has been held long enough, a tap that no second tap followed) and returns the actions fired since the last call, in order. An action bound to several inputs fires once for each.

public string[] Poll(double time)

Parameters

time double

Returns

string[]

Press(string, Modifiers, double)

An input goes down. modifiers are the Ctrl, Shift and Alt held with it, not counting the input itself.

public void Press(string input, Modifiers modifiers, double time)

Parameters

input string

modifiers Modifiers

time double

Release(string, double)

An input goes up.

public void Release(string input, double time)

Parameters

input string

time double

ReleaseAll()

Everything let go and forgotten: the window lost focus, or the game is changing screens.

public void ReleaseAll()

StopListening()

public void StopListening()

Update(double)

, and raises for each action and for a binding that was listened for. Once a frame, before the logic that reads the actions.

public void Update(double time)

Parameters

time double