LuanRoger / xinput_gamepad

🎮 Add support to XInput controllers with Win32 API.
https://pub.dev/packages/xinput_gamepad
MIT License
6 stars 2 forks source link
controller dart flutter gamepad keyboard-events mouse-events win32 xinput

xinput_gamepad

Add support to XInput controllers with Win32 API.

badge_version badge_license badge_sdk badge_platform

Dependencies

Features

Instalation

With Dart

dart pub add xinput_gamepad

With Flutter

flutter pub add xinput_gamepad

See more in install section

Simple example

Enable XInput:

XInputManager.enableXInput();

Init and map the controller:

final Controller controller = Controller(index: 0);
controller.buttonsMapping = {
  ControllerButton.A_BUTTON: () =>
      print("Controller $controllerIndex - Button A"),
  ControllerButton.B_BUTTON: () =>
      print("Controller $controllerIndex - Button B"),
  ControllerButton.X_BUTTON: () =>
      print("Controller $controllerIndex - Button X"),
  ControllerButton.Y_BUTTON: () =>
      print("Controller $controllerIndex - Button Y"),
};

//Start to listen inputs
controller.listen();

You can get the indexes of the available/connected controllers with:

ControllersManager.getIndexConnectedControllers();

See all practical examples here

Documentation

Access the documentation here