Skip to main content

Axis2Binding

Struct Axis2Binding 

Source
pub struct Axis2Binding { /* private fields */ }
Expand description

A pair of controls that read back a vector, and the knobs they read through.

A stick and a button composite read no longer than 1. The pointer and the wheel read how far they moved through scale, which nothing clamps.

Implementations§

Source§

impl Axis2Binding

Source

pub fn stick(stick: Stick) -> Self

Both lanes of one stick of the standard gamepad layout.

Examples found in repository?
examples/sound-lab.rs (line 320)
311    fn bindings(&self) -> Vec<Axis2Binding> {
312        match self {
313            Move::Walk => vec![
314                Axis2Binding::from(ButtonAxis2 {
315                    left: Key::A,
316                    right: Key::D,
317                    down: Key::S,
318                    up: Key::W,
319                }),
320                Axis2Binding::stick(Stick::Left),
321            ],
322        }
323    }
More examples
Hide additional examples
examples/sprite-adventure.rs (line 796)
781    fn bindings(&self) -> Vec<Axis2Binding> {
782        match self {
783            Move::Walk => vec![
784                Axis2Binding::from(ButtonAxis2 {
785                    left: Key::A,
786                    right: Key::D,
787                    down: Key::S,
788                    up: Key::W,
789                }),
790                Axis2Binding::from(ButtonAxis2 {
791                    left: Key::Left,
792                    right: Key::Right,
793                    down: Key::Down,
794                    up: Key::Up,
795                }),
796                Axis2Binding::stick(Stick::Left),
797            ],
798        }
799    }
examples/input-lab.rs (line 162)
159    fn bindings(&self) -> Vec<Axis2Binding> {
160        match self {
161            Self::LeftStick => vec![
162                Axis2Binding::stick(Stick::Left),
163                ButtonAxis2 {
164                    left: Key::A,
165                    right: Key::D,
166                    down: Key::S,
167                    up: Key::W,
168                }
169                .into(),
170            ],
171            Self::RightStick => vec![
172                Axis2Binding::stick(Stick::Right),
173                ButtonAxis2 {
174                    left: Key::J,
175                    right: Key::L,
176                    down: Key::K,
177                    up: Key::I,
178                }
179                .into(),
180            ],
181            Self::Pointer => vec![Axis2Binding::pointer()],
182            Self::Wheel => vec![Axis2Binding::wheel()],
183        }
184    }
Source

pub fn pointer() -> Self

Pixels the pointer moved this frame, read through scale alone: nothing clamps what it reads.

Examples found in repository?
examples/material-playground.rs (line 691)
689    fn bindings(&self) -> Vec<Axis2Binding> {
690        match self {
691            Self::Look => vec![Axis2Binding::pointer().scale(LOOK_SENSITIVITY)],
692        }
693    }
More examples
Hide additional examples
examples/ui-fonts.rs (line 498)
496    fn bindings(&self) -> Vec<Axis2Binding> {
497        match self {
498            Self::Look => vec![Axis2Binding::pointer().scale(TURN_SENSITIVITY)],
499        }
500    }
examples/stress-preview.rs (line 166)
150    fn bindings(&self) -> Vec<Axis2Binding> {
151        match self {
152            Self::Pan => vec![
153                Axis2Binding::from(ButtonAxis2 {
154                    left: Key::A,
155                    right: Key::D,
156                    down: Key::S,
157                    up: Key::W,
158                }),
159                Axis2Binding::from(ButtonAxis2 {
160                    left: Key::Left,
161                    right: Key::Right,
162                    down: Key::Down,
163                    up: Key::Up,
164                }),
165            ],
166            Self::Look => vec![Axis2Binding::pointer().scale(LOOK_SENSITIVITY)],
167        }
168    }
examples/input-lab.rs (line 181)
159    fn bindings(&self) -> Vec<Axis2Binding> {
160        match self {
161            Self::LeftStick => vec![
162                Axis2Binding::stick(Stick::Left),
163                ButtonAxis2 {
164                    left: Key::A,
165                    right: Key::D,
166                    down: Key::S,
167                    up: Key::W,
168                }
169                .into(),
170            ],
171            Self::RightStick => vec![
172                Axis2Binding::stick(Stick::Right),
173                ButtonAxis2 {
174                    left: Key::J,
175                    right: Key::L,
176                    down: Key::K,
177                    up: Key::I,
178                }
179                .into(),
180            ],
181            Self::Pointer => vec![Axis2Binding::pointer()],
182            Self::Wheel => vec![Axis2Binding::wheel()],
183        }
184    }
Source

pub fn wheel() -> Self

Notches the wheel turned this frame, both lanes as one vector: WheelDelta::Sideways is x and WheelDelta::Up is y. Read through scale alone, so nothing clamps what it reads.

Examples found in repository?
examples/input-lab.rs (line 182)
159    fn bindings(&self) -> Vec<Axis2Binding> {
160        match self {
161            Self::LeftStick => vec![
162                Axis2Binding::stick(Stick::Left),
163                ButtonAxis2 {
164                    left: Key::A,
165                    right: Key::D,
166                    down: Key::S,
167                    up: Key::W,
168                }
169                .into(),
170            ],
171            Self::RightStick => vec![
172                Axis2Binding::stick(Stick::Right),
173                ButtonAxis2 {
174                    left: Key::J,
175                    right: Key::L,
176                    down: Key::K,
177                    up: Key::I,
178                }
179                .into(),
180            ],
181            Self::Pointer => vec![Axis2Binding::pointer()],
182            Self::Wheel => vec![Axis2Binding::wheel()],
183        }
184    }
Source§

impl Axis2Binding

Source

pub fn deadzone(self, deadzone: f32) -> Self

Reads nothing until the control has moved deadzone of its way, then stretches what is left over the whole range; AxisBinding::DEFAULT_DEADZONE for a pad or joystick control, and nothing for the rest.

Clamped into 0.0..=0.95, a fraction of that way, so a control always keeps a range to read in.

Source

pub fn scale(self, scale: f32) -> Self

Multiplies what the control reads, as a fraction of it; 1.0 until set.

A control with a range of its own keeps to it whatever this is set to. A pointer lane or a wheel lane has none, so it reads its own distance times this: pixels for a pointer lane, notches for a wheel lane.

Examples found in repository?
examples/material-playground.rs (line 691)
689    fn bindings(&self) -> Vec<Axis2Binding> {
690        match self {
691            Self::Look => vec![Axis2Binding::pointer().scale(LOOK_SENSITIVITY)],
692        }
693    }
More examples
Hide additional examples
examples/ui-fonts.rs (line 498)
496    fn bindings(&self) -> Vec<Axis2Binding> {
497        match self {
498            Self::Look => vec![Axis2Binding::pointer().scale(TURN_SENSITIVITY)],
499        }
500    }
examples/stress-preview.rs (line 166)
150    fn bindings(&self) -> Vec<Axis2Binding> {
151        match self {
152            Self::Pan => vec![
153                Axis2Binding::from(ButtonAxis2 {
154                    left: Key::A,
155                    right: Key::D,
156                    down: Key::S,
157                    up: Key::W,
158                }),
159                Axis2Binding::from(ButtonAxis2 {
160                    left: Key::Left,
161                    right: Key::Right,
162                    down: Key::Down,
163                    up: Key::Up,
164                }),
165            ],
166            Self::Look => vec![Axis2Binding::pointer().scale(LOOK_SENSITIVITY)],
167        }
168    }
Source

pub fn invert(self) -> Self

Flips the upward lane, for a control that reads the other way round.

Trait Implementations§

Source§

impl Clone for Axis2Binding

Source§

fn clone(&self) -> Axis2Binding

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Axis2Binding

Source§

impl Debug for Axis2Binding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Axis2Binding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<L, R, D, U> From<ButtonAxis2<L, R, D, U>> for Axis2Binding

Source§

fn from(quad: ButtonAxis2<L, R, D, U>) -> Self

Four buttons around a center, the way WASD is laid out; a diagonal reads as long as a straight direction, never longer. The vector is x right minus left, y up minus down; what that means in the world is the game’s call.

Source§

impl From<Stick> for Axis2Binding

Source§

fn from(stick: Stick) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Axis2Binding

Source§

fn eq(&self, other: &Axis2Binding) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Axis2Binding

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<S> Holds<<S as InputActions>::Axis2, Axis2Binding> for S
where S: InputActions,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more