Struct cuivre::input::InputManager[][src]

pub struct InputManager { /* fields omitted */ }

Retrieves and manages input from events.

Methods

impl InputManager
[src]

Initializes a new InputManager.

Important traits for Vec<u8>

Updates InputManager with new events from an event pump.

This should be called at the start of your game loop.

Returns events that aren't handled by the InputManager.

Gets the current state of a keyboard key.

Returns KeycodeNotFound if the keycode is not found in the current keyboard state.

Example

if input_manager.key(Keycode::Space)?.pressed() {
    println!("Space pressed!");
}

Gets the current state of a custom keybind.

Returns KeybindNotFound if the keybind name is not set.

Can also return the same error(s) as key.

Example

if input_manager.keybind("Space")?.pressed() {
    println!("Space pressed!");
}

Sets a custom keybind for chosen Keycode.

Example

input_manager.set_keybind("Space", Keycode::Space);

Removes a keybind.

Example

input_manager.clear_keybind("Space");

Gets the current state of a mouse button.

Returns MouseButtonNotFound if the button is not found in the current mouse state.

Example

if input_manager.button(MouseButton::Right)?.released() {
    println!("Right click released!");
}

Gets the current mouse position in pixels, relative to the top left corner of the window.

Gets the current mouse position in pixels, relative to last frame's mouse position.

Gets the current state of the mouse wheel. < 0: scrolling down

0: scrolling up

Trait Implementations

impl Default for InputManager
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations