From 0660d2b357246897938e27006a9e6b8d1c5a123f Mon Sep 17 00:00:00 2001 From: Guillaume Pinot Date: Fri, 11 Dec 2020 22:10:40 +0100 Subject: [PATCH] CHANGELOG and more doc for custom actionmagnet:?xt=urn:btih:a6721ad2e6a3aadba5caf0474998e1c2eb69af11&dn=Les.Blagues.De.Toto.2020.FRENCH.1080p.WEB.x264-PREUMS.mkv&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.opentrackr.org:1337/announce --- CHANGELOG.md | 7 +++++++ src/action.rs | 5 +++++ src/layout.rs | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aef2bcc..7d655ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ Breaking changes: * `Action::HoldTap` now takes a configuration for different behaviors. * `Action::HoldTap` now takes the `tap_hold_interval` field. Not implemented yet. +* `Action` is now generic, for the `Action::Custom(T)` variant, + allowing custom action to be handled outside of keyberon. This + functionality can be used to drive non keyboard actions, as reset + the microcontroller, drive leds (for backlight or underglow for + example), manage a mouse emulation, or any other ideas you can + have. As there is a default value for the type parameter, the update + should be transparent. # v0.1.1 diff --git a/src/action.rs b/src/action.rs index 4a05bd1..12500d6 100644 --- a/src/action.rs +++ b/src/action.rs @@ -90,6 +90,11 @@ where tap_hold_interval: u16, }, /// Custom action. + /// + /// Define a user defined action. This enum can be anything you + /// want, as long as it has the `'static` lifetime. It can be used + /// to drive any non keyboard related actions that you might + /// manage with key events. Custom(T), } impl Action { diff --git a/src/layout.rs b/src/layout.rs index 17cff1b..a3719ad 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -274,7 +274,8 @@ impl Layout { /// /// This method must be called regularly, typically every millisecond. /// - /// Returns an iterator on the current key code state. + /// Returns the corresponding `CustomEvent`, allowing to manage + /// custom actions thanks to the `Action::Custom` variant. pub fn tick<'a>(&'a mut self) -> CustomEvent { self.states = self.states.iter().filter_map(State::tick).collect(); self.stacked.iter_mut().for_each(Stacked::tick);