aboutsummaryrefslogtreecommitdiffstats
path: root/users/callum/swapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/callum/swapper.c')
-rw-r--r--users/callum/swapper.c27
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 @@
+#include "swapper.h"
+
+void update_swapper(
+ bool *active,
+ uint16_t cmdish,
+ uint16_t tabish,
+ uint16_t trigger,
+ uint16_t keycode,
+ keyrecord_t *record
+) {
+ if (keycode == trigger) {
+ if (record->event.pressed) {
+ if (!*active) {
+ *active = true;
+ register_code(cmdish);
+ }
+ register_code(tabish);
+ } else {
+ unregister_code(tabish);
+ // Don't unregister cmdish until some other key is hit or released.
+ }
+ } else if (*active) {
+ unregister_code(cmdish);
+ *active = false;
+ }
+}
+