rktk_keymanager/interface/
state.rs1use macro_rules_attribute::apply;
2
3use super::common_derive;
4
5#[apply(common_derive)]
6pub struct KeymapInfo {
7 pub layer_count: u8,
8 pub max_tap_dance_key_count: u8,
9 pub max_tap_dance_repeat_count: u8,
10 pub oneshot_state_size: u8,
11}
12
13pub mod config {
14 use crate::macros::common_derive;
15 use macro_rules_attribute::apply;
16
17 #[apply(common_derive)]
19 pub struct StateConfig {
20 pub mouse: MouseConfig,
21 pub key_resolver: KeyResolverConfig,
22 }
23
24 #[apply(common_derive)]
25 pub struct MouseConfig {
26 pub auto_mouse_layer: u8,
27 pub auto_mouse_duration: u32,
28 pub auto_mouse_threshold: u8,
29 pub scroll_divider_x: i8,
30 pub scroll_divider_y: i8,
31 }
32
33 #[apply(common_derive)]
34 pub struct KeyResolverConfig {
35 pub tap_hold: TapHoldConfig,
36 pub tap_dance: TapDanceConfig,
37 pub combo: ComboConfig,
38 }
39
40 #[apply(common_derive)]
41 pub struct TapHoldConfig {
42 pub threshold: u32,
43 pub hold_on_other_key: bool,
44 }
45
46 #[apply(common_derive)]
47 pub struct TapDanceConfig {
48 pub threshold: u32,
49 }
50
51 #[apply(common_derive)]
52 pub struct ComboConfig {
53 pub threshold: u32,
54 }
55}
56
57pub mod input_event {
58 use crate::macros::common_derive;
59
60 use macro_rules_attribute::apply;
61
62 #[apply(common_derive)]
66 pub struct KeyChangeEvent {
67 pub col: u8,
68 pub row: u8,
69 pub pressed: bool,
70 }
71
72 #[derive(Copy)]
74 #[apply(common_derive)]
75 pub enum EncoderDirection {
76 Clockwise,
77 CounterClockwise,
78 }
79
80 #[apply(common_derive)]
81 pub enum InputEvent {
82 Key(KeyChangeEvent),
83 Mouse((i8, i8)),
84 Encoder((u8, EncoderDirection)),
85 None,
86 }
87}
88
89pub mod output_event {
90 use crate::{keycode::prelude::*, macros::common_derive};
91
92 use macro_rules_attribute::apply;
93
94 #[derive(Copy)]
95 #[apply(common_derive)]
96 pub enum EventType {
97 Pressed,
98 Pressing,
99 Released,
100 }
101
102 #[derive(Copy)]
103 #[apply(common_derive)]
104 pub enum OutputEvent {
105 Key((Key, EventType)),
106 Modifier((Modifier, EventType)),
107 MouseButton((Mouse, EventType)),
108 MediaKey((Media, EventType)),
109 Custom(u8, (u8, EventType)),
110 MouseMove((i8, i8)),
111 MouseScroll((i8, i8)),
112 }
113}