From 8fcc8dc1efd97354e45ad569f55825f3149a5be1 Mon Sep 17 00:00:00 2001 From: Haobo Gu Date: Wed, 15 Nov 2023 21:11:47 +0800 Subject: [PATCH] refactor(core): code/doc reformat Signed-off-by: Haobo Gu --- rmk/src/debounce.rs | 2 +- rmk/src/eeprom.rs | 2 +- rmk/src/via/keycode_convert.rs | 8 ++++---- rmk/src/via/process.rs | 12 ++++++++---- rmk/src/via/protocol.rs | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/rmk/src/debounce.rs b/rmk/src/debounce.rs index d76f3e25..62219589 100644 --- a/rmk/src/debounce.rs +++ b/rmk/src/debounce.rs @@ -67,7 +67,7 @@ impl return; } - // rmk uses 10khz tick, so the debounce threshold should * 10 + // Use 10khz tick, so the debounce threshold should * 10 if state.counter < DEBOUNCE_THRESHOLD * 10 { state.increase(elapsed_ms); return; diff --git a/rmk/src/eeprom.rs b/rmk/src/eeprom.rs index fc690617..f7569ac0 100644 --- a/rmk/src/eeprom.rs +++ b/rmk/src/eeprom.rs @@ -135,7 +135,7 @@ impl Eeprom { } Err(e) => { error!( - "Restore eeprom value at pos {:x} error: {:?}", + "Restore eeprom value at pos {:X} error: {:?}", eeprom.pos, e ); break; diff --git a/rmk/src/via/keycode_convert.rs b/rmk/src/via/keycode_convert.rs index b5ab1c2b..bd2eb50b 100644 --- a/rmk/src/via/keycode_convert.rs +++ b/rmk/src/via/keycode_convert.rs @@ -116,15 +116,15 @@ pub fn from_via_keycode(via_keycode: u16) -> KeyAction { KeyAction::No } 0x6000..=0x7FFF => { - // Modifier Tap/Hold - // The via equivalent of Modifier Tap/Hold is called Mod-tap, whose keycode representation is same with RMK + // Modifier tap/hold + // The via equivalent of Modifier tap/hold is called Mod-tap, whose keycode representation is same with RMK let keycode = KeyCode::from_primitive(via_keycode & 0x00FF); let modifier = ModifierCombination::from_bits(((via_keycode >> 8) & 0b11111) as u8); KeyAction::ModifierTapHold(Action::Key(keycode), modifier) } 0x4000..=0x4FFF => { - // Layer Tap/Hold - // The via equivalent of Modifier Tap/Hold is called Mod-tap, + // Layer tap/hold + // The via equivalent of Modifier tap/hold is called Mod-tap, let layer = (via_keycode >> 8) & 0xF; let keycode = KeyCode::from_primitive(via_keycode & 0x00FF); KeyAction::LayerTapHold(Action::Key(keycode), layer as u8) diff --git a/rmk/src/via/process.rs b/rmk/src/via/process.rs index c4bf427e..17b561d4 100644 --- a/rmk/src/via/process.rs +++ b/rmk/src/via/process.rs @@ -74,7 +74,7 @@ pub fn process_via_packet< Err(e) => error!("Invalid subcommand: {} of GetKeyboardValue", e.number), } } - ViaCommand::DynamicKeymapGetKeycode => { + ViaCommand::DynamicKeymapGetKeyCode => { let layer = report.output_data[1] as usize; let row = report.output_data[2] as usize; let col = report.output_data[3] as usize; @@ -86,7 +86,7 @@ pub fn process_via_packet< ); BigEndian::write_u16(&mut report.input_data[4..6], keycode); } - ViaCommand::DynamicKeymapSetKeycode => { + ViaCommand::DynamicKeymapSetKeyCode => { let layer = report.output_data[1] as usize; let row = report.output_data[2] as usize; let col = report.output_data[3] as usize; @@ -192,8 +192,12 @@ pub fn process_via_packet< *a = action; idx += 2; let current_offset = offset as usize + i; - let (row, col, layer) = get_position_from_offset(current_offset, row_num, col_num); - info!("Setting keymap buffer of offset: {}, row,col,layer: {},{},{}", offset, row, col, layer); + let (row, col, layer) = + get_position_from_offset(current_offset, row_num, col_num); + info!( + "Setting keymap buffer of offset: {}, row,col,layer: {},{},{}", + offset, row, col, layer + ); match eeprom { Some(e) => e.set_keymap_action(row, col, layer, action), None => (), diff --git a/rmk/src/via/protocol.rs b/rmk/src/via/protocol.rs index 9fcc6cd9..858ea88b 100644 --- a/rmk/src/via/protocol.rs +++ b/rmk/src/via/protocol.rs @@ -10,8 +10,8 @@ pub enum ViaCommand { GetProtocolVersion = 0x01, // always 0x01 GetKeyboardValue = 0x02, SetKeyboardValue = 0x03, - DynamicKeymapGetKeycode = 0x04, - DynamicKeymapSetKeycode = 0x05, + DynamicKeymapGetKeyCode = 0x04, + DynamicKeymapSetKeyCode = 0x05, DynamicKeymapReset = 0x06, CustomSetValue = 0x07, CustomGetValue = 0x08,