leafwing_input_manager/input_processing/
mod.rs

1//! Processors for input values
2//!
3//! This module simplifies input handling in your application by providing processors
4//! for refining and manipulating values before reaching the application logic.
5//!
6//! The foundation of this module lies in these enums.
7//!
8//! - [`AxisProcessor`]: Handles `f32` values for single-axis inputs.
9//! - [`DualAxisProcessor`]: Handles [`Vec2`](bevy::prelude::Vec2) values for dual-axis inputs.
10//!
11//! Need something specific? You can also create your own processors by implementing these traits for specific needs.
12//!
13//! - [`CustomAxisProcessor`]: Handles `f32` values for single-axis inputs.
14//! - [`CustomDualAxisProcessor`]: Handles [`Vec2`](bevy::prelude::Vec2) values for dual-axis inputs.
15//!
16//! Feel free to suggest additions to the built-in processors if you have a common use case!
17//!
18//! # Built-in Processors
19//!
20//! ## Digital Conversion
21//!
22//! Digital processors convert raw input values into discrete values,
23//! similar to [`f32::signum`] but returning `0.0` for zero values.
24//!
25//! - [`AxisProcessor::Digital`]: Single-axis digital conversion.
26//! - [`DualAxisProcessor::Digital`]: Dual-axis digital conversion.
27//!
28//! ## Inversion
29//!
30//! Inversion flips the sign of input values, resulting in a directional reversal of control.
31//! For example, positive values become negative, and up becomes down.
32//!
33//! - [`AxisProcessor::Inverted`]: Single-axis inversion.
34//! - [`DualAxisInverted`]: Dual-axis inversion, implemented [`Into<DualAxisProcessor>`].
35//!
36//! ## Sensitivity
37//!
38//! Sensitivity scales input values with a specified multiplier (doubling, halving, etc.),
39//! allowing fine-tuning the responsiveness of controls.
40//!
41//! - [`AxisProcessor::Sensitivity`]: Single-axis scaling.
42//! - [`DualAxisSensitivity`]: Dual-axis scaling, implemented [`Into<DualAxisProcessor>`].
43//!
44//! ## Value Bounds
45//!
46//! Value bounds define an acceptable range for input values,
47//! clamping out-of-bounds inputs to the nearest valid value and leaving others as is
48//! to avoid unexpected behavior caused by extreme inputs.
49//!
50//! - [`AxisBounds`]: A min-max range for valid single-axis inputs,
51//!   implemented [`Into<AxisProcessor>`] and [`Into<DualAxisProcessor>`].
52//! - [`DualAxisBounds`]: A square-shaped region for valid dual-axis inputs,
53//!   with independent min-max ranges for each axis, implemented [`Into<DualAxisProcessor>`].
54//! - [`CircleBounds`]: A circular region for valid dual-axis inputs,
55//!   with a radius defining the maximum magnitude, implemented [`Into<DualAxisProcessor>`].
56//!
57//! ## Dead Zones
58//!
59//! ### Unscaled Versions
60//!
61//! Unscaled dead zones specify regions where input values within the regions
62//! are considered excluded from further processing and treated as zeros,
63//! helping filter out minor fluctuations and unintended movements.
64//!
65//! - [`AxisExclusion`]: A min-max range for excluding single-axis input values,
66//!   implemented [`Into<AxisProcessor>`] and [`Into<DualAxisProcessor>`].
67//! - [`DualAxisExclusion`]: A cross-shaped region for excluding dual-axis inputs,
68//!   with independent min-max ranges for each axis, implemented [`Into<DualAxisProcessor>`].
69//! - [`CircleExclusion`]: A circular region for excluding dual-axis inputs,
70//!   with a radius defining the maximum excluded magnitude, implemented [`Into<DualAxisProcessor>`].
71//!
72//! ### Scaled Versions
73//!
74//! Scaled dead zones transform input values by restricting values within the default bounds,
75//! and then scaling non-excluded values linearly into the "live zone",
76//! the remaining region within the bounds after dead zone exclusion.
77//!
78//! - [`AxisDeadZone`]: A scaled version of [`AxisExclusion`] with the bounds
79//!   set to [`AxisBounds::symmetric(1.0)`](AxisBounds::default),
80//!   implemented [`Into<AxisProcessor>`] and [`Into<DualAxisProcessor>`].
81//! - [`DualAxisDeadZone`]: A scaled version of [`DualAxisExclusion`] with the bounds
82//!   set to [`DualAxisBounds::symmetric_all(1.0)`](DualAxisBounds::default), implemented [`Into<DualAxisProcessor>`].
83//! - [`CircleDeadZone`]: A scaled version of [`CircleExclusion`] with the bounds
84//!   set to [`CircleBounds::new(1.0)`](CircleBounds::default), implemented [`Into<DualAxisProcessor>`].
85
86pub use self::dual_axis::*;
87pub use self::single_axis::*;
88
89pub mod dual_axis;
90pub mod single_axis;