FLUTTER ECOSYSTEM

halildurmus/win32_gamepad

Windows 컴퓨터에 연결된 게임패드에 액세스하기 위한 현대적이고 타입 안전한 Dart API입니다.

win32_gamepad 프로젝트 이미지
Stars
25
Forks
2
최근 푸시(UTC)
2026. 2. 26.
프로젝트 상태
보관됨
Halil Durmus GitHub avatar
GITHUB User

Halil Durmus ↗

Software Engineer • Dart Enthusiast💙🎯

언어DartC++CMakeC

기술 주제

사용 중인 의존성

의존성 목록 6 개
  • ffi^2.2.0
  • win32^6.0.0
  • checks개발 의존성^0.3.1
  • halildurmus_hooks개발 의존성^0.1.1
  • halildurmus_lints개발 의존성^2.0.0
  • test개발 의존성^1.29.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

This package has moved

The package can now be found at https://github.com/halildurmus/win32/tree/main/packages/win32_gamepad.


ci Package: win32_gamepad Publisher: halildurmus.dev Language: Dart License: BSD-3-Clause

A modern, type-safe Dart API for accessing gamepads connected to a Windows machine.

This package builds on top of the package:win32 and provides a high-level abstraction over native gamepad APIs. It eliminates the need to work directly with FFI, raw pointers, or low-level Win32 calls while preserving performance and correctness.

✨ Features

  • Connect up to 4 gamepads — supports all four XInput controller slots
  • Poll buttons, triggers & thumbsticks — full access to every input via a clean GamepadState object
  • Rumble motor control — independently set left and right vibration motor speeds
  • Battery information — query battery level and type for wireless controllers

🚀 Getting Started

Add the package to your pubspec.yaml:

dependencies:
  win32_gamepad: ^1.0.10

Then import it:

import 'package:win32_gamepad/win32_gamepad.dart';

⚡ Quick Example

Create a Gamepad instance by passing the controller index (0–3):

final gamepad = Gamepad(0); // primary controller

Windows supports up to four gamepads simultaneously. Poll the gamepad by calling updateState() in your game loop, then inspect the state object for buttons, triggers, and thumbstick values. Rumble motors can be activated with the vibrate method.

import 'dart:io';

import 'package:win32_gamepad/win32_gamepad.dart';

void main() {
  // Check which controllers are connected.
  for (var idx = 0; idx < 4; idx++) {
    final gamepad = Gamepad(idx);
    final connectionStatus = gamepad.isConnected ? 'connected' : 'disconnected';
    print('Gamepad $idx is $connectionStatus.');
  }

  final gamepad = Gamepad(0);
  if (!gamepad.isConnected) {
    print('No gamepad connected on slot 0.');
    return;
  }

  // Read battery information.
  final GamepadBatteryInfo(:batteryLevel, :batteryType) =
      gamepad.gamepadBatteryInfo;
  print('Battery type is ${batteryType.name}.');
  print('Battery level is ${batteryLevel.name}.');

  // Test vibration motors.
  print('Vibrating left motor (half intensity).');
  gamepad.vibrate(leftMotorSpeed: 32767);
  sleep(const .new(milliseconds: 1000));

  print('Vibrating right motor (half intensity).');
  gamepad.vibrate(rightMotorSpeed: 32767);
  sleep(const .new(milliseconds: 1000));

  print('Vibrating both motors (full intensity).');
  gamepad.vibrate(leftMotorSpeed: 65535, rightMotorSpeed: 65535);
  sleep(const .new(milliseconds: 1000));

  print('Turning off vibration.');
  gamepad.vibrate();
}

🖥️ Flutter Inspector Demo

A full Flutter example app is available in the example/inspector/ directory. It demonstrates how to build a live gamepad monitor with button highlights, trigger bars, and thumbstick visualisations inside a game loop:

Gamepad Inspector Demo

📝 Documentation

Full API reference is available here:

👉 API Reference.

Additional usage examples are located in the [example] directory.

🐞 Features and Bugs

If you encounter bugs or need additional functionality, please file an issue.