bevy-input-actions
Skill29 starsChanged 11 days agoMITView on GitHub
Use when building Bevy 0.20 input with `InputSystems`, entity-based `Gamepad`/`GamepadSettings`, `AccumulatedMouseMotion`, or `CursorOptions`: rebindable actions, hot-plugging, deadzones, Steam Deck, accessibility controllers, and correct transfer into `FixedUpdate`.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- bevy-a11ySkill
- bevy-animationSkill
- bevy-assetsSkill
- bevy-audioSkill
- bevy-camerasSkill
- bevy-captureSkill
- bevy-cargo-featuresSkill
- bevy-core-conceptsSkill
- bevy-custom-assetsSkill
- bevy-diagnostics-profilingSkill
- bevy-ecs-componentsSkill
- bevy-ecs-queriesSkill
- bevy-ecs-systemsSkill
- bevy-fluentSkill
- bevy-migration-0-17-to-0-18Skill
- bevy-migration-0-18-to-0-19Skill
- bevy-migration-0-19-to-0-20Skill
- bevy-pbr-materialsSkill
- bevy-physicsSkill
- bevy-portingSkill
- bevy-renderingSkill
- bevy-save-loadSkill
- bevySkill
- bevy-testingSkill
- bevy-uiSkill
- bevy-vfxSkill
- bevy-voxel-dataSkill
- bevy-voxel-pipelineSkill
- bevy-voxel-runtimeSkill
- bevy-wasm-webgpuSkill
- similarity-rsSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 62
Use stable serialized action IDs such as gameplay.jump, menu.confirm, and camera.look.
- Very specific: line 83
Use GamepadConnectionEvent for connection changes and GamepadEvent when relative ordering among connection, button, and axis changes …
- Distinctive: line 90
Do not apply a second hidden deadzone in gameplay code.
- Very specific: line 101
never re-read just_pressed or AccumulatedMouseMotion independently in each FixedUpdate iteration.
- Distinctive: line 145
Every gameplay operation is bindable through a named action, including menu and accessibility paths.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bevy 0.20 — input actions
When to use this skill
- Gameplay needs device-neutral, persisted, rebindable actions and prompts.
- Controllers can hot-plug/reorder or multiple players/devices share input.
- Mouse capture, focus loss, Steam Deck, or adaptive hardware needs one policy.
- Frame-scoped edges/motion must drive deterministic
FixedUpdatesimulation.
Gameplay consumes logical actions, never raw keys or a hard-coded controller entity. Translate Bevy's frame input into an action state once, then feed presentation and fixed simulation from that state.
Canonical pattern
Bevy updates raw input in PreUpdate inside InputSystems. Run the translator after
that set so ButtonInput, Gamepad, input messages, and accumulated mouse motion
represent the current frame:
use bevy::{input::InputSystems, prelude::*};
fn install_input(app: &mut App) {
app.init_resource::<ActionBuffer>().add_systems(
PreUpdate,
translate_physical_input.after(InputSystems),
);
}
#[derive(Resource, Default)]
struct ActionBuffer;
fn translate_physical_input(mut _actions: ResMut<ActionBuffer>) {}keyboard / mouse / touch / Gamepad entities / Steam Input
|
v
physical bindings + device calibration
|
v
active action set/context + conflict policy
|
v
frame action state + ordered transition queue
| |
Update/UI consumers fixed-tick bridgeUse stable serialized action IDs such as gameplay.jump, menu.confirm, and
camera.look. Bindings, labels, prompts, save data, and analytics refer to those IDs;
Rust enum discriminants and catalog order are not persistence contracts.
For an edge whose precise per-device-stream order matters, translate the underlying
keyboard, mouse, or gamepad messages into an ordered queue. A single just_pressed
boolean cannot represent two transitions or their order. Held state and filtered axes
may be stored as the latest values.
Gamepads are entities in Bevy 0.20
fn inspect_gamepads(gamepads: Query<(Entity, &Gamepad)>) {
for (entity, gamepad) in &gamepads {
let move_x = gamepad.get(GamepadAxis::LeftStickX).unwrap_or(0.0);
let jump_started = gamepad.just_pressed(GamepadButton::South);
let _sample = (entity, move_x, jump_started);
}
}Use GamepadConnectionEvent for connection changes and GamepadEvent when relative
ordering among connection, button, and axis changes matters. Store active-player
assignment separately from bindings. An ECS Entity is a live device handle, not a
stable device identity or save-file key.
Configure per-device filtering through its GamepadSettings component. Apply an
inner deadzone, optional outer calibration, response curve, and final clamp once.
Do not apply a second hidden deadzone in gameplay code.
Gotchas: frame input is not fixed-tick input
Raw input is frame-scoped; fixed simulation may run zero, one, or many ticks in that frame. Therefore:
- retain ordered press/release transitions until a fixed tick consumes them;
- accumulate relative motion until that same tick;
- drain transitions and relative motion once, on the first available tick;
- copy held buttons and absolute axes to every fixed tick;
- never re-read
just_pressedorAccumulatedMouseMotionindependently in eachFixedUpdateiteration.
For rollback/network simulation, convert the bridge output into an explicit command frame keyed by simulation tick and retain it for replay.
Mouse capture and focus
Capture through the primary window's CursorOptions: hide the cursor and request
CursorGrabMode::Locked when gameplay owns look input. On focus loss, pause or
neutralise gameplay input, release capture, synthesize required action releases, and
clear relative motion. Reacquire only from an intentional user gesture; never trap
the pointer merely because focus returned.
Keyboard state is released by Bevy on focus loss, while gamepad state is independent of window focus. Your action layer still needs one policy that prevents stuck or unexpected gameplay actions.
Version traps
- 0.20:
GamepadButton::Other(u32)/GamepadAxis::Other(u32)(wereu8). - 0.20: UI pointer events are flat. Write
On<PointerPress>withevent.pointer.position, notOn<Pointer<Press>>withpointer_location. - 0.20:
EntityCursor,DefaultCursor,CursorIconPluginlive inbevy::picking::cursor; thecustom_cursorfeature belongs tobevy_picking.CursorOptions(grab mode, visibility) is still a window-entity component:Single<&mut CursorOptions, With<PrimaryWindow>>. - 0.20:
chain_weakrelaxed several built-in schedules;PreUpdate/InputSystemsis not one of them, and.after(InputSystems)is still a strict edge. - 0.19:
InputFocusfields are private (set/get/clear), andbevy_input_focusis no longer implied by thepickingfeature. - 0.18+: connection changes are messages:
MessageReader<GamepadConnectionEvent>, notEventReader.
Choose the relevant deep dive
| Problem | Read |
| Stable actions, binding grammar, contexts, rebinding and conflicts | Actions and rebinding |
| Device assignment, hot-plug, deadzones, Steam Deck and adaptive hardware | Gamepads and platforms |
| Edge queues, mouse accumulation, zero/multiple fixed ticks, rollback | Fixed-step buffering |
Review checklist
- Every gameplay operation is bindable through a named action, including menu and accessibility paths; essential actions offer alternatives to chords/holds.
- Prompts resolve the active binding and device glyph rather than naming a key.
- Disconnecting one controller does not silently transfer its player to another.
- Press+release between two fixed ticks is delivered, exactly once, in order.
- Mouse motion is neither lost on a zero-tick frame nor multiplied on catch-up ticks.
- Focus loss cannot leave a held action or captured pointer stuck.
- Steam Deck and adaptive-controller testing uses real hardware and saved rebinding.
See also
bevy-a11y— action accessibility and controller acceptance criteria.bevy-core-concepts—PreUpdate,Update, andFixedUpdate.bevy-testing— deterministic fixed-step input tests.bevy-migration-0-19-to-0-20— cursor module move, flat pointer events.- Bevy gamepad module
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

