bevy_enhanced_input 0.27.2

Input manager for Bevy, inspired by Unreal Engine Enhanced Input
Documentation
/*!
Instead of hardcoded states like "pressed" or "released", all actions use an abstract [`TriggerState`] component
(which is a required component of [`Action<C>`]). Its meaning depends on the assigned [input conditions](crate::condition),
which determine when the action is triggered. This allows you to define flexible behaviors, such as "hold for 1 second".

Input conditions are components that implement [`InputCondition`] trait. Similar to modifiers, you can attach them to
both actions and bindings. They also evaluated during [`EnhancedInputSystems::Update`] right after modifiers in their insertion
order and update [`TriggerState`] on the associated action entity.

If no conditions are attached, the action behaves like with [`Down`] condition with a zero actuation threshold,
meaning it will trigger on any non-zero input value.

# Examples

```
use bevy::{asset::AssetPlugin, prelude::*, scene::ScenePlugin};
use bevy_enhanced_input::prelude::*;

#[derive(Component, Default, Clone)]
struct Player;

#[derive(InputAction)]
#[action_output(bool)]
struct Jump;

#[derive(InputAction)]
#[action_output(bool)]
struct Fire;

# let mut app = App::new();
# app.add_plugins((MinimalPlugins, AssetPlugin::default(), ScenePlugin));
let world = app.world_mut();
world.spawn_scene(bsn! {
    Player
    Actions<Player> [
        Action::<Jump>::new()
        // The action will trigger only if held for 1 second.
        ~Hold::new(1.0)
        Bindings [
            Binding(KeyCode::Space)
            --
            Binding(GamepadButton::South)
        ]
        --
        Action::<Fire>::new()
        // The action will trigger every 0.5 seconds while held.
        ~Pulse::new(0.5)
        Bindings [
            Binding(GamepadButton::RightTrigger2)
            // Additionally the right trigger only counts if its value is greater than 0.3.
            Down::new(0.3)
            --
            Binding(MouseButton::Left)
        ]
    ]
}).unwrap();
```
*/

pub mod block_by;
pub mod chord;
pub mod combo;
#[allow(deprecated)]
pub mod cooldown;
pub mod down;
pub mod flick;
pub mod fns;
pub mod hold;
pub mod hold_and_release;
pub mod press;
pub mod pulse;
pub mod release;
pub mod tap;
pub mod toggle;

use std::fmt::Debug;

use crate::prelude::*;

/// Default actuation threshold for all conditions.
pub const DEFAULT_ACTUATION: f32 = 0.5;

/// Defines how input activates.
///
/// Conditions analyze the input, checking for minimum actuation values
/// and validating patterns like short taps, prolonged holds, or the typical "press"
/// or "release" events.
///
/// Can be attached both to bindings and actions.
///
/// If you create a custom condition, it needs to be registered using
/// [`InputConditionAppExt::add_input_condition`].
pub trait InputCondition: Debug {
    /// Returns calculates state.
    ///
    /// `actions` is a state of other actions within the currently evaluating context.
    fn evaluate(
        &mut self,
        actions: &ActionsQuery,
        time: &ContextTime,
        value: ActionValue,
    ) -> TriggerState;

    /// Returns how the condition is combined with others.
    fn kind(&self) -> ConditionKind {
        ConditionKind::Explicit
    }
}

/// Determines how a condition contributes to the final [`TriggerState`].
///
/// If no conditions are provided, the state will be set to [`TriggerState::Fired`]
/// on any non-zero value, functioning similarly to a [`Down`] condition
/// with a zero actuation threshold.
///
/// For details about how actions are combined, see [`Actions`].
pub enum ConditionKind {
    /// The most significant [`TriggerState`] from all explicit conditions will be the
    /// resulting state.
    Explicit,
    /// Like [`Self::Explicit`], but [`TriggerState::Fired`] will be set only if all
    /// implicit conditions return it.
    ///
    /// Otherwise, the most significant state will be capped at [`TriggerState::Ongoing`].
    Implicit,
    /// Any blocking condition that returns [`TriggerState::None`] will override
    /// the state with [`TriggerState::None`].
    ///
    /// Doesn't contribute to the state on its own.
    Blocker,
}