ScriptedGamepad class final

A GamepadPlatform a test holds the controllers of: it plugs a pad into a slot, sets what the pad is doing, and pulls it out again.

What a backend owes, kept. A slot with no pad reads as disconnected; unplug zeroes the pad before it says so on connectionChanges, so a game that reads it on hearing the news sees nothing held; the slots past the first are real second players, not the first read twice. Install it with GamepadPlatform.instance = ScriptedGamepad(), or hand it to a Gamepad directly.

final pads = ScriptedGamepad();
pads.plug().setDown(PadButton.faceSouth, down: true);
Inheritance

Constructors

ScriptedGamepad()
A platform with no pad plugged in.

Properties

connectionChanges → Stream<PadConnection>
Attaching and detaching, as it happens.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isSupported → bool
False where this package has no implementation.
no setteroverride
reads → int
How many times a slot was read.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → Future<void>
Stops listening. Called when the last owner goes away.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pad({int slot = 0}) → PadSnapshot?
The pad in slot, to set what it does; null when none is plugged in.
plug({int slot = 0}) → PadSnapshot
Plugs a pad into slot and says so; answers the pad, at rest, to set what it does. A slot already holding one keeps it.
read(PadSnapshot out) → void
Fills out with what the pad is doing now.
override
readPad(PadReadContext context) → void
Reads the controller in the context's slot into its snapshot: the first player's is slot 0, the next one to connect slot 1, and so on, as the lights on a console's controllers are numbered.
override
toString() → String
A string representation of this object.
inherited
unplug({int slot = 0}) → void
Pulls the pad out of slot: zeroed first, then announced.

Operators

operator ==(Object other) → bool
The equality operator.
inherited