GamepadService class
A service to match operators to gamepads.
An operator is a human user who will be assigned a gamepad. This user will expect to operate one part of the rover for the duration of the session, hence the name. Above all, it is critical that, once assigned, an operator's controller never changes assignments. that means managing differences between the order of the operators and the order of the gamepads.
For example, say there are three operators and three gamepads. It is very likely that they will not grab the gamepads in the "correct" order -- operator 1 might end up with gamepad 2. Instead of forcing the operators to think like machines, we keep the gamepads list in the order of the operators. When an operator wishes to connect, they may call connect which will grab the first gamepad available, which may have a mismatched gamepad index. init will simply try to connect as many gamepads as possible, which is often desirable at the start of a session.
Note that some gamepads with wireless receivers will show up as connected when the receiver is plugged in, even if the gamepad itself is turned off. This is a fundamental limitation.
Constructors
Properties
-
gamepads
↔ List<
Gamepad> -
A list of gamepads that are currently connected.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
osIndexes
→ Set<
int> -
A list of Gamepad.controllerIndexes for each currently connected controller.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
int operatorIndex) → Future< void> - Connects the given operator to the first available gamepad.
-
dispose(
) → Future< void> - Cleans up any resources used by the service.
-
init(
) → Future< void> - Initializes the service.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getConnectedGamepads(
) → Iterable< int> - Gets a list of currently connected gamepads.
Constants
- maxGamepads → const int
- The maximum number of gamepads that will be connected.