summaryrefslogtreecommitdiffstats
path: root/users/davidkristoffersen/macros
diff options
context:
space:
mode:
authorDavid Kristoffersen <david.alta2010@gmail.com>2022-07-02 14:18:21 +0200
committerGitHub <noreply@github.com>2022-07-02 22:18:21 +1000
commita80943579c88255fff9de57978b8e577d184785c (patch)
treedba57e907e20f50f4c9cbee22866d99a620e5d0d /users/davidkristoffersen/macros
parentef633cf46139282daaca77939937f7ba2519f56b (diff)
[Keymap] Add prog_qgmlwb keymap (#16890)
Diffstat (limited to 'users/davidkristoffersen/macros')
-rw-r--r--users/davidkristoffersen/macros/debug.c36
-rw-r--r--users/davidkristoffersen/macros/language.c40
-rw-r--r--users/davidkristoffersen/macros/macros.c16
-rw-r--r--users/davidkristoffersen/macros/macros.h23
-rw-r--r--users/davidkristoffersen/macros/norwegian.h19
-rw-r--r--users/davidkristoffersen/macros/readme.md3
6 files changed, 137 insertions, 0 deletions
diff --git a/users/davidkristoffersen/macros/debug.c b/users/davidkristoffersen/macros/debug.c
new file mode 100644
index 0000000000..64fdc4a702
--- /dev/null
+++ b/users/davidkristoffersen/macros/debug.c
@@ -0,0 +1,36 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "macros.h"
+
+// Replace key records with macros
+bool handle_test(uint16_t keycode) {
+ switch (keycode) {
+ case KC_T0: {
+ // Test QK_MAKE command
+ SEND_STRING("qmk compile -kb " QMK_KEYBOARD " -km " QMK_KEYMAP);
+ break;
+ }
+ case KC_T1:
+ // Test ascii characters
+ SEND_STRING(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
+ break;
+ case KC_T2:
+#ifdef LAYER_NO
+ // Test other characters
+ tap_code16(NO_AE);
+ tap_code16(NO_OE);
+ tap_code16(NO_AA);
+ tap_code16(S(NO_AE));
+ tap_code16(S(NO_OE));
+ tap_code16(S(NO_AA));
+#endif
+ return false;
+ }
+ return true;
+};
+
+bool process_debug(uint16_t keycode, keyrecord_t* record) {
+ HANDLE_FALSE(handle_test(keycode));
+ return true;
+}
diff --git a/users/davidkristoffersen/macros/language.c b/users/davidkristoffersen/macros/language.c
new file mode 100644
index 0000000000..9b6dca79ca
--- /dev/null
+++ b/users/davidkristoffersen/macros/language.c
@@ -0,0 +1,40 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "macros.h"
+
+bool handle_language(uint16_t keycode) {
+#ifdef LAYER_NO
+ // Handle conversion of English to Norwegian codes
+ uint16_t org_keycode = keycode;
+ keycode = get_norwegian_code(keycode);
+#endif
+
+#ifndef NO_SPECIAL_SHIFT
+ // Handle conversion of special shift codes
+ if (get_mods() & MOD_MASK_SHIFT) {
+ uint16_t shifted_key = get_special_shifted_code(keycode);
+ if (shifted_key != keycode) {
+ // Tap shifted key while shift is disabled
+ unregister_code(KC_LSFT);
+ tap_code16(shifted_key);
+ register_code(KC_LSFT);
+ return false;
+ }
+ }
+#endif
+
+#ifdef LAYER_NO
+ // Tap new language key
+ if (keycode != org_keycode) {
+ tap_code16(keycode);
+ return false;
+ }
+#endif
+ return true;
+}
+
+bool process_language(uint16_t keycode, keyrecord_t* record) {
+ HANDLE_FALSE(handle_language(keycode));
+ return true;
+}
diff --git a/users/davidkristoffersen/macros/macros.c b/users/davidkristoffersen/macros/macros.c
new file mode 100644
index 0000000000..6d8c0b6f57
--- /dev/null
+++ b/users/davidkristoffersen/macros/macros.c
@@ -0,0 +1,16 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "macros.h"
+
+// Prepend key records with macros
+bool process_record_user(uint16_t keycode, keyrecord_t* record) {
+ if (record->event.pressed) {
+#ifdef SPLIT_SPACE
+ handle_split_space(keycode, record);
+#endif
+ HANDLE_FALSE(process_debug(keycode, record));
+ HANDLE_FALSE(process_language(keycode, record));
+ }
+ return true;
+}
diff --git a/users/davidkristoffersen/macros/macros.h b/users/davidkristoffersen/macros/macros.h
new file mode 100644
index 0000000000..fb1e5c862c
--- /dev/null
+++ b/users/davidkristoffersen/macros/macros.h
@@ -0,0 +1,23 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "davidkristoffersen.h"
+
+enum keycodes {
+ // Test keys
+ KC_T0 = SAFE_RANGE,
+ KC_T1,
+ KC_T2,
+ // Norwegian Æ, Ø, Å
+ KC_AE,
+ KC_OE,
+ KC_AA
+};
+
+bool process_debug(uint16_t keycode, keyrecord_t* record);
+bool process_language(uint16_t keycode, keyrecord_t* record);
+
+// Prepend key records with macros
+bool process_record_user(uint16_t keycode, keyrecord_t* record);
diff --git a/users/davidkristoffersen/macros/norwegian.h b/users/davidkristoffersen/macros/norwegian.h
new file mode 100644
index 0000000000..575d1e9f2f
--- /dev/null
+++ b/users/davidkristoffersen/macros/norwegian.h
@@ -0,0 +1,19 @@
+// Copyright 2022 David Kristoffersen (@davidkristoffersen)
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include "keymap_extras/keymap_norwegian.h"
+#include "davidkristoffersen.h"
+
+// Better norwegian defines
+#undef NO_LESS
+#define NO_LESS KC_NUBS // <
+#undef NO_GRTR
+#define NO_GRTR S(NO_LESS) // >
+#undef NO_AE
+#define NO_AE KC_QUOT // Æ
+#undef NO_OE
+#define NO_OE KC_SCLN // Ø
+#undef NO_AA
+#define NO_AA KC_LBRC // Å
diff --git a/users/davidkristoffersen/macros/readme.md b/users/davidkristoffersen/macros/readme.md
new file mode 100644
index 0000000000..7c074b2bb5
--- /dev/null
+++ b/users/davidkristoffersen/macros/readme.md
@@ -0,0 +1,3 @@
+# Macros
+
+This directory contains any type of dynamic and static macros.