Files
shinespark/src/input/map.rs
T
EIREXE aca3886113
CI / build-and-test (push) Successful in 1m24s
CI / production-build (push) Successful in 11m47s
Rework input buffer to match HDR closer (#79)
## Summary

- Preserve distinct same-action bindings in rollback input frames.
- Add independent command lifetimes with tap and state-scoped hold buffering.
- Detect second shield bindings and consume shield commands for air dodge.
- Fix duplicate keyboard mappings being overwritten.

Reviewed-on: #79
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
2026-10-03 09:20:56 +00:00

85 lines
1.8 KiB
Rust

use bevy::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Copy, Clone, PartialEq, Default)]
pub enum InputActionState {
JustPressed,
Pressed,
JustReleased,
#[default]
Released,
}
#[derive(Debug)]
pub enum InputMapAction {
MovementXDir(i32),
MovementYDir(i32),
Jump,
Shield,
Attack,
}
impl InputMapAction {
pub const fn digital_action(&self) -> Option<crate::input::DigitalAction> {
match self {
Self::Jump => Some(crate::input::DigitalAction::Jump),
Self::Shield => Some(crate::input::DigitalAction::Shield),
Self::Attack => Some(crate::input::DigitalAction::Attack),
Self::MovementXDir(_) | Self::MovementYDir(_) => None,
}
}
}
#[derive(Debug)]
pub enum MenuInputMapAction {
MovementXDir(i32),
MovementYDir(i32),
Accept,
Back,
Start,
}
#[derive(Debug)]
pub struct KeyboardInputMapElement {
pub key: KeyCode,
pub action: InputMapAction,
pub binding_slot: u8,
}
#[derive(Debug)]
pub enum GamepadBinding {
Button(GamepadButton),
Axis(GamepadAxis, i32),
}
#[derive(Debug)]
pub struct GamepadInputMapElement {
pub binding: GamepadBinding,
pub action: InputMapAction,
pub binding_slot: u8,
}
#[derive(Debug)]
pub struct MenuKeyboardInputMapElement {
pub key: KeyCode,
pub action: MenuInputMapAction,
}
#[derive(Debug)]
pub struct MenuGamepadInputMapElement {
pub binding: GamepadBinding,
pub action: MenuInputMapAction,
}
#[derive(Resource)]
pub struct BaseInputMap {
pub keyboard: Vec<KeyboardInputMapElement>,
pub gamepad: Vec<GamepadInputMapElement>,
}
#[derive(Resource)]
pub struct MenuInputMap {
pub keyboard: Vec<MenuKeyboardInputMapElement>,
pub gamepad: Vec<MenuGamepadInputMapElement>,
}