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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Key representations
//!
use serde::{
Deserialize,
Serialize,
};
use newtype::NewType;
use crate::keycode::KeyCode;
/// The matrix position of a key
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy, Ord, PartialOrd)]
pub struct KeyPos {
/// The "pulled" line of the key
pub x: u8,
/// The "read" line of the key
pub y: u8,
}
/// The state of a key
///
/// `true` == "pressed"
///
/// `false` == "not pressed"
#[derive(Serialize, Deserialize, NewType, Debug, PartialEq, Eq, Clone, Copy)]
pub struct KeyState(pub bool);
/// A physical key's position and state
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)]
pub struct PhysKey {
/// The position of the key
pub pos: KeyPos,
/// The state of the key
pub state: KeyState,
}
/// A physical key with board information
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)]
pub struct ModuleKey {
/// The module the key belongs to
pub module: u8,
/// They key's physical position and state
pub key: PhysKey,
}
/// A resolved key with a KeyCode
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)]
pub struct LogiKey {
/// The actual keycode
pub code: KeyCode,
/// The state of the key
pub state: KeyState,
}