From de73451615e7f12da900223cfe82ae11accb1b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80lex=20Rom=C3=A0n?= Date: Thu, 27 Aug 2026 16:35:49 +0200 Subject: [PATCH] Move deadzone application to later in the pipeline --- src/input/gamepad.rs | 11 +---------- src/input/mod.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/input/gamepad.rs b/src/input/gamepad.rs index 2137c57..35a147f 100644 --- a/src/input/gamepad.rs +++ b/src/input/gamepad.rs @@ -1,5 +1,6 @@ use bevy::math::Vec2; use bevy::prelude::*; +use fixed::traits::Fixed; use crate::game_settings::GameSettings; use crate::input::map::GamepadBinding; @@ -38,16 +39,6 @@ pub fn sample_gamepad(pad: &Gamepad, input_map: &BaseInputMap, game_settings: &G } } - if movement.x.abs() < game_settings.input_common.stick_deadzone { - movement.x = 0.0; - } - if movement.y.abs() < game_settings.input_common.stick_deadzone { - movement.y = 0.0; - } - - if movement.length_squared() > 1.0 { - movement = movement.normalize(); - } input_frame.movement = FGVec2::new(FGi32::from_num(movement.x), FGi32::from_num(movement.y)); input_frame diff --git a/src/input/mod.rs b/src/input/mod.rs index 3928a84..aa7d033 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -24,6 +24,7 @@ pub use map::{ }; use crate::game_settings::GameSettings; +use crate::math::int::FGi32; use crate::netcode::GGRSCfg; use crate::schedule::GameplaySet; @@ -95,6 +96,7 @@ impl Plugin for FighterInputPlugin { }) .add_plugins(gamecube::GamecubeAdapterPlugin) .add_systems(ReadInputs, read_local_inputs) + .add_systems(EguiPrimaryContextPass, debug::input_debug) .add_systems( GgrsSchedule, buffer::postprocess_input.in_set(GameplaySet::Input), @@ -103,6 +105,15 @@ impl Plugin for FighterInputPlugin { } } +fn preprocess_input_frame(frame: &mut FighterInputFrame, game_settings: &GameSettings) { + if frame.movement.x.abs() < game_settings.input_common.stick_deadzone { + frame.movement.x = FGi32::ZERO; + } + if frame.movement.y.abs() < game_settings.input_common.stick_deadzone { + frame.movement.y = FGi32::ZERO; + } +} + fn read_local_inputs( mut commands: Commands, key: Res>, @@ -122,11 +133,14 @@ fn read_local_inputs( .flatten() .and_then(|entity| gamepads.get(entity).ok()); - let input_frame = match gamepad { + let mut input_frame = match gamepad { Some(pad) => gamepad::sample_gamepad(pad, &input_map, &game_settings), None => keyboard::sample_keyboard(&key, &input_map), }; + // preprocess frame + preprocess_input_frame(&mut input_frame, &game_settings); + local_inputs.insert(*handle, input_frame); } commands.insert_resource(LocalInputs::(local_inputs));