InputEvent

Enum InputEvent 

Source
pub enum InputEvent<T>
where T: BindingTypes,
{
Show 19 variants KeyPressed { key_code: VirtualKeyCode, scancode: u32, }, KeyReleased { key_code: VirtualKeyCode, scancode: u32, }, KeyTyped(char), MouseButtonPressed(MouseButton), MouseButtonReleased(MouseButton), ButtonPressed(Button), ButtonReleased(Button), CursorMoved { delta_x: f32, delta_y: f32, }, MouseMoved { delta_x: f32, delta_y: f32, }, MouseWheelMoved(ScrollDirection), AxisMoved { axis: T::Axis, value: f32, }, ControllerAxisMoved { which: u32, axis: ControllerAxis, value: f32, }, ControllerButtonPressed { which: u32, button: ControllerButton, }, ControllerButtonReleased { which: u32, button: ControllerButton, }, ControllerConnected { which: u32, }, ControllerDisconnected { which: u32, }, ActionPressed(T::Action), ActionReleased(T::Action), ActionWheelMoved(T::Action),
}
Expand description

Events generated by the input system

Type parameter T is the type assigned to your Actions for your InputBundle or InputHandler.

Variants§

§

KeyPressed

A key was pressed down, sent exactly once per key press.

Fields

§key_code: VirtualKeyCode

VirtualKeyCode, used for semantic info. i.e. “W” was pressed

§scancode: u32

Scancode, used for positional info. i.e. The third key on the first row was pressed.

§

KeyReleased

A key was released, sent exactly once per key release.

Fields

§key_code: VirtualKeyCode

VirtualKeyCode, used for semantic info. i.e. “W” was released

§scancode: u32

Scancode, used for positional info. i.e. The third key on the first row was released.

§

KeyTyped(char)

A unicode character was received by the window. Good for typing.

§

MouseButtonPressed(MouseButton)

A mouse button was pressed down, sent exactly once per press.

§

MouseButtonReleased(MouseButton)

A mouse button was released, sent exactly once per release.

§

ButtonPressed(Button)

A button was pressed.

§

ButtonReleased(Button)

A button was released.

§

CursorMoved

The mouse pointer moved on screen

Fields

§delta_x: f32

The amount the cursor moved horizontally in pixels.

§delta_y: f32

The amount the cursor moved vertically in pixels.

§

MouseMoved

The mouse device moved. Use this for any use of the mouse that doesn’t involve a standard mouse pointer.

Fields

§delta_x: f32

The amount the mouse moved horizontally.

§delta_y: f32

The amount the mouse moved vertically.

§

MouseWheelMoved(ScrollDirection)

The mousewheel was moved in either direction

§

AxisMoved

An axis value changed.

Note that this variant is used for BindingTypes::Axis, not a ControllerAxis.

Fields

§axis: T::Axis

The axis that moved on the controller.

§value: f32

The amount that the axis moved.

§

ControllerAxisMoved

A controller Axis was moved.

Note that this variant is used for a ControllerAxis, not BindingTypes::Axis.

Fields

§which: u32

The id for the controller whose axis moved.

§axis: ControllerAxis

The axis that moved on the controller.

§value: f32

The amount that the axis moved.

§

ControllerButtonPressed

A controller button was pressed.

Fields

§which: u32

The id for the controller whose button was pressed.

§button: ControllerButton

The button that was pressed.

§

ControllerButtonReleased

A controller button was released.

Fields

§which: u32

The id for the controller whose button was released.

§button: ControllerButton

The button that was released.

§

ControllerConnected

New controller was connected.

Fields

§which: u32

The id for the controller connected.

§

ControllerDisconnected

Controller was disconnected, its id might be reused later.

Fields

§which: u32

The id for the controller disconnected.

§

ActionPressed(T::Action)

The associated action had any related button or combination pressed.

If a combination is bound to an action, it will be pressed if all buttons within are pressed.

§

ActionReleased(T::Action)

The associated action had any related button or combination released.

If a combination is bound to an action, it will be released if any of the buttons within is released while all others are pressed.

§

ActionWheelMoved(T::Action)

The associated action has its mouse wheel moved.

Trait Implementations§

Source§

impl<T> Clone for InputEvent<T>
where T: BindingTypes,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for InputEvent<T>
where T: BindingTypes + Debug, T::Axis: Debug, T::Action: Debug,

Source§

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

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

impl<'de, T> Deserialize<'de> for InputEvent<T>
where T: BindingTypes, T::Axis: Deserialize<'de>, T::Action: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a, T> Into<InputEvent<T>> for &'a ControllerEvent
where T: BindingTypes,

Source§

fn into(self) -> InputEvent<T>

Converts this type into the (usually inferred) input type.
Source§

impl<T> PartialEq for InputEvent<T>

Source§

fn eq(&self, other: &InputEvent<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for InputEvent<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> StructuralPartialEq for InputEvent<T>
where T: BindingTypes,

Auto Trait Implementations§

§

impl<T> Freeze for InputEvent<T>
where <T as BindingTypes>::Axis: Freeze, <T as BindingTypes>::Action: Freeze,

§

impl<T> RefUnwindSafe for InputEvent<T>

§

impl<T> Send for InputEvent<T>

§

impl<T> Sync for InputEvent<T>

§

impl<T> Unpin for InputEvent<T>
where <T as BindingTypes>::Axis: Unpin, <T as BindingTypes>::Action: Unpin,

§

impl<T> UnwindSafe for InputEvent<T>

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> Any for T
where T: Any,

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<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> Config for T
where T: for<'a> Deserialize<'a> + Serialize,

Source§

fn load<P>(path: P) -> Result<T, ConfigError>
where P: AsRef<Path>,

Loads a configuration structure from a file.
Source§

fn load_bytes(bytes: &[u8]) -> Result<T, ConfigError>

Loads configuration structure from raw bytes.
Source§

fn write<P>(&self, path: P) -> Result<(), ConfigError>
where P: AsRef<Path>,

Writes a configuration structure to a file.
Source§

fn load_no_fallback<P>(path: P) -> Result<Self, ConfigError>
where P: AsRef<Path>,

👎Deprecated: use load instead
Loads a configuration structure from a file.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Event for T
where T: Send + Sync + 'static,

Source§

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