Trait bevy_doryen::doryen::InputApi
source · pub trait InputApi {
// Required methods
fn key(&self, key: &str) -> bool;
fn key_pressed(&mut self, key: &str) -> bool;
fn keys_pressed(&self) -> Keys<'_> ⓘ;
fn key_released(&mut self, key: &str) -> bool;
fn keys_released(&self) -> Keys<'_> ⓘ;
fn text(&self) -> String;
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);
fn close_requested(&self) -> bool;
}
Expand description
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§
sourcefn key_pressed(&mut self, key: &str) -> bool
fn key_pressed(&mut self, key: &str) -> bool
return true if a key was pressed since last update.
sourcefn keys_pressed(&self) -> Keys<'_> ⓘ
fn keys_pressed(&self) -> Keys<'_> ⓘ
return an iterator over all the keys that were pressed since last update.
sourcefn key_released(&mut self, key: &str) -> bool
fn key_released(&mut self, key: &str) -> bool
return true if a key was released since last update.
sourcefn keys_released(&self) -> Keys<'_> ⓘ
fn keys_released(&self) -> Keys<'_> ⓘ
return an iterator over all the keys that were released since last update.
return the current status of a mouse button (true if pressed)
return true if a mouse button was pressed since last update.
return true if a mouse button was released since last update.
sourcefn mouse_pos(&self) -> (f32, f32)
fn mouse_pos(&self) -> (f32, f32)
return the current mouse position in console cells coordinates (float value to have subcell precision)
sourcefn close_requested(&self) -> bool
fn close_requested(&self) -> bool
Whether the window close button was clicked