Skip to content

Commit

Permalink
Third gamepad (#110)
Browse files Browse the repository at this point in the history
Co-authored-by: Levi Lesches <[email protected]>
  • Loading branch information
aidanahram and Levi-Lesches authored Jun 1, 2023
1 parent 08b05b8 commit 2a87c03
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/src/models/rover/rover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Rover extends Model {
/// Listens for inputs on the second connected gamepad.
final controller2 = Controller(1, ArmControls());

/// Listens for inputs on the third connected gamepad.
final controller3 = Controller(2, CameraControls());

/// Whether the rover is connected.
bool get isConnected => models.sockets.data.isConnected;

Expand All @@ -33,6 +36,7 @@ class Rover extends Model {
await metrics.init();
await controller1.init();
await controller2.init();
await controller3.init();
await settings.init();

metrics.addListener(notifyListeners);
Expand All @@ -47,6 +51,7 @@ class Rover extends Model {
metrics.dispose();
controller1.dispose();
controller2.dispose();
controller3.dispose();
settings.dispose();
super.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/services/gamepad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const vibrateIntensity = 65000;
/// [update] to read any button presses, or else [Gamepad.state] will never update.
class GamepadService extends Service {
/// The maximum number of gamepads we support.
static const int numGamepads = 2;
static const int numGamepads = 3;

/// A list of all the [Gamepad]s the user has connected.
///
Expand Down
2 changes: 2 additions & 0 deletions lib/src/widgets/generic/gamepad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class GamepadButtons extends StatelessWidget {
GamepadButton(controller: models.rover.controller1),
const SizedBox(width: 8),
GamepadButton(controller: models.rover.controller2),
const SizedBox(width: 8),
GamepadButton(controller: models.rover.controller3),
],
);
}

0 comments on commit 2a87c03

Please sign in to comment.