Header menu logo Mibo

InputMapper Module

Subscription-based input mapping.

This is intentionally "push" driven: it listens to raw IInput deltas and dispatches a user message that contains the mapped ActionState.

Why this exists:

  • keeps the user's update signature unchanged (no context parameter)
  • user can opt into any model strategy by handling a single message
  • supports dynamic remapping via a getMap callback (e.g., backed by a ref/agent)

Functions and values

Function or value Description

getService ctx

Full Usage: getService ctx

Parameters:
Returns: IInputMapper<'Action>

Gets the IInputMapper service from the game context. Throws if the service is not registered. Use Program.withInputMapper to ensure registration.

ctx : GameContext
Returns: IInputMapper<'Action>

subscribe getMap toMsg ctx

Full Usage: subscribe getMap toMsg ctx

Parameters:
Returns: Sub<'Msg>

Subscribe to mapped action state changes.

ActionState/ActionState are one-shot sets relative to the most recent hardware delta batch.

If you store the state in your model, you typically want to clear one-shots each frame (or just treat them as event-like).

getMap : unit -> InputMap<'Action>
toMsg : ActionState<'Action> -> 'Msg
ctx : GameContext
Returns: Sub<'Msg>

subscribeStatic map toMsg ctx

Full Usage: subscribeStatic map toMsg ctx

Parameters:
Returns: Sub<'Msg>

Convenience overload for static mappings.

map : InputMap<'Action>
toMsg : ActionState<'Action> -> 'Msg
ctx : GameContext
Returns: Sub<'Msg>

tryGetService ctx

Full Usage: tryGetService ctx

Parameters:
Returns: IInputMapper<'Action> voption

Attempts to get the IInputMapper service from the game context. Returns ValueNone if the service is not registered (i.e., Program.withInputMapper wasn't used).

ctx : GameContext
Returns: IInputMapper<'Action> voption

Type something to start searching.