From f177d3e88ae7d82b23439764d016e7576cf76b0e Mon Sep 17 00:00:00 2001 From: Haobo Gu Date: Tue, 31 Oct 2023 18:47:14 +0800 Subject: [PATCH] feat(core): process unsupported keycodes no action Signed-off-by: Haobo Gu --- rmk/src/action.rs | 2 +- rmk/src/keyboard.rs | 12 ++++++++++-- rmk/src/via/keycode_convert.rs | 32 ++++++++++++++++++++------------ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/rmk/src/action.rs b/rmk/src/action.rs index 5b39e915..261ee1cd 100644 --- a/rmk/src/action.rs +++ b/rmk/src/action.rs @@ -93,7 +93,7 @@ impl KeyAction { 0x0000 } } - KeyAction::TapHold(_, _) => { + KeyAction::TapHold(_tap, _hold) => { error!("Unsupported TapHold action: {:?}", self); 0x0000 } diff --git a/rmk/src/keyboard.rs b/rmk/src/keyboard.rs index 2f65776c..3e25cdbd 100644 --- a/rmk/src/keyboard.rs +++ b/rmk/src/keyboard.rs @@ -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; + } } } diff --git a/rmk/src/via/keycode_convert.rs b/rmk/src/via/keycode_convert.rs index 6a9d5664..b5ab1c2b 100644 --- a/rmk/src/via/keycode_convert.rs +++ b/rmk/src/via/keycode_convert.rs @@ -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!(), } } @@ -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 @@ -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 + } } }