Skip to content

Commit

Permalink
feat(macro): add input device toml config
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Dec 26, 2024
1 parent 2a186c7 commit 5a91d3a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions rmk-macro/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct KeyboardTomlConfig {
pub dependency: Option<DependencyConfig>,
/// Split config
pub split: Option<SplitConfig>,
/// Input device config
pub input_device: Option<InputDeviceConfig>,
}

/// Configurations for keyboard info
Expand Down Expand Up @@ -185,7 +187,10 @@ pub struct SplitBoardConfig {
pub ble_addr: Option<[u8; 6]>,
/// Serial config, the vector length should be 1 for peripheral
pub serial: Option<Vec<SerialConfig>>,
/// Matrix config for the split
pub matrix: MatrixConfig,
/// Input device config for the split
pub input_device: InputDeviceConfig,
}

/// Serial port config
Expand Down Expand Up @@ -220,3 +225,21 @@ fn parse_duration_millis<'de, D: de::Deserializer<'de>>(deserializer: D) -> Resu
other => Err(de::Error::custom(format!("Invalid unit \"{other}\" in [one_shot.timeout]: unit part must be either \"s\" or \"ms\""))),
}
}

/// Configurations for input devices
///
#[derive(Clone, Debug, Default, Deserialize)]
pub struct InputDeviceConfig {
pub encoder: Option<Vec<EncoderConfig>>,
}

#[derive(Clone, Debug, Default, Deserialize)]
pub struct EncoderConfig {
pub pin_a: String,
pub pin_b: String,
pub pin_btn: Option<String>,
pub resolution: Option<u8>,
pub clockwise_pos: (u8, u8),
pub counter_clockwise_pos: (u8, u8),
pub press_pos: Option<(u8, u8)>,
}

0 comments on commit 5a91d3a

Please sign in to comment.