pub enum BasicInputs {
None,
Simple(Box<dyn Buttonlike>),
Composite(Vec<Box<dyn Buttonlike>>),
Chord(Vec<Box<dyn Buttonlike>>),
}
Expand description
A flat list of the Buttonlike
inputs that make up a UserInput
.
This is used to check for potential clashes between actions, where one action is a strict subset of another.
Variants§
None
No buttonlike inputs are involved.
This might be used for things like a joystick axis.
Simple(Box<dyn Buttonlike>)
The input consists of a single, fundamental Buttonlike
UserInput
.
For example, a single key press.
Composite(Vec<Box<dyn Buttonlike>>)
The input can be triggered by multiple independent Buttonlike
UserInput
s,
but is still fundamentally considered a single input.
For example, a virtual D-Pad is only one input, but can be triggered by multiple keys.
Chord(Vec<Box<dyn Buttonlike>>)
The input represents one or more independent Buttonlike
UserInput
types.
For example, a chorded input is a group of multiple keys that must be pressed together.
Implementations§
source§impl BasicInputs
impl BasicInputs
sourcepub fn inputs(&self) -> Vec<Box<dyn Buttonlike>>
pub fn inputs(&self) -> Vec<Box<dyn Buttonlike>>
Returns a list of the underlying Buttonlike
UserInput
s.
§Warning
When checking for clashes, do not use this method to compute the length of the input.
Instead, use BasicInputs::len
, as these do not always agree.
sourcepub fn compose(self, other: BasicInputs) -> Self
pub fn compose(self, other: BasicInputs) -> Self
Create a BasicInputs::Composite
from two existing BasicInputs
.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of the logical Buttonlike
UserInput
s that make up the input.
A single key press is one input, while a chorded input is multiple inputs. A composite input is still considered one input, even if it can be triggered by multiple keys, as only one input need actually be pressed.
sourcepub fn clashes_with(&self, other: &BasicInputs) -> bool
pub fn clashes_with(&self, other: &BasicInputs) -> bool
Checks if the given two BasicInputs
clash with each other.
Trait Implementations§
source§impl Clone for BasicInputs
impl Clone for BasicInputs
source§fn clone(&self) -> BasicInputs
fn clone(&self) -> BasicInputs
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for BasicInputs
impl !RefUnwindSafe for BasicInputs
impl Send for BasicInputs
impl Sync for BasicInputs
impl Unpin for BasicInputs
impl !UnwindSafe for BasicInputs
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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
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