bevy_ineffable 0.2.0

A simple-to-use input manager for bevy that empowers players and makes accessibility easy.
Documentation
use bevy::prelude::{GamepadAxisType, Reflect};
use serde::{Deserialize, Serialize};

use crate::bindings::{BinaryInput, Threshold};

/// Input methods that indicate a direction and magnitude along a single axis.
#[derive(Debug, Serialize, Deserialize, Reflect, Clone, PartialEq, Eq, Hash)]
pub enum AnalogInput {
    /// The amount of scrolling on the mouse's horizontal scroll wheel, since last tick.
    /// Note that most mice don't have this. You're probably looking for ScrollWheelY instead.
    ScrollWheelX,
    /// The amount of scrolling on the mouse's vertical scroll wheel, since last tick.
    ScrollWheelY,

    /// The amount of horizontal movement by the mouse since the last tick.
    /// Could easily be in the high tens if the mouse is moved rapidly and the DPI settings are high.
    MouseMotionX,
    /// The amount of vertical movement by the mouse since the last tick.
    /// Could easily be in the high tens if the mouse is moved rapidly and the DPI settings are high.
    MouseMotionY,

    /// Axis types specific to the GamePad.
    GamePad(GamepadAxisType),
    /// The amount by which the bottom-left trigger is pushed in. Is a value between zero and one.
    /// This button is also present in the `GamepadButtonType`-enum, where it acts as a binary input that activates
    /// when the trigger is pushed 75% of the way in.
    GamePadLeftTrigger2,
    /// The amount by which the bottom-right trigger is pushed in. Is a value between zero and one.
    /// This button is also present in the `GamepadButtonType`-enum, where it acts as a binary input that activates
    /// when the trigger is pushed 75% of the way in.
    GamePadRightTrigger2,
}

impl AnalogInput {
    /// Converts an `AnalogInput` to a `BinaryInput` by applying a `Threshold`. Useful for the builder.
    pub fn at_threshold(self, threshold: Threshold) -> BinaryInput {
        BinaryInput::Axis(self, threshold)
    }
}