Skip to content

Commit

Permalink
feat(core): don't trigger fast tap for the same key
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <[email protected]>
  • Loading branch information
HaoboGu committed Dec 3, 2024
1 parent 887b6ff commit 39a9c60
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rmk/src/keyboard.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::config::BehaviorConfig;
use crate::{
action::{Action, KeyAction},
hid::{ConnectionType, HidWriterWrapper},
Expand All @@ -17,7 +18,6 @@ use embassy_sync::{
use embassy_time::{Instant, Timer};
use heapless::{FnvIndexMap, Vec};
use postcard::experimental::max_size::MaxSize;
use crate::config::BehaviorConfig;
use serde::{Deserialize, Serialize};
use usbd_hid::descriptor::KeyboardReport;

Expand Down Expand Up @@ -485,9 +485,12 @@ impl<'a, const ROW: usize, const COL: usize, const NUM_LAYER: usize>
key_event: KeyEvent,
) {
if self.behavior.tap_hold.enable_hrm {
// If HRM is enabled, check whether the key is in key streak
// If HRM is enabled, check whether it's a different key is in key streak
if let Some(last_release_time) = self.last_release.2 {
if key_event.pressed {
if key_event.pressed
&& !(key_event.row == self.last_release.0.row
&& key_event.col == self.last_release.0.col)
{
if last_release_time.elapsed() < self.behavior.tap_hold.prior_idle_time {
// The previous key is released within `prior_idle_time`, it's in key streak
debug!("Key streak detected, trigger tap action");
Expand Down

0 comments on commit 39a9c60

Please sign in to comment.