[][src]Trait doryen_rs::InputApi

pub trait InputApi {
    fn key(&self, key: &str) -> bool;
fn key_pressed(&mut self, key: &str) -> bool;
fn key_released(&mut self, key: &str) -> bool;
fn mouse_button(&self, num: usize) -> bool;
fn mouse_button_pressed(&mut self, num: usize) -> bool;
fn mouse_button_released(&mut self, num: usize) -> bool;
fn mouse_pos(&self) -> (f32, f32); }

Provides information about user input. Possible values for the key scancode parameter can be found in unrust/uni-app's translate_scan_code function. Warning, there are some slight variations from one OS to another, for example the Command, F13, F14, F15 keys only exist on Mac.

State functions like InputApi::key, InputApi::mouse_button and InputApi::mouse_pos always work. On another hand, pressed/released event functions should be called only in the update function.

Required methods

fn key(&self, key: &str) -> bool

return the current status of a key (true if pressed)

fn key_pressed(&mut self, key: &str) -> bool

return true if a key was pressed since last update.

fn key_released(&mut self, key: &str) -> bool

return true if a key was released since last update.

fn mouse_button(&self, num: usize) -> bool

return the current status of a mouse button (true if pressed)

fn mouse_button_pressed(&mut self, num: usize) -> bool

return true if a mouse button was pressed since last update.

fn mouse_button_released(&mut self, num: usize) -> bool

return true if a mouse button was released since last update.

fn mouse_pos(&self) -> (f32, f32)

return the current mouse position in console cells coordinates (float value to have subcell precision)

Loading content...

Implementors

Loading content...