summaryrefslogtreecommitdiff
path: root/users/callum/swapper.c
diff options
context:
space:
mode:
authorstein3 <stein3@gmail.com>2020-10-06 07:15:41 -0700
committerstein3 <stein3@gmail.com>2020-10-06 07:15:41 -0700
commit2e402741a89c5eec8cf30c966ce6f36d6ec9249b (patch)
tree3592e8c5e6bd19943ae55db7fc02a5f755afbb51 /users/callum/swapper.c
parent3e5e4f74272c610bb9fa737f674f8e65ed6100ca (diff)
parent2013f6313430b977e557e482d30daa279a46e75d (diff)
Merge branch 'master' into meteor
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 0000000000..736b2fef0c
--- /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;
+ }
+}
+