pub struct EventInputHandler<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> { /* private fields */ }
Expand description
Event-based input handler See module-level documentation for more detail.
Implementations§
Source§impl<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> EventInputHandler<I, C>
impl<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> EventInputHandler<I, C>
Sourcepub fn new(control_config: AHashMap<I, C>) -> Self
pub fn new(control_config: AHashMap<I, C>) -> Self
Create a new EventInputHandler with the specified controls. The HashMap in should map inputs to the controls you want them to actuate.
Sourcepub fn input_down(&mut self, input: I)
pub fn input_down(&mut self, input: I)
Call this function when your game engine gives you a KeyDown event, or any event signaling that an input is newly pressed down.
Sourcepub fn input_up(&mut self, input: I)
pub fn input_up(&mut self, input: I)
Call this function when your game engine gives you a KeyUp event, or any event signaling that an input has been released.
Sourcepub fn clear_inputs(&mut self)
pub fn clear_inputs(&mut self)
Manually clear all the inputs the handler has received.
(I’m not sure why you would want to do this, but hey, might as well expose the functionality.)
Trait Implementations§
Source§impl<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> Clone for EventInputHandler<I, C>
EnumMap doesn’t implement Clone so we do it ourselves
impl<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> Clone for EventInputHandler<I, C>
EnumMap doesn’t implement Clone so we do it ourselves
Source§impl<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> InputHandler<I, C> for EventInputHandler<I, C>
impl<I: Hash + Eq + PartialEq + Clone, C: Enum<u32> + Enum<bool> + Clone> InputHandler<I, C> for EventInputHandler<I, C>
Source§fn pressed(&self, control: C) -> bool
fn pressed(&self, control: C) -> bool
Is this input pressed down? i.e. is the player pressing the button?
Source§fn released(&self, control: C) -> bool
fn released(&self, control: C) -> bool
Is this input released? i.e. is the player not pressing the button?
Source§fn clicked_down(&self, control: C) -> bool
fn clicked_down(&self, control: C) -> bool
Is this input being clicked down? i.e. was it up last frame, but down this frame?
Auto Trait Implementations§
impl<I, C> Freeze for EventInputHandler<I, C>
impl<I, C> RefUnwindSafe for EventInputHandler<I, C>where
<C as Enum<u32>>::Array: RefUnwindSafe,
C: RefUnwindSafe,
<C as Enum<bool>>::Array: RefUnwindSafe,
I: RefUnwindSafe,
impl<I, C> Send for EventInputHandler<I, C>
impl<I, C> Sync for EventInputHandler<I, C>
impl<I, C> Unpin for EventInputHandler<I, C>
impl<I, C> UnwindSafe for EventInputHandler<I, C>where
I: UnwindSafe,
C: UnwindSafe,
<C as Enum<u32>>::Array: UnwindSafe,
<C as Enum<bool>>::Array: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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