InputService class
A game's input: its devices, the asset, and every live copy of the asset (a shared one, and one per player).
Events arrive whenever Flutter or a gamepad sends them and are queued; update replays them in order and moves every action along. The game calls update once per fixed step with its own clock — nothing here reads the wall clock.
Constructors
- InputService({PointerLock? pointerLock})
-
A service with its own devices.
pointerLockis the one InputService.pointerLock hands out (PointerLock.instance when null); a test gives its own.
Properties
- actions → InputActions
-
The asset for every device at once — one player, or the menus before
anyone has joined.
no setter
- asset → InputActionAsset
-
no setter
-
devices
→ List<
InputDevice> -
Every device there is now.
no setter
-
gamepads
→ List<
GamepadDevice> -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
instances
→ List<
InputActions> -
Every live copy of the asset.
no setter
- isSuspended → bool
-
While suspended, devices still change but no action does — a rebind
is listening, and the key it hears must not also jump.
no setter
- keyboard ↔ KeyboardDevice
-
latefinal
-
lastUsedDevice
→ ValueNotifier<
InputDevice?> -
The device used last — a key pressed, a button, a stick pushed. For
showing the right button prompts before anyone has joined.
final
- lockPointerOnClick ↔ bool
-
Whether a press on the game takes hold of pointerLock: a game that
looks with the mouse sets it.
GameWidgettakes hold on a press on the game, and the editor on a press on its play-test; Escape lets go.getter/setter pair - mouse ↔ MouseDevice
-
latefinal
- onScreen ↔ OnScreenDevice
-
latefinal
- overrideStore ↔ InputOverrideStore
-
Where players' own bindings are saved. In memory unless the game says
otherwise — the engine gives it its cache.
getter/setter pair
- players → PlayerInputManager
-
Local multiplayer: off until
players.start().latefinal - pointerLock → PointerLock
-
The app's pointer lock, its raw movement feeding mouse (in
MouseDevice.relativeMode while it holds). Made on first use: a game
that never asks for it never starts it.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- time → double
-
The clock, as of the last update.
no setter
- touchscreen ↔ TouchscreenDevice
-
latefinal
- updateCount → int
-
How many updates there have been. "This frame" means this update.
no setter
Methods
-
actionsFor(
int index) → InputActions? -
Player
index's actions — or, while nobody has joined, the shared ones for player 1. Null for a player who is not playing. -
addDevice(
InputDevice device) → void - Adds a device of the game's own.
-
attachGamepads(
[GamepadSource? source]) → Future< void> - Starts listening to gamepads. Opt-in, because it opens platform channels a test has no use for.
-
attachRawMouse(
Stream< Offset> deltas, {ValueListenable<bool> ? relative}) → InputSubscription - Feeds raw mouse movement from outside Flutter's pointer events into mouse — what pointerLock does with a locked pointer's:
-
createActions(
{DeviceFilter devices = const AllDevices(), String? group, Map< String, String> overrides = const {}, bool ignoreHeld = true}) → InputActions -
A new live copy of the asset, reading only
devices. WithignoreHeld, whatever is held now waits to be let go. -
dispose(
) → void -
forget(
InputActions instance) → void - Called by InputActions.dispose.
-
handleKeyEvent(
KeyEvent event) → void -
handlePointerEvent(
PointerEvent event) → void -
listenDevices(
DeviceListener listener) → InputSubscription -
listenRaw(
RawInputListener listener) → InputSubscription -
listenUpdates(
void listener(double now)) → InputSubscription - Called at the end of every update, with its time — for things that read actions once they have all moved, like a menu's focus.
-
loadAsset(
InputActionAsset asset) → void -
Takes up a new asset — at boot, or when the Input Actions editor
(
just_input_editor) saves one. Every live copy keeps its actions (and their callbacks) where the names match, and its maps on or off as they were. -
lockPointerForClick(
) → void -
Takes hold of pointerLock for a press on the game, if
lockPointerOnClick says so and it does not hold already. What
GameWidgetand the editor's play-test call. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
releaseKeyboard(
) → void - The window lost the keyboard: every key held is let go.
-
releasePointer(
) → Future< void> - Lets pointerLock go, if it was ever used: an editor's Stop or Pause.
-
removeDevice(
InputDevice device) → void -
resumeActions(
) → void - Actions move again; whatever is still held waits to be let go.
-
suspendActions(
) → void -
toString(
) → String -
A string representation of this object.
inherited
-
update(
double now) → void -
Replays what happened since the last update, in order, and moves every
action along to
now(seconds, from the game's clock).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited