Struct mini_gl_fb::breakout::BasicInput [−][src]
#[non_exhaustive]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, pub wait: bool, pub wakeups: Vec<Wakeup>, pub wakeup: Option<Wakeup>, // some fields omitted }
Expand description
Used for MiniGlFb::glutin_handle_basic_input
.
Contains the current state of the window in a polling-like fashion.
Fields (Non-exhaustive)
This struct is marked as 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
If the mouse was pressed this last frame.
If the mouse is currently down.
If the mouse was released this last frame.
If the key was pressed this last frame.
If the key is currently down.
If the key was released this last frame.
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.
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
.
Trait Implementations
Returns the “default value” for a type. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more