Struct mini_gl_fb::breakout::BasicInput [−][src]
pub struct BasicInput { pub mouse_pos: (f64, f64), pub mouse: HashMap<MouseButton, (bool, bool)>, pub keys: HashMap<VirtualKeyCode, (bool, bool)>, pub modifiers: ModifiersState, pub resized: bool, }
Fields
mouse_pos: (f64, f64)
The mouse position in buffer coordinates.
The bottom left of the window is (0, 0). Pixel centers are at multiples of (0.5, 0.5). If you want to use this to index into your buffer, in general the following is sufficient:
- clamp each coordinate to the half-open range [0.0, buffer_size)
- take the floor of each component
- cast to usize and compute an index:
let index = y * WIDTH + x
mouse: HashMap<MouseButton, (bool, bool)>
Stores whether a mouse button was down and is down, in that order.
If a button has not been pressed yet it will not be in the map.
keys: HashMap<VirtualKeyCode, (bool, bool)>
Stores the previous and current "key down" states, in that order.
If a key has not been pressed yet it will not be in the map.
modifiers: ModifiersState
resized: bool
Methods
impl BasicInput
[src]
impl BasicInput
pub fn mouse_pressed(&self, button: MouseButton) -> bool
[src]
pub fn mouse_pressed(&self, button: MouseButton) -> bool
If the mouse was pressed this last frame.
pub fn mouse_is_down(&self, button: MouseButton) -> bool
[src]
pub fn mouse_is_down(&self, button: MouseButton) -> bool
If the mouse is currently down.
pub fn mouse_released(&self, button: MouseButton) -> bool
[src]
pub fn mouse_released(&self, button: MouseButton) -> bool
If the mouse was released this last frame.
pub fn key_pressed(&self, button: VirtualKeyCode) -> bool
[src]
pub fn key_pressed(&self, button: VirtualKeyCode) -> bool
If the key was pressed this last frame.
pub fn key_is_down(&self, button: VirtualKeyCode) -> bool
[src]
pub fn key_is_down(&self, button: VirtualKeyCode) -> bool
If the key is currently down.
pub fn key_released(&self, button: VirtualKeyCode) -> bool
[src]
pub fn key_released(&self, button: VirtualKeyCode) -> bool
If the key was released this last frame.
Auto Trait Implementations
impl Send for BasicInput
impl Send for BasicInput
impl Sync for BasicInput
impl Sync for BasicInput