summaryrefslogtreecommitdiff
path: root/users/davidkristoffersen/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'users/davidkristoffersen/hardware')
-rw-r--r--users/davidkristoffersen/hardware/readme.md3
-rw-r--r--users/davidkristoffersen/hardware/split_space.c23
-rw-r--r--users/davidkristoffersen/hardware/split_space.h16
3 files changed, 42 insertions, 0 deletions
diff --git a/users/davidkristoffersen/hardware/readme.md b/users/davidkristoffersen/hardware/readme.md
new file mode 100644
index 0000000000..f31601812b
--- /dev/null
+++ b/users/davidkristoffersen/hardware/readme.md
@@ -0,0 +1,3 @@
+# Hardware
+
+This directory contains hardware related macros.
diff --git a/users/davidkristoffersen/hardware/split_space.c b/users/davidkristoffersen/hardware/split_space.c
new file mode 100644
index 0000000000..da25343f3d
--- /dev/null
+++ b/users/davidkristoffersen/hardware/split_space.c
@@ -0,0 +1,23 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "split_space.h"
+
+#ifdef SPLIT_SPACE
+void handle_split_space(uint16_t keycode) {
+ // Disable modifiers when numpad is active
+ if (IS_LAYER_ON(NUMPAD)) clear_oneshot_mods();
+
+ if (keycode == KC_LSPC) {
+ // 2ng tap: Activate ctrl if shift is active
+ if (get_oneshot_mods() & MOD_MASK_SHIFT) {
+ clear_oneshot_mods();
+ set_oneshot_mods(MOD_LCTL);
+ }
+ // 1st. tap: Activate shift if no modifier is active
+ else {
+ set_oneshot_mods(MOD_LSFT);
+ }
+ }
+}
+#endif
diff --git a/users/davidkristoffersen/hardware/split_space.h b/users/davidkristoffersen/hardware/split_space.h
new file mode 100644
index 0000000000..a9736b5ca1
--- /dev/null
+++ b/users/davidkristoffersen/hardware/split_space.h
@@ -0,0 +1,16 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "davidkristoffersen.h"
+
+#define KC_RSPC KC_SPACE
+
+#ifdef SPLIT_SPACE
+# define KC_LSPC LT(NUMPAD, KC_NO)
+#else
+# define KC_LSPC KC_SPACE
+#endif
+
+void handle_split_space(uint16_t keycode);