Struct mini_gl_fb::breakout::BasicInput [−][src]
Used for MiniGlFb::glutin_handle_basic_input
.
Contains the current state of the window in a polling-like fashion.
Fields (Non-exhaustive)
Struct {{ .. }}
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.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
The current modifier keys that are being pressed.
resized: bool
This is set to true
when the window is resized outside of your callback. If you do not
update the buffer in your callback, you should still draw it if this is true
.
wait: bool
If this is set to true
by your callback, it will not be called as fast as possible, but
rather only when the input changes.
wakeups: Vec<Wakeup>
A record of all the Wakeup
s that are scheduled to happen. If your callback is being
called because of a wakeup, BasicInput::wakeup
will be set to Some(id)
where id
is
the unique identifier of the Wakeup
.
Wakeups can be scheduled using BasicInput::schedule_wakeup
. Wakeups can be cancelled
using BasicInput::cancel_wakeup
, or by removing the item from the Vec
.
wakeup: Option<Wakeup>
Indicates to your callback which Wakeup
it should be handling. Normally, it's okay to
ignore this, as it will always be None
unless you manually schedule wakeups using
BasicInput::schedule_wakeup
.
Implementations
impl BasicInput
[src]
pub fn mouse_pressed(&self, button: MouseButton) -> bool
[src]
If the mouse was pressed this last frame.
pub fn mouse_is_down(&self, button: MouseButton) -> bool
[src]
If the mouse is currently down.
pub fn mouse_released(&self, button: MouseButton) -> bool
[src]
If the mouse was released this last frame.
pub fn key_pressed(&self, button: VirtualKeyCode) -> bool
[src]
If the key was pressed this last frame.
pub fn key_is_down(&self, button: VirtualKeyCode) -> bool
[src]
If the key is currently down.
pub fn key_released(&self, button: VirtualKeyCode) -> bool
[src]
If the key was released this last frame.
pub fn schedule_wakeup(&mut self, when: Instant) -> u32
[src]
Given an Instant
in the future (or in the past, in which case it will be triggered
immediately), schedules a wakeup to be triggered then. Returns the ID of the wakeup, which
will be the ID of BasicInput::wakeup
if your callback is getting called by the wakeup.
pub fn reschedule_wakeup(&mut self, wakeup: Wakeup)
[src]
Reschedules a wakeup. It is perfectly valid to re-use IDs of wakeups that have already been
triggered; that is why BasicInput::wakeup
is a Wakeup
and not just a u32
.
pub fn cancel_wakeup(&mut self, id: u32) -> Option<Wakeup>
[src]
Cancels a previously scheduled Wakeup
by its ID. Returns the Wakeup
if it is found,
otherwise returns None
.
pub fn adjust_wakeup(&mut self, id: u32, when: Instant) -> bool
[src]
Trait Implementations
impl Clone for BasicInput
[src]
fn clone(&self) -> BasicInput
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for BasicInput
[src]
impl Default for BasicInput
[src]
fn default() -> BasicInput
[src]
impl PartialEq<BasicInput> for BasicInput
[src]
fn eq(&self, other: &BasicInput) -> bool
[src]
fn ne(&self, other: &BasicInput) -> bool
[src]
impl StructuralPartialEq for BasicInput
[src]
Auto Trait Implementations
impl RefUnwindSafe for BasicInput
impl Send for BasicInput
impl Sync for BasicInput
impl Unpin for BasicInput
impl UnwindSafe for BasicInput
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,