diff options
Diffstat (limited to 'users/callum/swapper.c')
| -rw-r--r-- | users/callum/swapper.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/users/callum/swapper.c b/users/callum/swapper.c new file mode 100644 index 000000000..736b2fef0 --- /dev/null +++ b/users/callum/swapper.c | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #include "swapper.h" | ||
| 2 | |||
| 3 | void update_swapper( | ||
| 4 | bool *active, | ||
| 5 | uint16_t cmdish, | ||
| 6 | uint16_t tabish, | ||
| 7 | uint16_t trigger, | ||
| 8 | uint16_t keycode, | ||
| 9 | keyrecord_t *record | ||
| 10 | ) { | ||
| 11 | if (keycode == trigger) { | ||
| 12 | if (record->event.pressed) { | ||
| 13 | if (!*active) { | ||
| 14 | *active = true; | ||
| 15 | register_code(cmdish); | ||
| 16 | } | ||
| 17 | register_code(tabish); | ||
| 18 | } else { | ||
| 19 | unregister_code(tabish); | ||
| 20 | // Don't unregister cmdish until some other key is hit or released. | ||
| 21 | } | ||
| 22 | } else if (*active) { | ||
| 23 | unregister_code(cmdish); | ||
| 24 | *active = false; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
