Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luanroger/xinput_gamepad
🎮 Add support to XInput controllers with Win32 API.
https://github.com/luanroger/xinput_gamepad
controller dart flutter gamepad keyboard-events mouse-events win32 xinput
Last synced: 2 months ago
JSON representation
🎮 Add support to XInput controllers with Win32 API.
- Host: GitHub
- URL: https://github.com/luanroger/xinput_gamepad
- Owner: LuanRoger
- License: mit
- Created: 2022-03-07T14:19:21.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-02T22:12:50.000Z (over 1 year ago)
- Last Synced: 2024-05-02T04:04:48.975Z (9 months ago)
- Topics: controller, dart, flutter, gamepad, keyboard-events, mouse-events, win32, xinput
- Language: Dart
- Homepage: https://pub.dev/packages/xinput_gamepad
- Size: 11.5 MB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# xinput_gamepad
### Add support to XInput controllers with Win32 API.
[![badge_version](https://img.shields.io/pub/v/xinput_gamepad)](https://pub.dev/packages/xinput_gamepad)
[![badge_license](https://img.shields.io/github/license/LuanRoger/xinput_gamepad)](https://github.com/LuanRoger/xinput_gamepad/blob/main/LICENSE)
![badge_sdk](https://img.shields.io/badge/sdk-dart%20%7C%20flutter-blue)
![badge_platform](https://img.shields.io/badge/platform-windows-blue)## Dependencies
- [win32](https://pub.dev/packages/win32)
- [ffi](https://pub.dev/packages/ffi)## 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
```powershell
dart pub add xinput_gamepad
```
With Flutter
```powershell
flutter pub add xinput_gamepad
```
See more in [install section](https://pub.dev/packages/xinput_gamepad/install)## Simple example
Enable XInput:
```dart
XInputManager.enableXInput();
```
Init and map the controller:
```dart
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:
```dart
ControllersManager.getIndexConnectedControllers();
```
See all practical examples [here](https://github.com/LuanRoger/xinput_gamepad/tree/main/examples)## Documentation
Access the documentation [here](https://github.com/LuanRoger/xinput_gamepad/wiki)