Bevy Archie - Rust / Bevy Controller Support Module

Branch policy:
maintracks Bevy 0.19.x. The maintenance branch isbevy-0.18for Bevy 0.18.x. Bevy 0.17 support is no longer maintained; the final 0.1.x release remains on crates.io for existing consumers.
A comprehensive game controller support module for the Bevy engine, inspired by the RenPy Controller GUI project.
Controller Support Matrix
| Controller | Gyroscope | Touchpad | Adaptive Triggers | Rumble | Layout |
|---|---|---|---|---|---|
| Xbox 360 | 🔴 | 🔴 | 🔴 | ✅ | Xbox |
| Xbox One | 🔴 | 🔴 | 🔴 | ✅ | Xbox |
| Xbox Series X|S | 🔴 | 🔴 | 🔴 | ✅ | Xbox |
| PlayStation 3 | ✅ | 🔴 | 🔴 | ✅ | PlayStation |
| PlayStation 4 | ✅ | ✅ | 🔴 | ✅ | PlayStation |
| PlayStation 5 | ✅ | ✅ | ✅ | ✅ | PlayStation |
| Switch Pro | ✅ | 🔴 | 🔴 | ✅ | Nintendo |
| Switch 2 Pro | ✅ | 🔴 | 🔴 | ✅ | Nintendo |
| Switch Joy-Con | ✅ | 🔴 | 🔴 | ✅ | Nintendo |
| Steam Controller | ✅ | ✅ | 🔴 | ✅ | Xbox |
| Stadia | ✅ | 🔴 | 🔴 | ✅ | Xbox |
| Amazon Luna | 🔴 | 🔴 | 🔴 | ✅ | Xbox |
| 8BitDo M30 | 🔴 | 🔴 | 🔴 | ✅ | Sega |
| 8BitDo SN30 Pro | 🔴 | 🔴 | 🔴 | ✅ | Nintendo |
| HORI Fighting Cmd | 🔴 | 🔴 | 🔴 | ✅ | PlayStation |
| Generic | 🔶 | 🔶 | 🔴 | ✅ | Xbox |
Legend: ✅ Supported | 🔴 Hardware limitation | 🔶 Unknown (varies by device)
Note: Gyroscope, touchpad, and adaptive triggers require platform-specific implementations. See Advanced Features Guide for details.
Version Compatibility
| bevy | bevy_archie |
|---|---|
| 0.19 | 0.3.x (main) |
| 0.18 | 0.2.x (bevy-0.18) |
| 0.17 | 0.1.x (final, on crates.io) |
mainis Bevy 0.19.x. Bevy 0.17 is no longer maintained; thebevy-0.17branch has been retired.
Features
Core Input System
- Input Device Detection: Automatically detect and switch between mouse, keyboard, and gamepad input
- Input Action Mapping: Abstract input actions with customizable bindings for gamepad, keyboard, and mouse
- Action State Tracking: Query pressed, just_pressed, just_released states and analog values for any action
- Per-Stick Settings: Independent sensitivity and inversion for left/right analog sticks
- Deadzone Configuration: Configurable stick deadzones with per-stick customization
Controller Support
- Controller Icon System: Asset-agnostic icon mapping system that adapts to controller type (Xbox, PlayStation, Nintendo, Steam, Stadia, Generic). Bring your own icon assets or use any compatible pack.
- Controller Profiles: Automatic detection and profile loading based on vendor/product IDs
- Multi-controller Support: Handle multiple connected controllers with player assignment
- Controller Layout Detection: Auto-detect and adapt UI to controller type
Advanced Input Features
- Actionlike Trait: Define custom action enums with the
Actionliketrait for type-safe input handling - Haptic Feedback: Rumble and vibration patterns (Constant, Pulse, Explosion, DamageTap, HeavyImpact, Engine, Heartbeat) - fully implemented
- Input Buffering: Record and analyze input sequences for fighting game-style combo detection
- Action Modifiers: Detect Tap, Hold, DoubleTap, LongPress, and Released events on actions
- Button Chords: Detect simultaneous button combinations with configurable clash resolution
- Virtual Input Composites: Combine buttons into virtual axes (
VirtualAxis,VirtualDPad,VirtualDPad3D) - Conditional Bindings: Context-aware actions that activate based on game state or custom conditions
- Input State Machine: Define state machines driven by input actions with automatic transitions
- Gyroscope Support: Motion controls for PS4/PS5/Switch/Stadia/Steam controllers - complete gesture detection and data structures, needs hardware driver integration (HID/SDL2). See ps5_dualsense_motion.rs and switch_pro_gyro.rs
- Touchpad Support: PS4/PS5/Steam touchpad input with multi-touch and gesture detection (swipe, pinch, tap) - complete gesture detection and data structures, needs hardware driver integration (HID/SDL2). See ps5_dualsense_motion.rs and steam_touchpad.rs
Multiplayer
- Player Assignment: Automatic or manual controller-to-player assignment (up to 4 players)
- Controller Ownership: Track which player owns which controller
- Hot-swapping: Handle controller disconnection and reassignment
UI & Configuration
- Controller Remapping: Allow players to remap controller buttons at runtime
- Virtual Keyboard: On-screen keyboard for controller-friendly text input
- Virtual Cursor: Gamepad-controlled cursor for mouse-based UI navigation
- Configuration Persistence: Save and load controller settings to/from JSON files
Developer Tools
- Input Debugging: Visualize input states, history, and analog values
- Input Recording: Record input sequences for testing and replay
- Input Playback: Play back recorded inputs for automated testing
- Input Mocking:
MockInputandMockInputPluginfor unit testing input-dependent systems - Build Helpers: Generate icon manifests and organize controller assets at build time
Mobile & Touch
- Touch Joystick: Virtual on-screen joysticks for mobile platforms with fixed or floating modes
Networking
- Input Synchronization:
ActionDiffandActionDiffBufferfor efficient network input sync with rollback support
Supported Controllers
- Xbox - Xbox 360, Xbox One, Xbox Series X|S controllers
- PlayStation - PS3, PS4, PS5 (DualShock 3, DualShock 4, and DualSense)
- Nintendo - Switch Pro Controller, Switch 2 Pro, Joy-Cons
- Steam - Steam Controller, Steam Deck
- Stadia - Google Stadia Controller (Bluetooth mode)
- Amazon Luna - Amazon Luna Controller (Xbox-style layout)
- 8BitDo - M30 (Sega-style), SN30 Pro (Nintendo-style)
- HORI - Fighting Commander, HORIPAD series
- Generic - Any other standard gamepad
Note: Stadia controllers must be switched to Bluetooth mode (a permanent one-time operation that was available until Dec 31, 2025). In Bluetooth mode, they function as standard Xbox-style gamepads.
Installation
Add to your Cargo.toml:
[]
= { = "path/to/bevy-archie" }
# Or with specific features:
= { = "path/to/bevy-archie", = ["full"] }
Library Size
| Configuration | Pre-link (.rlib) | Final Binary Impact |
|---|---|---|
| Default features | ~8.7 MB | ~200-400 KB |
| All features | ~9.7 MB | ~300-500 KB |
The .rlib size includes Rust metadata and monomorphization templates. After LTO and dead code elimination, bevy_archie adds roughly 0.5-1% overhead on top of a typical Bevy application (~50-80 MB).
Quick Start
use *;
use *;
Action System
Define your game actions and bind them to controller buttons:
use *;
// Actions are predefined, but you can extend with custom actions
Controller Icons
Note: bevy-archie is asset-agnostic. You must provide your own icon assets or use a compatible icon pack like:
- Mr. Breakfast's Free Prompts (400+ icons, Xbox/PS/Switch/Steam Deck)
- Kenney Input Prompts
- Custom artwork
The icon system provides platform-aware filename generation and asset loading infrastructure. Point it to your icon directory:
Display controller-appropriate button icons in your UI:
Icon Naming Conventions
The system expects icons named according to platform conventions:
- Xbox:
xbox_a.png,xbox_b.png,xbox_lb.png,xbox_lt.png - PlayStation:
ps_cross.png,ps_circle.png,ps_l1.png,ps_l2.png - Nintendo:
switch_b.png,switch_a.png,switch_l.png,switch_zl.png - Generic:
left_stick.png,right_stick.png,dpad.png
Icon sizes are supported via suffixes: xbox_a_small.png (32x32), xbox_a.png (48x48), xbox_a_large.png (64x64).
If your icon pack uses different naming, create a thin wrapper or use symbolic links to match the expected names.
Remapping
Enable controller remapping in your settings menu:
Configuration
use *;
Virtual Cursor
Enable gamepad-controlled cursor for mouse-based UI:
use *;
use *;
Configuration Persistence
Save and load controller settings:
use *;
// Load config on startup
// Save config
// Custom path
Config files are saved to platform-specific directories:
- Linux:
~/.config/bevy_archie/controller.json - macOS:
~/Library/Application Support/bevy_archie/controller.json - Windows:
%APPDATA%\bevy_archie\controller.json
Examples
Bevy-archie includes several examples to help you get started:
Basic Examples
- basic_input.rs: Simple input handling
- controller_icons.rs: Display controller-specific icons
- remapping.rs: Runtime button remapping
- virtual_cursor.rs: Gamepad-controlled cursor
- config_persistence.rs: Save/load settings
Advanced Hardware Integration
These examples show how to integrate real hardware for gyro and touchpad:
-
ps5_dualsense_motion.rs: DualSense gyro + touchpad via hidapi
- Complete HID report parsing reference
- Both USB and Bluetooth modes
- Calibration and data injection patterns
-
switch_pro_gyro.rs: Switch Pro Controller gyro via SDL2
- Cross-platform gyro support
- Alternative: Direct HID approach
-
steam_touchpad.rs: Steam Deck/Steam Controller touchpad
- Steam Input API integration (recommended)
- Alternative: Direct HID for advanced users
Run examples with:
Supported Controller Layouts
- Xbox: Xbox 360, Xbox One, Xbox Series controllers
- PlayStation: DualShock 3/4, DualSense
- Nintendo: Joy-Con, Pro Controller, GameCube
- Steam: Steam Controller, Steam Deck
- Stadia: Google Stadia Controller (Bluetooth mode)
- Amazon Luna: Amazon Luna Controller (Xbox-style layout)
- Generic: Fallback for unrecognized controllers
Documentation Map
For a faster overview, this README stays focused on setup and common workflows. Deep dives are split into dedicated docs:
Testing
Quick commands:
For detailed coverage setup and reports, see Test Coverage Guide.
Credits
Inspired by the RenPy Controller GUI by Feniks.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.