Skip to content

Commit

Permalink
refactor: add row2col to matrix 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 25, 2024
1 parent 9ecc833 commit 34e03de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rmk-macro/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub enum MatrixType {
direct_pin,
}

#[allow(unused)]
#[derive(Clone, Debug, Default, Deserialize)]
pub struct MatrixConfig {
#[serde(default)]
Expand All @@ -65,6 +66,8 @@ pub struct MatrixConfig {
pub direct_pins: Option<Vec<Vec<String>>>,
#[serde(default = "default_true")]
pub direct_pin_low_active: bool,
#[serde(default = "default_false")]
pub row2col: bool,
}

/// Config for storage
Expand Down Expand Up @@ -200,7 +203,11 @@ pub struct SerialConfig {
#[derive(Clone, Debug, Deserialize)]
pub struct DurationMillis(#[serde(deserialize_with = "parse_duration_millis")] pub u64);

fn default_true() -> bool {
const fn default_true() -> bool {
true
}

const fn default_false() -> bool {
true
}

Expand Down
6 changes: 6 additions & 0 deletions rmk-macro/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub(crate) fn parse_keyboard_mod(item_mod: ItemMod) -> TokenStream2 {
Err(e) => return e,
};

if let Some(m) = toml_config.clone().matrix {
if m.row2col {
eprintln!("row2col is enabled, please ensure that you have updated your Cargo.toml, disabled default features(col2row is enabled as default feature)");
}
}

let keyboard_config = match KeyboardConfig::new(toml_config) {
Ok(c) => c,
Err(e) => return e,
Expand Down

0 comments on commit 34e03de

Please sign in to comment.