pub enum InputEvent<T> {
Show 18 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: f64, delta_y: f64, }, MouseMoved { delta_x: f64, delta_y: f64, }, MouseWheelMoved(ScrollDirection), ControllerAxisMoved { which: u32, axis: ControllerAxis, value: f64, }, ControllerButtonPressed { which: u32, button: ControllerButton, }, ControllerButtonReleased { which: u32, button: ControllerButton, }, ControllerConnected { which: u32, }, ControllerDisconnected { which: u32, }, ActionPressed(T), ActionReleased(T), ActionWheelMoved(T),
}
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

Fields

key_code: VirtualKeyCode

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

scancode: u32

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

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

KeyReleased

Fields

key_code: VirtualKeyCode

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

scancode: u32

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

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

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

Fields

delta_x: f64

The amount the cursor moved horizontally in pixels.

delta_y: f64

The amount the cursor moved vertically in pixels.

The mouse pointer moved on screen

MouseMoved

Fields

delta_x: f64

The amount the mouse moved horizontally.

delta_y: f64

The amount the mouse moved vertically.

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

MouseWheelMoved(ScrollDirection)

The mousewheel was moved in either direction

ControllerAxisMoved

Fields

which: u32

The id for the controller whose axis moved.

axis: ControllerAxis

The axis that moved on the controller.

value: f64

The amount that the axis moved.

A controller Axis was moved.

ControllerButtonPressed

Fields

which: u32

The id for the controller whose button was pressed.

button: ControllerButton

The button that was pressed.

A controller button was pressed.

ControllerButtonReleased

Fields

which: u32

The id for the controller whose button was released.

button: ControllerButton

The button that was released.

A controller button was released.

ControllerConnected

Fields

which: u32

The id for the controller connected.

New controller was connected.

ControllerDisconnected

Fields

which: u32

The id for the controller disconnected.

Controller was disconnected, it’s id might be reused later.

ActionPressed(T)

The associated action had one of its keys pressed.

ActionReleased(T)

The associated action had one of its keys released.

ActionWheelMoved(T)

The associated action has its mouse wheel moved.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert 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. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.