summaryrefslogtreecommitdiff
path: root/crates/renderer/src/input.rs
blob: f0536e94db7759732d08f7f44d3179eaa505012a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use device_query::DeviceQuery;

pub enum Command {
    None,
    Drawing,
    EraseAll,
}
pub struct Input {
    pub device: device_query::DeviceState,
}
impl Input {
    pub fn new() -> Self {
        Self {
            device: device_query::DeviceState::new(),
        }
    }
    pub fn get_mouse(&self) -> (i32, i32) {
        self.device.get_mouse().coords
    }
    pub fn get_command(&mut self) -> Command {
        let keys = self.device.get_keys();
        if keys.contains(&device_query::Keycode::LMeta) {
            Command::Drawing
        } else if keys.contains(&device_query::Keycode::RMeta) {
            Command::EraseAll
        } else {
            Command::None
        }
    }
}