Skip to main content
RKTK API Docs RKTK Home Repo

rktk/home/runner/work/rktk/rktk/target/debug/build/rktk-65464ff039be715a/out/
config.rs

1
2        /// Configuration schema
3        pub mod schema {
4            use kmsm::interface::state::config::*;
5
6            #[derive(Debug, Clone, serde :: Serialize)]#[doc = " Root struct of the \"constant\" config"] pub struct ConstantConfig{  pub keyboard: KeyboardConstantConfig,  pub buffer: BufferSizeConfig,  pub key_manager: KeymanagerConstantConfig,  pub magnetic: MagneticConstantConfig, }
7#[derive(Debug, Clone, serde :: Serialize)] pub struct BufferSizeConfig{ #[doc = r" Size of the buffer used by rrp"] pub rrp: usize, #[doc = r" Size of the log channel buffer"] pub log_channel: usize, #[doc = r" Size of the split channel buffer"] pub split_channel: usize, #[doc = r" Size of the rgb command channel buffer"] pub rgb_channel: usize, #[doc = r" Size of the mouse event buffer"] pub mouse_event: usize, #[doc = r" Size of the keyboard event buffer"] pub keyboard_event: usize, #[doc = r" Size of the encoder event buffer"] pub encoder_event: usize, #[doc = r" Size of the magnetic switch calibration data buffer."] pub calibration: usize, }
8#[derive(Debug, Clone, serde :: Serialize)] pub struct KeyboardConstantConfig{ #[doc = r" The number of columns in the keyboard matrix."] pub cols: u8, #[doc = r" The number of rows in the keyboard matrix."] pub rows: u8, #[doc = r" The number of encoder keys."] pub encoder_count: u8, }
9#[derive(Debug, Clone, serde :: Serialize)] pub struct KeymanagerConstantConfig{  pub layer_count: u8,  pub normal_max_pressed_keys: usize,  pub oneshot_state_size: usize,  pub tap_dance_max_definitions: usize,  pub tap_dance_max_repeats: usize,  pub combo_key_max_definitions: usize,  pub combo_key_max_sources: usize, }
10#[derive(Debug, Clone, serde :: Serialize)]#[doc = " Root struct of the \"dynamic\" config"] pub struct DynamicConfig{  pub keyboard: KeyboardConfig,  pub rktk: RktkConfig,  pub key_manager: KeyManagerConfig,  pub magnetic: MagneticConfig, }
11#[derive(Debug, Clone, serde :: Serialize)]#[doc = " RKTK behavior config"] pub struct RktkConfig{  pub rgb: RktkRgbConfig,  pub role_detection: RktkRoleDetectionConfig, #[doc = r" Threshold for double tap (ms)."] pub double_tap_threshold: u64, #[doc = r" Default CPI value for mouse"] pub default_cpi: u16, #[doc =
12r" Swap the x and y values obtained from the mouse driver. This also affects the scroll direction."] pub swap_mouse_x_y: bool, #[doc = r" Default duration of auto mouse mode (ms)"] pub default_auto_mouse_duration: u32, #[doc = r" Time (ms) to wait for the next keyboard scan"] pub scan_interval_keyboard: u64, #[doc = r" Time (ms) to wait for the next mouse scan"] pub scan_interval_mouse: u64, #[doc = r" Time(ms) until the display is turned off if there is no activity"] pub display_timeout: u64, #[doc =
13r" rktk basically updates the keyboard state only when it receives an event from the hardware."] pub state_update_interval: u64, }
14#[derive(Debug, Clone, serde :: Serialize)]#[doc = " RKTK RGB config"] pub struct RktkRgbConfig{ #[doc = r" Time(ms) to wait for the next RGB pattern update"] pub pattern_update_interval: u64, #[doc = r" Initial RGB blightness"] pub default_brightness: f32, }
15#[derive(Debug, Clone, serde :: Serialize)]#[doc = " RKTK role detection config"] pub struct RktkRoleDetectionConfig{ #[doc = r" Timeout for detecting split USB connection (ms)."] pub usb_timeout: u64,  pub timeout_behavior: RktkRoleDetectionTimeoutBehavior, #[doc = r" Method for role detection"] pub method: RktkRoleDetectionMethod, }
16#[derive(Debug, Clone, serde :: Serialize)] pub enum RktkRoleDetectionMethod{  Auto, ForceMaster, ForceSlave, }
17#[derive(Debug, Clone, serde :: Serialize)] pub enum RktkRoleDetectionTimeoutBehavior{  None, ForceMaster, ForceSlave, }
18#[derive(Debug, Clone, serde :: Serialize)]#[doc =
19r#"
20Keyboard layout and informations.
21
22This struct is used to
23- Defines keyboard basic informations (ex: name, cols, rows, ...)
24- Defines keyboard physical layout which is used by remapper (layout property)
25
26# Coordination of the keyboard matrix
27
28The rktk coordinate system has the top left as (0,0), and the coordinate values increase toward the bottom right.
29
30## Split keyboard coordinates
31For `col` in keyboard config, specify the coordinates of the entire keyboard.
32In other words, for a split keyboard with 7 columns on the left hand side and 7 columns on the right hand side, specify 14.
33
34Internally, the key scan driver returns the coordinates of "only one hand." In other words, in this case, x=0-6.
35Therefore, it is necessary to convert the coordinates received from the key scan driver into the coordinates of both hands,
36and for this purpose the `split_right_shift` property is used.
37
38Below is an example of a split keyboard with 14 columns and 4 rows.
39```ignored
40           [    Left    ]   [     Right     ]
41           0 1 2 3 4 5 6    0 1 2  3  4  5  6 ← One-handed coordinates
42                            ↓ split_right_shift=7 (or None)
43col=14 →   0 1 2 3 4 5 6    7 8 9 10 11 12 13 ← Two-handed coordinates
44         0 _ Q W E R T _    _ Y U  I  O  P  _
45         1 ...
46         2 ...
47         3 ...
48         ↑ row=4
49```"#] pub struct KeyboardConfig{ #[doc = r" The name of the keyboard."] pub name: &'static str, #[doc =
50r#"
51Defines the layout of the keyboard used in the remapper.
52
53This is a JSON object that represents the layout of the keyboard and compatible with via's
54json layout format."#] pub layout: Option<&'static str>, #[doc =
55r#"
56 A number representing the row number that the right col starts on in a split keyboard.
57 
58 If not set, `cols / 2` will be automatically set,
59 so there is no need to set it if the number of columns on the right and left sides is the same.
60 Also, there is no need to set it in the case of a non-split keyboard, as it is not used."#] pub split_right_shift: Option<u8>, }
61#[derive(Debug, Clone, serde :: Serialize)]#[doc = r#"
62Config for key manager.
63"#] pub struct KeyManagerConfig{  pub mouse: MouseConfig,  pub key_resolver: KeyResolverConfig, }
64#[derive(Debug, Clone, serde :: Serialize)] pub struct MagneticConstantConfig{  pub enabled: bool, }
65#[derive(Debug, Clone, serde :: Serialize)] pub struct MagneticConfig{ #[doc = r" Default press distance (normalized 0-65535)"] pub press_dist: u16, #[doc = r" Default release distance (normalized 0-65535)"] pub release_dist: u16, }
66        }
67        mod generate_config {
68            use super::schema::*;
69            use kmsm::interface::state::config::*;
70
71            #[allow(clippy::redundant_static_lifetimes)] #[doc = "Config generated from `constant` key of json"] pub const CONST_CONFIG: ConstantConfig = ConstantConfig { keyboard: KeyboardConstantConfig { cols: 14u8, rows: 5u8, encoder_count: 0u8, }, buffer: BufferSizeConfig { rrp: 512usize, log_channel: 64usize, split_channel: 64usize, rgb_channel: 3usize, mouse_event: 4usize, keyboard_event: 4usize, encoder_event: 4usize, calibration: 512usize, }, key_manager: KeymanagerConstantConfig { layer_count: 5u8, normal_max_pressed_keys: 8usize, oneshot_state_size: 4usize, tap_dance_max_definitions: 2usize, tap_dance_max_repeats: 4usize, combo_key_max_definitions: 2usize, combo_key_max_sources: 3usize, }, magnetic: MagneticConstantConfig { enabled: false, }, };
72
73            #[allow(clippy::redundant_static_lifetimes)] #[doc = "Config generated from `dynamic` key of json"] pub const DYNAMIC_CONFIG_FROM_FILE: DynamicConfig = DynamicConfig { keyboard: KeyboardConfig { name: "test-keyboard", layout: None, split_right_shift: None, }, rktk: RktkConfig { rgb: RktkRgbConfig { pattern_update_interval: 16u64, default_brightness: 0.5f32, }, role_detection: RktkRoleDetectionConfig { usb_timeout: 1000u64, timeout_behavior: RktkRoleDetectionTimeoutBehavior::None, method: RktkRoleDetectionMethod::Auto, }, double_tap_threshold: 500u64, default_cpi: 600u16, swap_mouse_x_y: false, default_auto_mouse_duration: 500u32, scan_interval_keyboard: 5u64, scan_interval_mouse: 5u64, display_timeout: 20000u64, state_update_interval: 10u64, }, key_manager: KeyManagerConfig { mouse: MouseConfig { auto_mouse_layer: 1u8, auto_mouse_duration: 500u32, auto_mouse_threshold: 0u8, scroll_divider_x: 20i8, scroll_divider_y: -12i8, }, key_resolver: KeyResolverConfig { tap_hold: TapHoldConfig { threshold: 200u32, hold_on_other_key: true, }, tap_dance: TapDanceConfig { threshold: 200u32, }, combo: ComboConfig { threshold: 50u32, }, }, }, magnetic: MagneticConfig { press_dist: 1000u16, release_dist: 1000u16, }, };
74        }
75
76        pub use generate_config::{CONST_CONFIG, DYNAMIC_CONFIG_FROM_FILE};
77