#winit #input #helper #state #cache

winit_input_helper

Processes winit events, allowing input state to be queried at any time

6 releases

✓ Uses Rust 2018 edition

0.3.0 Mar 12, 2019
0.2.1 Jan 10, 2019
0.2.0 Nov 8, 2018
0.1.2 Oct 26, 2018

#39 in Operating systems

Download history 29/week @ 2018-11-27 16/week @ 2018-12-04 16/week @ 2018-12-11 53/week @ 2018-12-18 7/week @ 2018-12-25 14/week @ 2019-01-01 19/week @ 2019-01-08 17/week @ 2019-01-15 4/week @ 2019-01-22 7/week @ 2019-01-29 3/week @ 2019-02-05 6/week @ 2019-02-12 11/week @ 2019-02-19 16/week @ 2019-02-26 6/week @ 2019-03-05

56 downloads per month
Used in 1 crate

MIT license

19KB
313 lines

Winit Input Helper

Build Status dependency status Crates.io Docs

Processes and store winit events, allowing input state to be queried at any time.

How to use

The WinitInputHelper struct takes events via the update or update_from_vec methods. The current input state can then be accessed via methods such as key_pressed, key_released, key_held, mouse, mouse_diff etc.

To see all available methods look at docs.rs

extern crate winit;
extern crate winit_input_helper;

use winit::{EventsLoop, VirtualKeyCode};
use winit_input_helper::WinitInputHelper;

fn main() {
    let mut input = WinitInputHelper::new();

    let mut events_loop = EventsLoop::new();
    let _window = winit::WindowBuilder::new().build(&events_loop).unwrap();

    loop {
        // call this once per loop
        input.update(&mut events_loop);

        // call these as many times as you want
        if input.key_pressed(VirtualKeyCode::A) {
            println!("The 'A' key was pressed on the keyboard");
        }
    }
}

Dependencies

~2MB
~37K SLoC