Skip to content

Commit

Permalink
doc: add press/release-only+toggle cfg sample
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo committed Jun 12, 2024
1 parent d2db36e commit c85002e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cfg_samples/key-toggle_press-only_release-only.kbd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#|

This configuration showcases all of:
- key toggle
- press-only
- release-only

|#

(deftemplate toggle-key (vkey-name output-key alias)
(defvirtualkeys $vkey-name $output-key)
(defalias $alias (on-press toggle-vkey $vkey-name))
)

(deftemplate press-only-release-only-pair
(vkey-name output-key press-alias release-alias)
(defvirtualkeys $vkey-name $output-key)
(defalias $press-alias (on-press press-vkey $vkey-name))
(defalias $release-alias (on-press release-vkey $vkey-name))
)

(template-expand toggle-key v-lctl lctl lcl)
(template-expand toggle-key v-rctl rctl rcl)

;; t! is a short form of template-expand
(t! press-only-release-only-pair v-lalt lalt p-a r-a)

(defsrc
lctl rctl lalt ralt
)

(deflayer base
@lcl @rcl @p-a @r-a
)
13 changes: 13 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ fn parse_home_row_mods() {
.unwrap();
}

#[test]
fn parse_press_release_toggle_vkeys() {
init_log();
let _lk = match CFG_PARSE_LOCK.lock() {
Ok(guard) => guard,
Err(poisoned) => poisoned.into_inner(),
};
new_from_file(&std::path::PathBuf::from(
"./cfg_samples/key-toggle_press-only_release-only.kbd",
))
.unwrap();
}

#[test]
fn sizeof_state() {
init_log();
Expand Down

0 comments on commit c85002e

Please sign in to comment.