InputAPI reference
Class ActionPrompts
Namespace: MicroEngine.Input
Assembly: MicroEngine.dll
Guide: Input
Tells the player which control presses an action on the device they are using, so dialogues, tutorials, help screens and hints never name a key the player does not have. The text follows the active device (the one that last pressed an action, touch while the on-screen controls are shown), the action’s current bindings (remapping included) and the touch layout, and changes as soon as the player switches device: read it every frame, or when Version changes. Games get one in Prompts.
public sealed class ActionPromptsInheritance
Examples
font.Draw(r, Prompts.Format("Press {attack} to swing the sword"), position, color);// Keyboard: "Press Z to swing...", Xbox pad: "Press A...", PlayStation: "Press ×...", phone: "Press A..." (the touch button's label)Constructors
ActionPrompts(InputMap, VirtualControls?)
Prompts for the actions of input and the controls of touch (optional).
public ActionPrompts(InputMap input, VirtualControls? touch = null)Parameters
input InputMap
touch VirtualControls?
Properties
Device
The device prompts are shown for: Override, else the device that last pressed an action; before any press (or after scripted input), touch when the on-screen controls are shown or the screen is touch-first, otherwise the keyboard.
public InputDevice Device { get; }Property Value
KeyLabels
The labels of the player’s keyboard layout (the platform’s IKeyLabels, set by the engine), so a key is named as printed on the player’s keyboard: the key in A’s place is “Q” on AZERTY. Null, or a key the layout does not label, uses KeyName.
public IKeyLabels? KeyLabels { get; set; }Property Value
Override
Forces prompts for one device (a “show keyboard controls” option, tests); null follows the player.
public InputDevice? Override { get; set; }Property Value
PadStyle
The gamepad family button names follow: PadStyleOverride, else the connected pad’s.
public GamepadStyle PadStyle { get; }Property Value
PadStyleOverride
Forces button names of one gamepad family; null follows the connected pad.
public GamepadStyle? PadStyleOverride { get; set; }Property Value
Version
Changes whenever the text of prompts may have changed (another device, another pad family), so a game that lays text out once (wrapping, measuring) knows when to do it again.
public int Version { get; }Property Value
Methods
All(string, InputDevice?)
Every control that presses action on the device, in binding order (an empty list when none does).
public IReadOnlyList<ActionPrompt> All(string action, InputDevice? device = null)Parameters
action string
device InputDevice?
Returns
ButtonName(PadButton, GamepadStyle)
The name printed on a gamepad button of style. PadButton names positions as on
an Xbox pad; PlayStation pads show shapes there (×, ○, □, △, all in the built-in font), Nintendo pads swap A/B and
X/Y.
public static string ButtonName(PadButton button, GamepadStyle style = GamepadStyle.Xbox)Parameters
button PadButton
style GamepadStyle
Returns
Directions(string?, string?, string?, string?, InputDevice?, string?)
How to show a group of directions together (“move”): on a keyboard the first key of each (“←→↑↓”, “WASD”), on a gamepad “D-pad” or “Stick”, on a touch screen the name of the d-pad or joystick that presses them all.
public string Directions(string? left = null, string? right = null, string? up = null, string? down = null, InputDevice? device = null, string? separator = null)Parameters
left string?
right string?
up string?
down string?
device InputDevice?
separator string?
Returns
Remarks
Keys are listed up, left, down, right, so a WASD set reads “WASD”. With separator set, a
keyboard shows every key set the directions share (“↑←↓→ / WASD”), for a help screen.
Format(string, Func<ActionPrompt, string>?)
Replaces each {action} in template with that action’s prompt ({{ and }}
are literal braces); {move} stands for Directions. Names that are neither bound, pressed by a
touch control nor labelled are left as written. decorate may wrap each prompt (“[Z]”).
public string Format(string template, Func<ActionPrompt, string>? decorate = null)Parameters
template string
decorate Func<ActionPrompt, string>?
Returns
Get(string, InputDevice?)
How to show action on device (default: Device): the first binding the device has.
public ActionPrompt Get(string action, InputDevice? device = null)Parameters
action string
device InputDevice?
Returns
KeyName(Key)
The name a key has on a US keyboard: “Z”, “Space”, “Esc”, “←” (prompts prefer the layout’s label, KeyText).
public static string KeyName(Key key)Parameters
key Key
Returns
KeyText(Key)
What a key cap shows on the player’s keyboard: the layout’s label (KeyLabels), else KeyName.
public string KeyText(Key key)Parameters
key Key
Returns
Knows(string)
Whether name is something a template may name.
public bool Knows(string name)Parameters
name string
Returns
SetLabel(string, InputDevice?, string?)
Replaces the prompt of action with text on device, or on
every device when it is null (“tap”, “the left side”). Null text removes the label.
public void SetLabel(string action, InputDevice? device, string? text)Parameters
action string
device InputDevice?
text string?
Split(string)
The pieces of a template: literal text, and actions with their prompts, for drawing prompts as glyphs between
runs of text (see MicroEngine.UI.PromptText).
public IReadOnlyList<(string Text, ActionPrompt? Prompt)> Split(string template)Parameters
template string
Returns
IReadOnlyList<(string Text, ActionPrompt? Prompt)>
StyleFromName(string?)
The gamepad family a pad’s name suggests (browsers and raylib report names, not types).
public static GamepadStyle StyleFromName(string? name)Parameters
name string?
Returns
Text(string, InputDevice?)
The first control’s text, as Get.
public string Text(string action, InputDevice? device = null)Parameters
action string
device InputDevice?
Returns
TextAll(string, string, InputDevice?)
Every control’s text joined with separator: “Z / Space / Enter” for a help screen.
public string TextAll(string action, string separator = " / ", InputDevice? device = null)Parameters
action string
separator string
device InputDevice?