summaryrefslogtreecommitdiffstats
path: root/users/rverst
diff options
context:
space:
mode:
authorRobert Verst <github@verst.eu>2021-03-17 17:44:21 +0100
committerGitHub <noreply@github.com>2021-03-17 09:44:21 -0700
commit3bc7f46412e6e6c829aaff6d0f15c4cf36011948 (patch)
treefac20a5310fbd7d26a7763f02445b367d8d9b8d1 /users/rverst
parent8a2d3a8861588646c8563dfde080e49358faa245 (diff)
[Keymap] Add userspace rverst (#12205)
Co-authored-by: Robert Verst <robert.verst@tobit.com>
Diffstat (limited to 'users/rverst')
-rw-r--r--users/rverst/config.h38
-rw-r--r--users/rverst/readme.md18
-rw-r--r--users/rverst/rules.mk7
-rw-r--r--users/rverst/rverst.c419
-rw-r--r--users/rverst/rverst.h81
-rw-r--r--users/rverst/unicode.h31
6 files changed, 594 insertions, 0 deletions
diff --git a/users/rverst/config.h b/users/rverst/config.h
new file mode 100644
index 0000000000..f5cb5c76fd
--- /dev/null
+++ b/users/rverst/config.h
@@ -0,0 +1,38 @@
+/* Copyright 2021 Robert Verst <robert@verst.eu> @rverst
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#ifdef RGBLIGHT_ENABLE
+# define RGBLIGHT_SLEEP
+# ifdef RGBLIGHT_ANIMATIONS
+# undef RGBLIGHT_ANIMATIONS
+# endif
+# define RGBLIGHT_SLEEP
+# define RGBLIGHT_EFFECT_BREATHING
+# define RGBLIGHT_EFFECT_RAINBOW_MOOD
+# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
+# define RGBLIGHT_EFFECT_STATIC_GRADIENT
+# define RGBLIGHT_EFFECT_TWINKLE
+#endif // RGBLIGHT_ENABLE
+
+#if defined(LOCKING_SUPPORT_ENABLE)
+# undef LOCKING_SUPPORT_ENABLE
+#endif
+
+#if defined(LOCKING_RESYNC_ENABLE)
+# undef LOCKING_RESYNC_ENABLE
+#endif
diff --git a/users/rverst/readme.md b/users/rverst/readme.md
new file mode 100644
index 0000000000..b25af82db4
--- /dev/null
+++ b/users/rverst/readme.md
@@ -0,0 +1,18 @@
+# Overview
+
+This is my user space, main goal is to unify the experience between different
+keyboard models and operating systems.
+My native language is German and I almost exclusively use keyboards in the
+US-ANSI layout. I find this layout the most practical for programming as
+far as the placement of special characters is concerned. However, when I write
+in German, I miss a few special characters like umlauts, etc.
+Since I also use different operating systems (MacOS, Linux and Windows)
+and especially Windows and MacOS behave very differently regarding the input
+of such characters (under Linux there is at least the Compose key).
+So I needed a hardware solution, and that's how I came to QMK.
+
+Here are defined some key codes to put the keyboard in different modes
+(Mac, Windows, Linux) and the corresponding functions to make the input.
+And some logic to store the respective mode and load it at boot time.
+
+You'll find a proper layout here: [keyborads/id80/keymaps/rverst](../../keyboards/id80/keymaps/rverst)
diff --git a/users/rverst/rules.mk b/users/rverst/rules.mk
new file mode 100644
index 0000000000..91b096aede
--- /dev/null
+++ b/users/rverst/rules.mk
@@ -0,0 +1,7 @@
+SRC += rverst.c
+
+LEADER_ENABLE = no
+MOUSEKEY_ENABLE = no
+LTO_ENABLE = yes
+CONSOLE_ENABLE = yes
+UNICODEMAP_ENABLE = yes
diff --git a/users/rverst/rverst.c b/users/rverst/rverst.c
new file mode 100644
index 0000000000..4e8aa43e4d
--- /dev/null
+++ b/users/rverst/rverst.c
@@ -0,0 +1,419 @@
+/* Copyright 2021 Robert Verst <robert@verst.eu> @rverst
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rverst.h"
+#include "print.h"
+
+#ifdef UNICODEMAP_ENABLE
+# include "unicode.h"
+#endif
+
+userspace_config_t userspace_config;
+
+uint8_t get_mode(void) {
+ int m = 0;
+ if (userspace_config.mode_1) {
+ m += 1;
+ }
+ if (userspace_config.mode_2) {
+ m += 2;
+ }
+ if (userspace_config.mode_3) {
+ m += 4;
+ }
+
+ return m;
+}
+
+void set_mode(uint8_t mode, bool save) {
+ if (mode == get_mode()) {
+ return;
+ }
+ switch_mode(mode);
+
+ if (mode > 7) {
+ mode = 7;
+ }
+
+ if (mode >= 4) {
+ userspace_config.mode_3 = true;
+ mode -= 4;
+ } else {
+ userspace_config.mode_3 = false;
+ }
+
+ if (mode >= 2) {
+ userspace_config.mode_2 = true;
+ mode -= 2;
+ } else {
+ userspace_config.mode_2 = false;
+ }
+
+ if (mode > 0) {
+ userspace_config.mode_1 = true;
+ } else {
+ userspace_config.mode_1 = false;
+ }
+
+ if (save) {
+ eeconfig_update_user(userspace_config.raw);
+ }
+}
+
+void switch_mode(uint8_t mode) {
+#ifdef UNICODEMAP_ENABLE
+ switch (mode) {
+ case MAC_UNI:
+ set_unicode_input_mode(UC_MAC);
+ break;
+ case WINDOWS_UNI:
+ set_unicode_input_mode(UC_WINC);
+ break;
+ case LINUX_UNI:
+ set_unicode_input_mode(UC_LNX);
+ break;
+ }
+#endif
+}
+
+bool is_unicode(uint8_t mode) { return (mode == MAC_UNI) || (mode == WINDOWS_UNI) || (mode == LINUX_UNI); }
+
+//**********************
+// keyboard_pre_init
+//**********************
+__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
+
+void keyboard_pre_init_user(void) {
+ userspace_config.raw = eeconfig_read_user();
+ switch_mode(get_mode());
+ keyboard_pre_init_keymap();
+}
+
+//************************
+// keyboard_post_init
+//************************
+__attribute__((weak)) void keyboard_post_init_keymap(void) {}
+
+void keyboard_post_init_user(void) {
+ // debug_enable = true;
+ // debug_matrix=true;
+ // debug_keyboard = true;
+
+#ifdef RGBLIGHT_ENABLE
+
+#endif
+
+ keyboard_post_init_keymap();
+}
+
+//**********************
+// eeconfig_init
+//**********************
+
+__attribute__((weak)) void eeconfig_init_keymap(void) {}
+
+void eeconfig_init_user(void) {
+ userspace_config.raw = 0;
+ eeconfig_update_user(userspace_config.raw);
+ eeconfig_init_keymap();
+ keyboard_init();
+}
+
+//**********************
+// process_record
+//**********************
+__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ if (process_record_keymap(keycode, record)) {
+ return false;
+ }
+
+ bool ls = (get_mods() | get_weak_mods()) & MOD_BIT(KC_LSFT);
+ bool rs = (get_mods() | get_weak_mods()) & MOD_BIT(KC_RSFT);
+ bool as = ls || rs;
+
+ int mode = get_mode();
+
+ switch (keycode) {
+ case RV_SM0:
+ case RV_SM0S:
+ set_mode(MAC_UNI, keycode == RV_SM0S);
+ return false;
+ case RV_SM1:
+ case RV_SM1S:
+ set_mode(WINDOWS_UNI, keycode == RV_SM1S);
+ return false;
+ case RV_SM2:
+ case RV_SM2S:
+ set_mode(LINUX_UNI, keycode == RV_SM2S);
+ return false;
+ case RV_SM3:
+ case RV_SM3S:
+ set_mode(MAC, keycode == RV_SM3S);
+ return false;
+ case RV_SM4:
+ case RV_SM4S:
+ set_mode(WINDOWS, keycode == RV_SM4S);
+ return false;
+
+ case RV_SAYM:
+ switch (mode) {
+ case MAC:
+ send_string("MacOS (normal)");
+ break;
+ case WINDOWS:
+ send_string("Windows (normal)");
+ break;
+ case MAC_UNI:
+ send_string("MacOS (unicode)");
+ break;
+ case WINDOWS_UNI:
+ send_string("Windows (unicode)");
+ break;
+ case LINUX_UNI:
+ send_string("Linux (unicode)");
+ break;
+ }
+ return false;
+
+ // Lock computer
+ case RV_LOCK:
+ if (mode == MAC || mode == MAC_UNI) {
+ register_code(KC_LGUI);
+ register_code(KC_LCTL);
+ tap_code(KC_Q);
+ unregister_code(KC_LCTL);
+ unregister_code(KC_LGUI);
+ } else if (mode == WINDOWS || mode == WINDOWS_UNI) {
+ register_code(KC_LGUI);
+ tap_code(KC_L);
+ register_code(KC_LGUI);
+ }
+ return false;
+
+ // Screenshot
+ case RV_SNAP:
+ if (mode == MAC || mode == MAC_UNI) {
+ if (ls) unregister_code(KC_LSFT);
+ if (rs) unregister_code(KC_RSFT);
+
+ register_code(KC_LGUI);
+ register_code(KC_LSFT);
+ if (as)
+ tap_code(KC_5);
+ else
+ tap_code(KC_4);
+ unregister_code(KC_LSFT);
+ unregister_code(KC_LGUI);
+
+ if (ls) register_code(KC_LSFT);
+ if (rs) register_code(KC_RSFT);
+ } else if (mode == WINDOWS || mode == WINDOWS_UNI) {
+ register_code(KC_LGUI);
+ register_code(KC_LSFT);
+ tap_code(KC_S);
+ register_code(KC_LSFT);
+ register_code(KC_LGUI);
+ }
+ return false;
+
+ // Umlauts - äÄöÖüÜ
+ case RV_AUML:
+ case RV_OUML:
+ case RV_UUML:
+ if (is_unicode(mode)) {
+ if (keycode == RV_AUML) {
+ if (as)
+ send_unicode_string("Ä");
+ else
+ send_unicode_string("ä");
+ } else if (keycode == RV_OUML) {
+ if (as)
+ send_unicode_string("Ö");
+ else
+ send_unicode_string("ö");
+ } else if (keycode == RV_UUML) {
+ if (as)
+ send_unicode_string("Ü");
+ else
+ send_unicode_string("ü");
+ }
+ } else if (mode == MAC) {
+ if (ls) unregister_code(KC_LSFT);
+ if (rs) unregister_code(KC_RSFT);
+
+ register_code(KC_LALT);
+ tap_code(KC_U);
+ unregister_code(KC_LALT);
+
+ if (as) register_code(KC_LSFT);
+ if (keycode == RV_AUML) {
+ tap_code(KC_A);
+ } else if (keycode == RV_OUML) {
+ tap_code(KC_O);
+ } else if (keycode == RV_UUML) {
+ tap_code(KC_U);
+ }
+ if (rs) {
+ unregister_code(KC_LSFT);
+ register_code(KC_RSFT);
+ }
+ } else if (mode == WINDOWS) {
+ if (ls) unregister_code(KC_LSFT);
+ if (rs) unregister_code(KC_RSFT);
+
+ register_code(KC_RALT);
+ tap_code(KC_1);
+ if (keycode == RV_AUML) {
+ if (as)
+ tap_code(KC_4);
+ else
+ tap_code(KC_3);
+ tap_code(KC_2);
+ } else if (keycode == RV_OUML) {
+ if (as) {
+ tap_code(KC_5);
+ tap_code(KC_3);
+ } else {
+ tap_code(KC_4);
+ tap_code(KC_8);
+ }
+ } else if (keycode == RV_UUML) {
+ if (as) {
+ tap_code(KC_5);
+ tap_code(KC_4);
+ } else {
+ tap_code(KC_2);
+ tap_code(KC_9);
+ }
+ }
+ unregister_code(KC_RALT);
+
+ if (ls) register_code(KC_LSFT);
+ if (rs) register_code(KC_RSFT);
+ }
+ return false;
+
+ // Euro sign - €
+ // with legacy-mode for MAC and WINDOWS without unicode support
+ case RV_EUR:
+ if (is_unicode(mode)) {
+ send_unicode_string("€");
+ } else if (mode == MAC) {
+ register_code(KC_LALT);
+ register_code(KC_LSFT);
+ tap_code(KC_2);
+ unregister_code(KC_LSFT);
+ unregister_code(KC_LALT);
+ } else if (mode == WINDOWS) {
+ register_code(KC_RALT);
+ tap_code(KC_0);
+ tap_code(KC_1);
+ tap_code(KC_2);
+ tap_code(KC_8);
+ unregister_code(KC_RALT);
+ }
+ return false;
+
+ // Sharp-S - ß
+ // with legacy-mode for MAC and WINDOWS without unicode support
+ case RV_SZ:
+ if (is_unicode(mode)) {
+ if (as) {
+ send_unicode_string("§");
+ } else {
+ send_unicode_string("ß");
+ }
+ } else if (mode == MAC) {
+ register_code(KC_LALT);
+ tap_code(KC_S);
+ unregister_code(KC_LALT);
+ } else if (mode == WINDOWS) {
+ register_code(KC_RALT);
+ tap_code(KC_2);
+ tap_code(KC_2);
+ tap_code(KC_5);
+ unregister_code(KC_RALT);
+ }
+ return false;
+
+ // Trademark - ™
+ case RV_TM:
+ if (is_unicode(mode)) {
+ send_unicode_string("™");
+ }
+ return false;
+
+ // Registered trademark - ®
+ case RV_RT:
+ if (is_unicode(mode)) {
+ send_unicode_string("®");
+ }
+ return false;
+
+ // Copyright - ©
+ case RV_CC:
+ if (is_unicode(mode)) {
+ send_unicode_string("©");
+ }
+ return false;
+
+ // Degree - °
+ case RV_DEG:
+ if (is_unicode(mode)) {
+ send_unicode_string("°");
+ }
+ return false;
+
+ // Plus-minus - ±
+ case RV_PM:
+ if (is_unicode(mode)) {
+ send_unicode_string("±");
+ }
+ return false;
+
+ // Not equal - ≠
+ case RV_UNEQ:
+ if (is_unicode(mode)) {
+ send_unicode_string("≠");
+ }
+ return false;
+
+ // Superscript one - ¹
+ case RV_SUP1:
+ if (is_unicode(mode)) {
+ send_unicode_string("¹");
+ }
+ return false;
+
+ // Superscript two - ²
+ case RV_SUP2:
+ if (is_unicode(mode)) {
+ send_unicode_string("²");
+ }
+ return false;
+
+ // Superscript three - ³
+ case RV_SUP3:
+ if (is_unicode(mode)) {
+ send_unicode_string("³");
+ }
+ return false;
+ }
+
+ return true;
+}
diff --git a/users/rverst/rverst.h b/users/rverst/rverst.h
new file mode 100644
index 0000000000..b7aea556c2
--- /dev/null
+++ b/users/rverst/rverst.h
@@ -0,0 +1,81 @@
+/* Copyright 2021 Robert Verst <robert@verst.eu> @rverst
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include QMK_KEYBOARD_H
+
+enum userspace_mode {
+ MAC = 0,
+ WINDOWS,
+ MAC_UNI,
+ WINDOWS_UNI,
+ LINUX_UNI,
+};
+
+enum userspace_keycodes {
+ RV_NON = SAFE_RANGE,
+ RV_SM0, // set Mac Unicode mode
+ RV_SM1, // set Window Unicode mode
+ RV_SM2, // set Linux Unicode mode
+ RV_SM3, // set Mac lagecy mode
+ RV_SM4, // set Windows legacy mode
+ RV_SM0S, // set Mac Unicode mode and save
+ RV_SM1S, // set Windows Unicode mode and save
+ RV_SM2S, // set Linux Unicode and save
+ RV_SM3S, // set Mac legacy mode
+ RV_SM4S, // set Windows legacy and save
+ RV_SAYM, // say mode
+ RV_LOCK, // lock computer
+ RV_AUML, // äÄ
+ RV_OUML, // öÖ
+ RV_UUML, // üÜ
+ RV_EUR, // €
+ RV_SZ, // ߧ
+ RV_TM, // ™
+ RV_RT, // ®
+ RV_CC, // ©
+ RV_DEG, // °
+ RV_SNAP, // Screenshot
+ RV_PM, // ±
+ RV_UNEQ, // ≠
+ RV_SUP1, // ¹
+ RV_SUP2, // ²
+ RV_SUP3, // ³
+
+};
+
+typedef union {
+ uint32_t raw;
+ struct {
+ bool mode_1 : 1;
+ bool mode_2 : 1;
+ bool mode_3 : 1;
+ };
+} userspace_config_t;
+
+extern userspace_config_t userspace_config;
+
+uint8_t get_mode(void);
+void set_mode(uint8_t mode, bool save);
+void switch_mode(uint8_t mode);
+bool is_unicode(uint8_t mode);
+
+void keyboard_pre_init_keymap(void);
+void keyboard_post_init_keymap(void);
+void eeconfig_init_keymap(void);
+bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
+
diff --git a/users/rverst/unicode.h b/users/rverst/unicode.h
new file mode 100644
index 0000000000..2268ffb594
--- /dev/null
+++ b/users/rverst/unicode.h
@@ -0,0 +1,31 @@
+/* Copyright 2021 Robert Verst <robert@verst.eu> @rverst
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#ifdef UNICODE_SELECTED_MODES
+# undef UNICODE_SELECTED_MODES
+# define UNICODE_SELECTED_MODES UC_MAC, UC_LNX, UC_WINC
+#endif
+
+enum unicode_names { BANG, IRONY, SNEK };
+
+const uint32_t PROGMEM unicode_map[] = {
+ [BANG] = 0x203D,
+ [IRONY] = 0x2E2E,
+ [SNEK] = 0x1F40D,
+};
+