diff options
Diffstat (limited to 'users/callum/oneshot.h')
| -rw-r--r-- | users/callum/oneshot.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/users/callum/oneshot.h b/users/callum/oneshot.h new file mode 100644 index 000000000..a6b8e1774 --- /dev/null +++ b/users/callum/oneshot.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include QMK_KEYBOARD_H | ||
| 4 | |||
| 5 | // Represents the four states a oneshot key can be in | ||
| 6 | typedef enum { | ||
| 7 | os_up_unqueued, | ||
| 8 | os_up_queued, | ||
| 9 | os_down_unused, | ||
| 10 | os_down_used, | ||
| 11 | } oneshot_state; | ||
| 12 | |||
| 13 | // Custom oneshot mod implementation that doesn't rely on timers. If a mod is | ||
| 14 | // used while it is held it will be unregistered on keyup as normal, otherwise | ||
| 15 | // it will be queued and only released after the next non-mod keyup. | ||
| 16 | void update_oneshot( | ||
| 17 | oneshot_state *state, | ||
| 18 | uint16_t mod, | ||
| 19 | uint16_t trigger, | ||
| 20 | uint16_t keycode, | ||
| 21 | keyrecord_t *record | ||
| 22 | ); | ||
| 23 | |||
| 24 | // To be implemented by the consumer. Defines keys to cancel oneshot mods. | ||
| 25 | bool is_oneshot_cancel_key(uint16_t keycode); | ||
| 26 | |||
| 27 | // To be implemented by the consumer. Defines keys to ignore when determining | ||
| 28 | // whether a oneshot mod has been used. Setting this to modifiers and layer | ||
| 29 | // change keys allows stacking multiple oneshot modifiers, and carrying them | ||
| 30 | // between layers. | ||
| 31 | bool is_oneshot_ignored_key(uint16_t keycode); | ||
