pub struct AxisBinding { /* private fields */ }Expand description
One control that reads back a number, and the knobs it reads through.
A pad lane, a trigger, a joystick axis and a button composite read in
-1..=1. A PointerDelta lane and a WheelDelta lane read how far
they moved through scale, which nothing clamps.
Implementations§
Source§impl AxisBinding
impl AxisBinding
Sourcepub const DEFAULT_DEADZONE: f32 = 0.15
pub const DEFAULT_DEADZONE: f32 = 0.15
Distance a pad or joystick control moves before it reads at all.
Sourcepub fn pad(axis: PadAxis) -> Self
pub fn pad(axis: PadAxis) -> Self
One lane of the standard gamepad layout.
Examples found in repository?
228 fn bindings(&self) -> Vec<AxisBinding> {
229 match self {
230 Move::Paddle => vec![
231 AxisBinding::from(ButtonAxis {
232 negative: Key::A,
233 positive: Key::D,
234 }),
235 AxisBinding::from(ButtonAxis {
236 negative: Key::Left,
237 positive: Key::Right,
238 }),
239 AxisBinding::from(ButtonAxis {
240 negative: Pad::DPadLeft,
241 positive: Pad::DPadRight,
242 }),
243 AxisBinding::pad(PadAxis::LeftX),
244 ],
245 }
246 }More examples
90 fn bindings(&self) -> Vec<AxisBinding> {
91 match self {
92 Self::LeftX => vec![
93 AxisBinding::pad(PadAxis::LeftX),
94 ButtonAxis {
95 negative: Key::A,
96 positive: Key::D,
97 }
98 .into(),
99 ],
100 Self::LeftY => vec![
101 AxisBinding::pad(PadAxis::LeftY),
102 ButtonAxis {
103 negative: Key::S,
104 positive: Key::W,
105 }
106 .into(),
107 ],
108 Self::RightX => vec![
109 AxisBinding::pad(PadAxis::RightX),
110 ButtonAxis {
111 negative: Key::J,
112 positive: Key::L,
113 }
114 .into(),
115 ],
116 Self::RightY => vec![
117 AxisBinding::pad(PadAxis::RightY),
118 ButtonAxis {
119 negative: Key::K,
120 positive: Key::I,
121 }
122 .into(),
123 ],
124 Self::LeftTrigger => vec![
125 AxisBinding::pad(PadAxis::LeftTrigger),
126 ButtonAxis {
127 negative: Key::Minus,
128 positive: Key::BracketLeft,
129 }
130 .into(),
131 ],
132 Self::RightTrigger => vec![
133 AxisBinding::pad(PadAxis::RightTrigger),
134 ButtonAxis {
135 negative: Key::Equal,
136 positive: Key::BracketRight,
137 }
138 .into(),
139 ],
140 Self::PointerSideways => vec![AxisBinding::pointer_delta(PointerDelta::Sideways)],
141 Self::PointerUp => vec![AxisBinding::pointer_delta(PointerDelta::Up)],
142 Self::WheelUp => vec![AxisBinding::wheel(WheelDelta::Up)],
143 Self::WheelSideways => vec![AxisBinding::wheel(WheelDelta::Sideways)],
144 }
145 }Sourcepub fn joystick(control: JoystickControl) -> Self
pub fn joystick(control: JoystickControl) -> Self
One axis of a device with no standard layout, by the number its platform reports for it; capture one rather than writing one.
Sourcepub fn pointer_delta(lane: PointerDelta) -> Self
pub fn pointer_delta(lane: PointerDelta) -> Self
Pixels one lane of the pointer moved this frame, read through
scale alone: nothing clamps what it reads.
Examples found in repository?
More examples
90 fn bindings(&self) -> Vec<AxisBinding> {
91 match self {
92 Self::LeftX => vec![
93 AxisBinding::pad(PadAxis::LeftX),
94 ButtonAxis {
95 negative: Key::A,
96 positive: Key::D,
97 }
98 .into(),
99 ],
100 Self::LeftY => vec![
101 AxisBinding::pad(PadAxis::LeftY),
102 ButtonAxis {
103 negative: Key::S,
104 positive: Key::W,
105 }
106 .into(),
107 ],
108 Self::RightX => vec![
109 AxisBinding::pad(PadAxis::RightX),
110 ButtonAxis {
111 negative: Key::J,
112 positive: Key::L,
113 }
114 .into(),
115 ],
116 Self::RightY => vec![
117 AxisBinding::pad(PadAxis::RightY),
118 ButtonAxis {
119 negative: Key::K,
120 positive: Key::I,
121 }
122 .into(),
123 ],
124 Self::LeftTrigger => vec![
125 AxisBinding::pad(PadAxis::LeftTrigger),
126 ButtonAxis {
127 negative: Key::Minus,
128 positive: Key::BracketLeft,
129 }
130 .into(),
131 ],
132 Self::RightTrigger => vec![
133 AxisBinding::pad(PadAxis::RightTrigger),
134 ButtonAxis {
135 negative: Key::Equal,
136 positive: Key::BracketRight,
137 }
138 .into(),
139 ],
140 Self::PointerSideways => vec![AxisBinding::pointer_delta(PointerDelta::Sideways)],
141 Self::PointerUp => vec![AxisBinding::pointer_delta(PointerDelta::Up)],
142 Self::WheelUp => vec![AxisBinding::wheel(WheelDelta::Up)],
143 Self::WheelSideways => vec![AxisBinding::wheel(WheelDelta::Sideways)],
144 }
145 }Sourcepub fn wheel(lane: WheelDelta) -> Self
pub fn wheel(lane: WheelDelta) -> Self
Notches lane of the wheel turned this frame, read through
scale alone: nothing clamps what it reads.
Examples found in repository?
90 fn bindings(&self) -> Vec<AxisBinding> {
91 match self {
92 Self::LeftX => vec![
93 AxisBinding::pad(PadAxis::LeftX),
94 ButtonAxis {
95 negative: Key::A,
96 positive: Key::D,
97 }
98 .into(),
99 ],
100 Self::LeftY => vec![
101 AxisBinding::pad(PadAxis::LeftY),
102 ButtonAxis {
103 negative: Key::S,
104 positive: Key::W,
105 }
106 .into(),
107 ],
108 Self::RightX => vec![
109 AxisBinding::pad(PadAxis::RightX),
110 ButtonAxis {
111 negative: Key::J,
112 positive: Key::L,
113 }
114 .into(),
115 ],
116 Self::RightY => vec![
117 AxisBinding::pad(PadAxis::RightY),
118 ButtonAxis {
119 negative: Key::K,
120 positive: Key::I,
121 }
122 .into(),
123 ],
124 Self::LeftTrigger => vec![
125 AxisBinding::pad(PadAxis::LeftTrigger),
126 ButtonAxis {
127 negative: Key::Minus,
128 positive: Key::BracketLeft,
129 }
130 .into(),
131 ],
132 Self::RightTrigger => vec![
133 AxisBinding::pad(PadAxis::RightTrigger),
134 ButtonAxis {
135 negative: Key::Equal,
136 positive: Key::BracketRight,
137 }
138 .into(),
139 ],
140 Self::PointerSideways => vec![AxisBinding::pointer_delta(PointerDelta::Sideways)],
141 Self::PointerUp => vec![AxisBinding::pointer_delta(PointerDelta::Up)],
142 Self::WheelUp => vec![AxisBinding::wheel(WheelDelta::Up)],
143 Self::WheelSideways => vec![AxisBinding::wheel(WheelDelta::Sideways)],
144 }
145 }Source§impl AxisBinding
impl AxisBinding
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
Trait Implementations§
Source§impl Clone for AxisBinding
impl Clone for AxisBinding
impl Copy for AxisBinding
Source§impl Debug for AxisBinding
impl Debug for AxisBinding
Source§impl Display for AxisBinding
impl Display for AxisBinding
Source§impl<N: Into<ButtonBinding>, P: Into<ButtonBinding>> From<ButtonAxis<N, P>> for AxisBinding
impl<N: Into<ButtonBinding>, P: Into<ButtonBinding>> From<ButtonAxis<N, P>> for AxisBinding
Source§fn from(pair: ButtonAxis<N, P>) -> Self
fn from(pair: ButtonAxis<N, P>) -> Self
A pair, negative counting down and positive counting up; a
diagonal never reads longer than a straight direction.
Source§impl From<PadAxis> for AxisBinding
impl From<PadAxis> for AxisBinding
Source§impl From<PointerDelta> for AxisBinding
impl From<PointerDelta> for AxisBinding
Source§fn from(lane: PointerDelta) -> Self
fn from(lane: PointerDelta) -> Self
Source§impl From<WheelDelta> for AxisBinding
impl From<WheelDelta> for AxisBinding
Source§fn from(lane: WheelDelta) -> Self
fn from(lane: WheelDelta) -> Self
Source§impl PartialEq for AxisBinding
impl PartialEq for AxisBinding
impl StructuralPartialEq for AxisBinding
Auto Trait Implementations§
impl Freeze for AxisBinding
impl RefUnwindSafe for AxisBinding
impl Send for AxisBinding
impl Sync for AxisBinding
impl Unpin for AxisBinding
impl UnsafeUnpin for AxisBinding
impl UnwindSafe for AxisBinding
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
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