bevy_gamepad

Crates.iobevy_gamepad
lib.rsbevy_gamepad
version0.1.3
created_at2025-03-02 08:19:41.446442+00
updated_at2025-03-09 00:53:55.465311+00
descriptionApple Game Controller Framework Integration plugin for Bevy
homepage
repositoryhttps://github.com/boondocklabs/bevy_gamepad
max_upload_size
id1574384
size169,445
Matt Thompson (boondocklabs)

documentation

README

Apple Game Controller Framework Integration plugin for Bevy

This project provides integration for Apple Game Controllers with the Bevy game engine, as an alternative to the builtin Gilrs based gamepad interface. It enables Bevy to detect, connect, and handle input events from Apple-compatible game controllers using objc2 and objc2_game_controller.

This should also work on iOS devices, but is currently untested.

Supported Controllers

The Game Controller framework limits support of controllers to those supported by Apple.

Known working controllers

  • Nintendo Switch Pro Controller

  • Nintendo Switch JoyCon - Both left and right JoyCons must be paired and will show up as a single gamepad

  • 8BitDo Ultimate Bluetooth (Switch Pro compatible)

  • Xbox

  • DualShock 4

  • DualSense

Features

  • Detects gamepad connections and disconnections using Notification Center framework

  • Supports multiple gamepads

  • Assigns playerIndex enabling LED player displays on controllers

  • Maps gamepad buttons and axes to Bevy's input system

  • Uses Bevy's event system to handle gamepad interactions

  • Asyncronous change detection handled by GC framework

Installation

To use this integration in your Bevy project, add the following dependencies to your Cargo.toml:

[dependencies]
bevy_gamepad = 0

Disable internal Gilrs Gamepad plugin

Since gilrs is included by default, you either need to remove it from the features, or manually define the set of plugins loaded during application setup rather than using DefaultPlugins which includes gilrs. This could be conditional depending on the build target, only enabling the plugin when targeting MacOS/iOS.

The internal gilrs plugin can be disabled by setting default-features = false when importing bevy into your project, and setting all required features explicitly without the gilrs feature flag.

bevy = { git = "https://github.com/bevyengine/bevy", version = "0.16.0-dev", default-features = false, features = [...]

Usage

Add the Plugin to Your Bevy App

use bevy::prelude::*;
use bevy_gamepad::GamepadPlugin;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Add the Gamepad Plugin
        .add_plugins(GamepadPlugin)
        .run();
}
Commit count: 12

cargo fmt