Move deadzone application to later in the pipeline

This commit is contained in:
2026-08-27 16:35:49 +02:00
parent 348b1c172b
commit de73451615
2 changed files with 16 additions and 11 deletions
+1 -10
View File
@@ -1,5 +1,6 @@
use bevy::math::Vec2; use bevy::math::Vec2;
use bevy::prelude::*; use bevy::prelude::*;
use fixed::traits::Fixed;
use crate::game_settings::GameSettings; use crate::game_settings::GameSettings;
use crate::input::map::GamepadBinding; 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.movement = FGVec2::new(FGi32::from_num(movement.x), FGi32::from_num(movement.y));
input_frame input_frame
+15 -1
View File
@@ -24,6 +24,7 @@ pub use map::{
}; };
use crate::game_settings::GameSettings; use crate::game_settings::GameSettings;
use crate::math::int::FGi32;
use crate::netcode::GGRSCfg; use crate::netcode::GGRSCfg;
use crate::schedule::GameplaySet; use crate::schedule::GameplaySet;
@@ -95,6 +96,7 @@ impl Plugin for FighterInputPlugin {
}) })
.add_plugins(gamecube::GamecubeAdapterPlugin) .add_plugins(gamecube::GamecubeAdapterPlugin)
.add_systems(ReadInputs, read_local_inputs) .add_systems(ReadInputs, read_local_inputs)
.add_systems(EguiPrimaryContextPass, debug::input_debug)
.add_systems( .add_systems(
GgrsSchedule, GgrsSchedule,
buffer::postprocess_input.in_set(GameplaySet::Input), 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( fn read_local_inputs(
mut commands: Commands, mut commands: Commands,
key: Res<ButtonInput<KeyCode>>, key: Res<ButtonInput<KeyCode>>,
@@ -122,11 +133,14 @@ fn read_local_inputs(
.flatten() .flatten()
.and_then(|entity| gamepads.get(entity).ok()); .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), Some(pad) => gamepad::sample_gamepad(pad, &input_map, &game_settings),
None => keyboard::sample_keyboard(&key, &input_map), None => keyboard::sample_keyboard(&key, &input_map),
}; };
// preprocess frame
preprocess_input_frame(&mut input_frame, &game_settings);
local_inputs.insert(*handle, input_frame); local_inputs.insert(*handle, input_frame);
} }
commands.insert_resource(LocalInputs::<GGRSCfg>(local_inputs)); commands.insert_resource(LocalInputs::<GGRSCfg>(local_inputs));