Skip to content

Apple Game Controller Framework Integration plugin for Bevy

License

Notifications You must be signed in to change notification settings

boondocklabs/bevy_gamepad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Apple Game Controller Framework Integration plugin for Bevy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages