Skip to content

Commit

Permalink
refactor(core): code/doc reformat
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Nov 15, 2023
1 parent 83bb971 commit 8fcc8dc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rmk/src/debounce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<const INPUT_PIN_NUM: usize, const OUTPUT_PIN_NUM: usize>
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;
Expand Down
2 changes: 1 addition & 1 deletion rmk/src/eeprom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<F: NorFlash, const EEPROM_SIZE: usize> Eeprom<F, EEPROM_SIZE> {
}
Err(e) => {
error!(
"Restore eeprom value at pos {:x} error: {:?}",
"Restore eeprom value at pos {:X} error: {:?}",
eeprom.pos, e
);
break;
Expand Down
8 changes: 4 additions & 4 deletions rmk/src/via/keycode_convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions rmk/src/via/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 => (),
Expand Down
4 changes: 2 additions & 2 deletions rmk/src/via/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8fcc8dc

Please sign in to comment.