summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2023-02-11 15:23:07 -0800
committerGitHub <noreply@github.com>2023-02-12 10:23:07 +1100
commitfe02abc47921428fe6eb59ca817bfd082f0de4bf (patch)
tree5bc3f68ec782969cfed93660c21704df4b530823 /quantum/process_keycode
parent40028437971fbca33f49e1d0b683b3b6e2dc9a61 (diff)
[Core] Tri Layer Keys (#19795)
Co-authored-by: wilba <wilba@wilba.tech> Co-authored-by: Pablo Martínez <58857054+elpekenin@users.noreply.github.com> Co-authored-by: Joel Challis <git@zvecr.com> Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_tri_layer.c30
-rw-r--r--quantum/process_keycode/process_tri_layer.h16
2 files changed, 46 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_tri_layer.c b/quantum/process_keycode/process_tri_layer.c
new file mode 100644
index 0000000000..1e681b9a1c
--- /dev/null
+++ b/quantum/process_keycode/process_tri_layer.c
@@ -0,0 +1,30 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "process_tri_layer.h"
+#include "tri_layer.h"
+#include "action_layer.h"
+
+bool process_tri_layer(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case QK_TRI_LAYER_LOWER:
+ if (record->event.pressed) {
+ layer_on(get_tri_layer_lower_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ } else {
+ layer_off(get_tri_layer_lower_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ }
+ return false;
+ case QK_TRI_LAYER_UPPER:
+ if (record->event.pressed) {
+ layer_on(get_tri_layer_upper_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ } else {
+ layer_off(get_tri_layer_upper_layer());
+ update_tri_layer(get_tri_layer_lower_layer(), get_tri_layer_upper_layer(), get_tri_layer_adjust_layer());
+ }
+ return false;
+ }
+ return true;
+}
diff --git a/quantum/process_keycode/process_tri_layer.h b/quantum/process_keycode/process_tri_layer.h
new file mode 100644
index 0000000000..9c4e3df1c2
--- /dev/null
+++ b/quantum/process_keycode/process_tri_layer.h
@@ -0,0 +1,16 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "action.h"
+
+/**
+ * @brief Handles tri layer behavior
+ *
+ * @param keycode the keycode
+ * @param record the key record structure
+ * @return true continue handling keycodes
+ * @return false stop handling keycodes
+ */
+bool process_tri_layer(uint16_t keycode, keyrecord_t *record);