Struct leafwing_input_manager::axislike::DualAxisData
source · [−]pub struct DualAxisData { /* private fields */ }Expand description
A wrapped Vec2 that represents the combaination of two input axes.
The neutral origin is always at 0, 0.
When working with gamepad axes, both x and y values are bounded by [-1.0, 1.0].
For other input axes (such as mousewheel data), this may not be true!
This struct should store the processed form of your raw inputs in a device-agnostic fashion. Any deadzone correction, rescaling or drift-correction should be done at an earlier level.
Implementations
sourceimpl DualAxisData
impl DualAxisData
sourcepub fn new(x: f32, y: f32) -> DualAxisData
pub fn new(x: f32, y: f32) -> DualAxisData
Creates a new [AxisPair] from the provided (x,y) coordinates
sourcepub fn from_xy(xy: Vec2) -> DualAxisData
pub fn from_xy(xy: Vec2) -> DualAxisData
Creates a new [AxisPair] directly from a Vec2
sourcepub fn merged_with(&self, other: DualAxisData) -> DualAxisData
pub fn merged_with(&self, other: DualAxisData) -> DualAxisData
Merge the state of this [AxisPair] with another.
This is useful if you have multiple sticks bound to the same game action, and you want to get their combined position.
Warning
This method can result in values with a greater maximum magnitude than expected!
Use [AxisPair::clamp_length] to limit the resulting direction.
sourceimpl DualAxisData
impl DualAxisData
sourcepub fn direction(&self) -> Option<Direction>
pub fn direction(&self) -> Option<Direction>
The Direction that this axis is pointing towards, if any
If the axis is neutral (x,y) = (0,0), a (0, 0) None will be returned
sourcepub fn rotation(&self) -> Option<Rotation>
pub fn rotation(&self) -> Option<Rotation>
The Rotation (measured clockwise from midnight) that this axis is pointing towards, if any
If the axis is neutral (x,y) = (0,0), this will be None
sourcepub fn length(&self) -> f32
pub fn length(&self) -> f32
How far from the origin is this axis’s position?
Typically bounded by 0 and 1.
If you only need to compare relative magnitudes, use magnitude_squared instead for faster computation.
sourcepub fn length_squared(&self) -> f32
pub fn length_squared(&self) -> f32
The square of the axis’ magnitude
Typically bounded by 0 and 1.
This is faster than magnitude, as it avoids a square root, but will generally have less natural behavior.
sourcepub fn clamp_length(&mut self, max: f32)
pub fn clamp_length(&mut self, max: f32)
Clamps the magnitude of the axis
Trait Implementations
sourceimpl Clone for DualAxisData
impl Clone for DualAxisData
sourcefn clone(&self) -> DualAxisData
fn clone(&self) -> DualAxisData
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read moresourceimpl Debug for DualAxisData
impl Debug for DualAxisData
sourceimpl Default for DualAxisData
impl Default for DualAxisData
sourcefn default() -> DualAxisData
fn default() -> DualAxisData
sourceimpl<'de> Deserialize<'de> for DualAxisData
impl<'de> Deserialize<'de> for DualAxisData
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl From<DualAxisData> for Vec2
impl From<DualAxisData> for Vec2
sourcefn from(data: DualAxisData) -> Vec2
fn from(data: DualAxisData) -> Vec2
sourceimpl PartialEq<DualAxisData> for DualAxisData
impl PartialEq<DualAxisData> for DualAxisData
sourcefn eq(&self, other: &DualAxisData) -> bool
fn eq(&self, other: &DualAxisData) -> bool
sourceimpl Serialize for DualAxisData
impl Serialize for DualAxisData
impl Copy for DualAxisData
impl StructuralPartialEq for DualAxisData
Auto Trait Implementations
impl RefUnwindSafe for DualAxisData
impl Send for DualAxisData
impl Sync for DualAxisData
impl Unpin for DualAxisData
impl UnwindSafe for DualAxisData
Blanket Implementations
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
T [ShaderType] for self. When used in [AsBindGroup]
derives, it is safe to assume that all images in self exist. Read moresourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read moreimpl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self using data from the given [World]