1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
extern crate flywheel;
use flywheel::*;

pub fn keybind_press_handler(button: &Button, keys: &mut HashMap<Key, &mut bool>) {
    keybind_handler(button, keys, true);
}
pub fn keybind_release_handler(button: &Button, keys: &mut HashMap<Key, &mut bool>) {
    keybind_handler(button, keys, false);
}
fn keybind_handler(button: &Button, keys: &mut HashMap<Key, &mut bool>, state: bool) {
    if let &Button::Keyboard(key) = button {
        match keys.get_mut(&key) {
            Some(target) => **target = state,
            None => {}
        }
    }
}