Skip to content

Commit

Permalink
feat(core): process unsupported keycodes no action
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Oct 31, 2023
1 parent fe40c37 commit f177d3e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion rmk/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl KeyAction {
0x0000
}
}
KeyAction::TapHold(_, _) => {
KeyAction::TapHold(_tap, _hold) => {
error!("Unsupported TapHold action: {:?}", self);
0x0000
}
Expand Down
12 changes: 10 additions & 2 deletions rmk/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,16 @@ impl<
KeyAction::OneShot(oneshot_action) => {
self.process_key_action_oneshot(oneshot_action).await
}
KeyAction::LayerTapHold(_, _) => todo!(),
KeyAction::ModifierTapHold(_, _) => todo!(),
KeyAction::LayerTapHold(tap_action, layer_num) => {
let layer_action = Action::LayerOn(layer_num);
self.process_key_action_tap_hold(tap_action, layer_action)
.await;
}
KeyAction::ModifierTapHold(tap_action, modifier) => {
let modifier_action = Action::Modifier(modifier);
self.process_key_action_tap_hold(tap_action, modifier_action)
.await;
}
}
}

Expand Down
32 changes: 20 additions & 12 deletions rmk/src/via/keycode_convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn to_via_keycode(key_action: KeyAction) -> u16 {

0x6000 | ((m.to_bits() as u16) << 8) | keycode
}
KeyAction::TapHold(_, _) => todo!(),
KeyAction::TapHold(_tap, _hold) => todo!(),
}
}

Expand Down Expand Up @@ -91,24 +91,29 @@ pub fn from_via_keycode(via_keycode: u16) -> KeyAction {
KeyAction::OneShot(Action::Modifier(m))
}
0x5700..=0x57FF => {
// Tap Dance
todo!()
// TODO: Tap Dance
warn!("Tap dance 0x{:X} not supported", via_keycode);
KeyAction::No
}
0x5C00..=0x5CFF => {
// QMK functions, such as reset, swap ctrl/caps, gui on, haptic, music, clicky, combo, RGB, etc
todo!()
// TODO: QMK functions, such as reset, swap ctrl/caps, gui on, haptic, music, clicky, combo, RGB, etc
warn!("QMK functions 0x{:X} not supported", via_keycode);
KeyAction::No
}
0x5D00..=0x5D0F => {
// DM Rec/Stop/Play
todo!()
// TODO: DM Rec/Stop/Play
warn!("DM Rec/Stop/Play 0x{:X} not supported", via_keycode);
KeyAction::No
}
0x5F12..=0x5F21 => {
// Macro 1-16
todo!()
// TODO: Macro 1-16
warn!("Macro 0x{:X} not supported", via_keycode);
KeyAction::No
}
0x5F80..=0x5F8F => {
// User 1-16
todo!()
// TODO: User 1-16
warn!("User 0x{:X} not supported", via_keycode);
KeyAction::No
}
0x6000..=0x7FFF => {
// Modifier Tap/Hold
Expand All @@ -125,7 +130,10 @@ pub fn from_via_keycode(via_keycode: u16) -> KeyAction {
KeyAction::LayerTapHold(Action::Key(keycode), layer as u8)
}

_ => KeyAction::No,
_ => {
warn!("Via keycode 0x{:X} is not processed", via_keycode);
KeyAction::No
}
}
}

Expand Down

0 comments on commit f177d3e

Please sign in to comment.