#gamepad #bevy #joystick #gamedev #apple

bevy_gamepad

Apple Game Controller Framework Integration plugin for Bevy

4 releases

Uses new Rust 2024

0.1.3 Mar 9, 2025
0.1.2 Mar 2, 2025
0.1.1 Mar 2, 2025
0.1.0 Mar 2, 2025

#424 in Game dev

Custom license

48KB
962 lines

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();
}

Dependencies

~28–40MB
~680K SLoC