Skip to content

Commit

Permalink
Macro support (#1)
Browse files Browse the repository at this point in the history
* Fixed description and updated the either dependency to 1.6

* Added support for Sequence Actions (aka macros) whereby multiple key events are executed in succession.

* Added support for Sequence Actions (aka macros) whereby multiple key events are executed in succession.

* Modified per TeXitoi's instructions (as best I understood them) and also added a new Delay() feature that lets you put arbitrary delays between sequence (key macro) events.

* Removed some leftover commented-out cruft

* Made some changes to make Clippy happy.

* Unit tests for sequences and improved tick start

* Minor fixes to make Clippy happy

* Support for sequences of nearly limitless length!

* Make Clippy happy

* Changed do_action() to make Clippy happy

* Fixed a bug where Delay() wasn't working properly

* Added the ability to cancel running sequences
as well as the ability to use a `Complete` as a sort of "release all".

* Fixed an edge case with CancelSequence

* Added `SequenceEvent::Tap`
as a shortcut for `Press(),Release()`

* 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

* Changed how sequences are processed (MUCH simpler).

Added support for multiple simultaneous sequences executed at once (max 4).

Renamed CancelSequence to CancelSequences since we now do up to 4 at once.

* Added SequenceEvent back to layout.rs (got removed with last merge of upstream)

Co-authored-by: Riskable <[email protected]>
Co-authored-by: Guillaume Pinot <[email protected]>
  • Loading branch information
3 people committed Sep 27, 2021
1 parent 1e7e0fb commit 5cbba47
Show file tree
Hide file tree
Showing 2 changed files with 364 additions and 2 deletions.
39 changes: 38 additions & 1 deletion src/action.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
//! The different actions that can be done.
//! The different actions that can be executed via any given key.

use crate::key_code::KeyCode;

/// The different types of actions we support for key sequences/macros
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum SequenceEvent {
/// No operation action: just do nothing (a placeholder).
NoOp,
/// A keypress/keydown
Press(KeyCode),
/// Key release/keyup
Release(KeyCode),
/// A shortcut for `Press(KeyCode), Release(KeyCode)`
Tap(KeyCode),
/// For sequences that need to wait a bit before continuing
Delay {
/// How long (in ticks) this Delay will last
duration: u32, // NOTE: This isn't a u16 because that's only max ~65 seconds (assuming 1000 ticks/sec)
},
/// A marker that indicates there's more of the macro than would fit
/// in the 'sequenced' ArrayDeque
Continue {
/// The current chunk
index: usize,
/// The full list of Sequence Events (that aren't Continue())
events: &'static [SequenceEvent],
},
/// Cancels the running sequence and can be used to mark the end of a sequence
/// instead of using a number of Release() events
Complete,
}

/// Behavior configuration of HoldTap.
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
Expand Down Expand Up @@ -89,6 +119,13 @@ where
/// update, set this to 0.
tap_hold_interval: u16,
},
/// A sequence of SequenceEvents
Sequence {
/// An array of SequenceEvents that will be triggered (in order)
events: &'static [SequenceEvent],
},
/// Cancels any running sequences
CancelSequences,
/// Custom action.
///
/// Define a user defined action. This enum can be anything you
Expand Down
Loading

0 comments on commit 5cbba47

Please sign in to comment.