Struct cuivre::input::InputManager [−][src]
pub struct InputManager { /* fields omitted */ }
Retrieves and manages input from events.
Methods
impl InputManager
[src]
impl InputManager
pub fn new() -> InputManager
[src]
pub fn new() -> InputManager
Initializes a new InputManager.
pub fn update(&mut self, events: EventPump) -> Vec<Event>
[src]
pub fn update(&mut self, events: EventPump) -> Vec<Event>
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
.
pub fn key(&self, keycode: Keycode) -> &KeyState
[src]
pub fn key(&self, keycode: Keycode) -> &KeyState
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!"); }
pub fn keybind(&self, name: &str) -> Result<&KeyState, InputError>
[src]
pub fn keybind(&self, name: &str) -> Result<&KeyState, InputError>
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!"); }
pub fn set_keybind(&mut self, name: &str, keycode: Keycode)
[src]
pub fn set_keybind(&mut self, name: &str, keycode: Keycode)
Sets a custom keybind for chosen Keycode
.
Example
input_manager.set_keybind("Space", Keycode::Space);
pub fn clear_keybind(&mut self, name: &str)
[src]
pub fn clear_keybind(&mut self, name: &str)
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!"); }
pub fn mouse_position(&self) -> Vector2i
[src]
pub fn mouse_position(&self) -> Vector2i
Gets the current mouse position in pixels, relative to the top left corner of the window.
pub fn mouse_position_relative(&self) -> Vector2i
[src]
pub fn mouse_position_relative(&self) -> Vector2i
Gets the current mouse position in pixels, relative to last frame's mouse position.
pub fn mouse_wheel(&self) -> i32
[src]
pub fn mouse_wheel(&self) -> i32
Gets the current state of the mouse wheel. < 0: scrolling down
0: scrolling up
Trait Implementations
impl Default for InputManager
[src]
impl Default for InputManager
Auto Trait Implementations
impl Send for InputManager
impl Send for InputManager
impl Sync for InputManager
impl Sync for InputManager