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
impl Axis2Binding
Sourcepub fn stick(stick: Stick) -> Self
pub fn stick(stick: Stick) -> Self
Both lanes of one stick of the standard gamepad layout.
Examples found in repository?
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
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 }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 }Sourcepub fn pointer() -> Self
pub fn pointer() -> Self
Pixels the pointer moved this frame, read through
scale alone: nothing clamps what it reads.
Examples found in repository?
More examples
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 }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 }Sourcepub fn wheel() -> Self
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?
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
impl Axis2Binding
Sourcepub fn deadzone(self, deadzone: f32) -> Self
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.
Sourcepub fn scale(self, scale: f32) -> Self
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?
More examples
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 }Trait Implementations§
Source§impl Clone for Axis2Binding
impl Clone for Axis2Binding
Source§fn clone(&self) -> Axis2Binding
fn clone(&self) -> Axis2Binding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Axis2Binding
Source§impl Debug for Axis2Binding
impl Debug for Axis2Binding
Source§impl Display for Axis2Binding
impl Display for Axis2Binding
Source§impl<L, R, D, U> From<ButtonAxis2<L, R, D, U>> for Axis2Bindingwhere
L: Into<ButtonBinding>,
R: Into<ButtonBinding>,
D: Into<ButtonBinding>,
U: Into<ButtonBinding>,
impl<L, R, D, U> From<ButtonAxis2<L, R, D, U>> for Axis2Bindingwhere
L: Into<ButtonBinding>,
R: Into<ButtonBinding>,
D: Into<ButtonBinding>,
U: Into<ButtonBinding>,
Source§fn from(quad: ButtonAxis2<L, R, D, U>) -> Self
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
impl From<Stick> for Axis2Binding
Source§impl PartialEq for Axis2Binding
impl PartialEq for Axis2Binding
impl StructuralPartialEq for Axis2Binding
Auto Trait Implementations§
impl Freeze for Axis2Binding
impl RefUnwindSafe for Axis2Binding
impl Send for Axis2Binding
impl Sync for Axis2Binding
impl Unpin for Axis2Binding
impl UnsafeUnpin for Axis2Binding
impl UnwindSafe for Axis2Binding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
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.Source§fn 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
impl<S> Holds<<S as InputActions>::Axis2, Axis2Binding> for Swhere
S: InputActions,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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