Skip to content

Commit c8d83fb

Browse files
committed
add sequence action
this omits the filter and restore events from the original PR (didn't feel it was necessary): TeXitoi/keyberon#122
1 parent e764778 commit c8d83fb

4 files changed

Lines changed: 416 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ A huge thanks goes to the following projects:
9292
- For providing the logic for keyboard matrix and layouts
9393
- [jtroo's `keyberon` fork](https://github.com/jtroo/kanata/tree/main/keyberon)
9494
- For the implementation of extra layout actions, like one shot and tap dance keys
95+
- [riskable and borisfaure](https://github.com/TeXitoi/keyberon/pull/122)
96+
- For the implementation of sequences/macros in `keyberon`
9597
- [simmsb's corne firmware](https://github.com/simmsb/keyboard)
9698
- Very helpful reference for developing a keyboard firmware using [embassy-rs](https://github.com/embassy-rs/embassy)
9799
- [TeXitoi's keyseebee project](https://github.com/TeXitoi/keyseebee)

docs/src/content/docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ A huge thanks goes to the following projects:
8989
- For powering the logic for keyboard matrix and layouts
9090
- [jtroo's `keyberon` fork](https://github.com/jtroo/kanata/tree/main/keyberon)
9191
- For the implementation of extra layout actions, like one shot and tap dance keys
92+
- [riskable and borisfaure](https://github.com/TeXitoi/keyberon/pull/122)
93+
- For the implementation of sequences/macros in `keyberon`
9294
- [simmsb's corne firmware](https://github.com/simmsb/keyboard)
9395
- Very helpful reference for developing a keyboard firmware using [embassy-rs](https://github.com/embassy-rs/embassy)
9496
- [TeXitoi's keyseebee project](https://github.com/TeXitoi/keyseebee)

keyberon/src/action.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ where
231231
pub config: TapDanceConfig,
232232
}
233233

234+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
235+
/// The different tyeps of actions we support for key sequences/macros
236+
pub enum SequenceEvent<K>
237+
where
238+
K: 'static,
239+
{
240+
/// No operation action: just do nothing (a placeholder).
241+
NoOp,
242+
/// A keypress/keydown
243+
Press(K),
244+
/// Key release/keyup
245+
Release(K),
246+
/// A shortcut for `Press(K), Release(K)`
247+
Tap(K),
248+
/// For sequences that need to wait a bit before continuing. The number represents how long (in
249+
/// ticks) this Delay will last for.
250+
Delay(u16),
251+
/// Cancels the running sequence and can be used to mark the end of a sequence.
252+
Complete,
253+
}
254+
234255
/// The different actions that can be done.
235256
#[non_exhaustive]
236257
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
@@ -283,6 +304,8 @@ where
283304
/// - `timeout` ticks elapse since the last tap of the same tap-dance key
284305
/// - the number of taps is equal to the length of `actions`.
285306
TapDance(&'static TapDanceAction<T, K>),
307+
/// An array of SequenceEvents that will be triggered (in order)
308+
Sequence(&'static &'static [SequenceEvent<K>]),
286309
/// Custom action.
287310
///
288311
/// Define a user defined action. This enum can be anything you

0 commit comments

Comments
 (0)