Skip to content

LuanRoger/xinput_gamepad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xinput_gamepad

Add support to XInput controllers with Win32 API.

badge_version badge_license badge_sdk badge_platform

Dependencies

Features

  • Handle controller inputs easily;
  • Get controllers information (Battery type, battery level, controller type and more);
  • Get connected controllers;
  • Set more than one button mapping per controller;
  • Set input lag and controller's deadzone;
  • Set and use controller's vibration motor;

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