Skip to content

Commit

Permalink
add sequence action
Browse files Browse the repository at this point in the history
this omits the filter and restore events from the original PR (didn't feel it was necessary): TeXitoi/keyberon#122
  • Loading branch information
Univa committed Dec 14, 2023
1 parent e764778 commit c8d83fb
Show file tree
Hide file tree
Showing 4 changed files with 416 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ A huge thanks goes to the following projects:
- For providing the logic for keyboard matrix and layouts
- [jtroo's `keyberon` fork](https://github.com/jtroo/kanata/tree/main/keyberon)
- For the implementation of extra layout actions, like one shot and tap dance keys
- [riskable and borisfaure](https://github.com/TeXitoi/keyberon/pull/122)
- For the implementation of sequences/macros in `keyberon`
- [simmsb's corne firmware](https://github.com/simmsb/keyboard)
- Very helpful reference for developing a keyboard firmware using [embassy-rs](https://github.com/embassy-rs/embassy)
- [TeXitoi's keyseebee project](https://github.com/TeXitoi/keyseebee)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ A huge thanks goes to the following projects:
- For powering the logic for keyboard matrix and layouts
- [jtroo's `keyberon` fork](https://github.com/jtroo/kanata/tree/main/keyberon)
- For the implementation of extra layout actions, like one shot and tap dance keys
- [riskable and borisfaure](https://github.com/TeXitoi/keyberon/pull/122)
- For the implementation of sequences/macros in `keyberon`
- [simmsb's corne firmware](https://github.com/simmsb/keyboard)
- Very helpful reference for developing a keyboard firmware using [embassy-rs](https://github.com/embassy-rs/embassy)
- [TeXitoi's keyseebee project](https://github.com/TeXitoi/keyseebee)
Expand Down
23 changes: 23 additions & 0 deletions keyberon/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,27 @@ where
pub config: TapDanceConfig,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// The different tyeps of actions we support for key sequences/macros
pub enum SequenceEvent<K>
where
K: 'static,
{
/// No operation action: just do nothing (a placeholder).
NoOp,
/// A keypress/keydown
Press(K),
/// Key release/keyup
Release(K),
/// A shortcut for `Press(K), Release(K)`
Tap(K),
/// For sequences that need to wait a bit before continuing. The number represents how long (in
/// ticks) this Delay will last for.
Delay(u16),
/// Cancels the running sequence and can be used to mark the end of a sequence.
Complete,
}

/// The different actions that can be done.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
Expand Down Expand Up @@ -283,6 +304,8 @@ where
/// - `timeout` ticks elapse since the last tap of the same tap-dance key
/// - the number of taps is equal to the length of `actions`.
TapDance(&'static TapDanceAction<T, K>),
/// An array of SequenceEvents that will be triggered (in order)
Sequence(&'static &'static [SequenceEvent<K>]),
/// Custom action.
///
/// Define a user defined action. This enum can be anything you
Expand Down
Loading

0 comments on commit c8d83fb

Please sign in to comment.