diff options
| author | Robert Verst <github@verst.eu> | 2021-03-17 17:44:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-17 09:44:21 -0700 |
| commit | 3bc7f46412e6e6c829aaff6d0f15c4cf36011948 (patch) | |
| tree | fac20a5310fbd7d26a7763f02445b367d8d9b8d1 /users | |
| parent | 8a2d3a8861588646c8563dfde080e49358faa245 (diff) | |
| download | qmk_firmware-3bc7f46412e6e6c829aaff6d0f15c4cf36011948.tar.gz qmk_firmware-3bc7f46412e6e6c829aaff6d0f15c4cf36011948.zip | |
[Keymap] Add userspace rverst (#12205)
Co-authored-by: Robert Verst <robert.verst@tobit.com>
Diffstat (limited to 'users')
| -rw-r--r-- | users/rverst/config.h | 38 | ||||
| -rw-r--r-- | users/rverst/readme.md | 18 | ||||
| -rw-r--r-- | users/rverst/rules.mk | 7 | ||||
| -rw-r--r-- | users/rverst/rverst.c | 419 | ||||
| -rw-r--r-- | users/rverst/rverst.h | 81 | ||||
| -rw-r--r-- | users/rverst/unicode.h | 31 |
6 files changed, 594 insertions, 0 deletions
diff --git a/users/rverst/config.h b/users/rverst/config.h new file mode 100644 index 000000000..f5cb5c76f --- /dev/null +++ b/users/rverst/config.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* Copyright 2021 Robert Verst <robert@verst.eu> @rverst | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #ifdef RGBLIGHT_ENABLE | ||
| 20 | # define RGBLIGHT_SLEEP | ||
| 21 | # ifdef RGBLIGHT_ANIMATIONS | ||
| 22 | # undef RGBLIGHT_ANIMATIONS | ||
| 23 | # endif | ||
| 24 | # define RGBLIGHT_SLEEP | ||
| 25 | # define RGBLIGHT_EFFECT_BREATHING | ||
| 26 | # define RGBLIGHT_EFFECT_RAINBOW_MOOD | ||
| 27 | # define RGBLIGHT_EFFECT_RAINBOW_SWIRL | ||
| 28 | # define RGBLIGHT_EFFECT_STATIC_GRADIENT | ||
| 29 | # define RGBLIGHT_EFFECT_TWINKLE | ||
| 30 | #endif // RGBLIGHT_ENABLE | ||
| 31 | |||
| 32 | #if defined(LOCKING_SUPPORT_ENABLE) | ||
| 33 | # undef LOCKING_SUPPORT_ENABLE | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #if defined(LOCKING_RESYNC_ENABLE) | ||
| 37 | # undef LOCKING_RESYNC_ENABLE | ||
| 38 | #endif | ||
diff --git a/users/rverst/readme.md b/users/rverst/readme.md new file mode 100644 index 000000000..b25af82db --- /dev/null +++ b/users/rverst/readme.md | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | # Overview | ||
| 2 | |||
| 3 | This is my user space, main goal is to unify the experience between different | ||
| 4 | keyboard models and operating systems. | ||
| 5 | My native language is German and I almost exclusively use keyboards in the | ||
| 6 | US-ANSI layout. I find this layout the most practical for programming as | ||
| 7 | far as the placement of special characters is concerned. However, when I write | ||
| 8 | in German, I miss a few special characters like umlauts, etc. | ||
| 9 | Since I also use different operating systems (MacOS, Linux and Windows) | ||
| 10 | and especially Windows and MacOS behave very differently regarding the input | ||
| 11 | of such characters (under Linux there is at least the Compose key). | ||
| 12 | So I needed a hardware solution, and that's how I came to QMK. | ||
| 13 | |||
| 14 | Here are defined some key codes to put the keyboard in different modes | ||
| 15 | (Mac, Windows, Linux) and the corresponding functions to make the input. | ||
| 16 | And some logic to store the respective mode and load it at boot time. | ||
| 17 | |||
| 18 | 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 000000000..91b096aed --- /dev/null +++ b/users/rverst/rules.mk | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | SRC += rverst.c | ||
| 2 | |||
| 3 | LEADER_ENABLE = no | ||
| 4 | MOUSEKEY_ENABLE = no | ||
| 5 | LTO_ENABLE = yes | ||
| 6 | CONSOLE_ENABLE = yes | ||
| 7 | UNICODEMAP_ENABLE = yes | ||
diff --git a/users/rverst/rverst.c b/users/rverst/rverst.c new file mode 100644 index 000000000..4e8aa43e4 --- /dev/null +++ b/users/rverst/rverst.c | |||
| @@ -0,0 +1,419 @@ | |||
| 1 | /* Copyright 2021 Robert Verst <robert@verst.eu> @rverst | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "rverst.h" | ||
| 18 | #include "print.h" | ||
| 19 | |||
| 20 | #ifdef UNICODEMAP_ENABLE | ||
| 21 | # include "unicode.h" | ||
| 22 | #endif | ||
| 23 | |||
| 24 | userspace_config_t userspace_config; | ||
| 25 | |||
| 26 | uint8_t get_mode(void) { | ||
| 27 | int m = 0; | ||
| 28 | if (userspace_config.mode_1) { | ||
| 29 | m += 1; | ||
| 30 | } | ||
| 31 | if (userspace_config.mode_2) { | ||
| 32 | m += 2; | ||
| 33 | } | ||
| 34 | if (userspace_config.mode_3) { | ||
| 35 | m += 4; | ||
| 36 | } | ||
| 37 | |||
| 38 | return m; | ||
| 39 | } | ||
| 40 | |||
| 41 | void set_mode(uint8_t mode, bool save) { | ||
| 42 | if (mode == get_mode()) { | ||
| 43 | return; | ||
| 44 | } | ||
| 45 | switch_mode(mode); | ||
| 46 | |||
| 47 | if (mode > 7) { | ||
| 48 | mode = 7; | ||
| 49 | } | ||
| 50 | |||
| 51 | if (mode >= 4) { | ||
| 52 | userspace_config.mode_3 = true; | ||
| 53 | mode -= 4; | ||
| 54 | } else { | ||
| 55 | userspace_config.mode_3 = false; | ||
| 56 | } | ||
| 57 | |||
| 58 | if (mode >= 2) { | ||
| 59 | userspace_config.mode_2 = true; | ||
| 60 | mode -= 2; | ||
| 61 | } else { | ||
| 62 | userspace_config.mode_2 = false; | ||
| 63 | } | ||
| 64 | |||
| 65 | if (mode > 0) { | ||
| 66 | userspace_config.mode_1 = true; | ||
| 67 | } else { | ||
| 68 | userspace_config.mode_1 = false; | ||
| 69 | } | ||
| 70 | |||
| 71 | if (save) { | ||
| 72 | eeconfig_update_user(userspace_config.raw); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | void switch_mode(uint8_t mode) { | ||
| 77 | #ifdef UNICODEMAP_ENABLE | ||
| 78 | switch (mode) { | ||
| 79 | case MAC_UNI: | ||
| 80 | set_unicode_input_mode(UC_MAC); | ||
| 81 | break; | ||
| 82 | case WINDOWS_UNI: | ||
| 83 | set_unicode_input_mode(UC_WINC); | ||
| 84 | break; | ||
| 85 | case LINUX_UNI: | ||
| 86 | set_unicode_input_mode(UC_LNX); | ||
| 87 | break; | ||
| 88 | } | ||
| 89 | #endif | ||
| 90 | } | ||
| 91 | |||
| 92 | bool is_unicode(uint8_t mode) { return (mode == MAC_UNI) || (mode == WINDOWS_UNI) || (mode == LINUX_UNI); } | ||
| 93 | |||
| 94 | //********************** | ||
| 95 | // keyboard_pre_init | ||
| 96 | //********************** | ||
| 97 | __attribute__((weak)) void keyboard_pre_init_keymap(void) {} | ||
| 98 | |||
| 99 | void keyboard_pre_init_user(void) { | ||
| 100 | userspace_config.raw = eeconfig_read_user(); | ||
| 101 | switch_mode(get_mode()); | ||
| 102 | keyboard_pre_init_keymap(); | ||
| 103 | } | ||
| 104 | |||
| 105 | //************************ | ||
| 106 | // keyboard_post_init | ||
| 107 | //************************ | ||
| 108 | __attribute__((weak)) void keyboard_post_init_keymap(void) {} | ||
| 109 | |||
| 110 | void keyboard_post_init_user(void) { | ||
| 111 | // debug_enable = true; | ||
| 112 | // debug_matrix=true; | ||
| 113 | // debug_keyboard = true; | ||
| 114 | |||
| 115 | #ifdef RGBLIGHT_ENABLE | ||
| 116 | |||
| 117 | #endif | ||
| 118 | |||
| 119 | keyboard_post_init_keymap(); | ||
| 120 | } | ||
| 121 | |||
| 122 | //********************** | ||
| 123 | // eeconfig_init | ||
| 124 | //********************** | ||
| 125 | |||
| 126 | __attribute__((weak)) void eeconfig_init_keymap(void) {} | ||
| 127 | |||
| 128 | void eeconfig_init_user(void) { | ||
| 129 | userspace_config.raw = 0; | ||
| 130 | eeconfig_update_user(userspace_config.raw); | ||
| 131 | eeconfig_init_keymap(); | ||
| 132 | keyboard_init(); | ||
| 133 | } | ||
| 134 | |||
| 135 | //********************** | ||
| 136 | // process_record | ||
| 137 | //********************** | ||
| 138 | __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } | ||
| 139 | |||
| 140 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 141 | if (process_record_keymap(keycode, record)) { | ||
| 142 | return false; | ||
| 143 | } | ||
| 144 | |||
| 145 | bool ls = (get_mods() | get_weak_mods()) & MOD_BIT(KC_LSFT); | ||
| 146 | bool rs = (get_mods() | get_weak_mods()) & MOD_BIT(KC_RSFT); | ||
| 147 | bool as = ls || rs; | ||
| 148 | |||
| 149 | int mode = get_mode(); | ||
| 150 | |||
| 151 | switch (keycode) { | ||
| 152 | case RV_SM0: | ||
| 153 | case RV_SM0S: | ||
| 154 | set_mode(MAC_UNI, keycode == RV_SM0S); | ||
| 155 | return false; | ||
| 156 | case RV_SM1: | ||
| 157 | case RV_SM1S: | ||
| 158 | set_mode(WINDOWS_UNI, keycode == RV_SM1S); | ||
| 159 | return false; | ||
| 160 | case RV_SM2: | ||
| 161 | case RV_SM2S: | ||
| 162 | set_mode(LINUX_UNI, keycode == RV_SM2S); | ||
| 163 | return false; | ||
| 164 | case RV_SM3: | ||
| 165 | case RV_SM3S: | ||
| 166 | set_mode(MAC, keycode == RV_SM3S); | ||
| 167 | return false; | ||
| 168 | case RV_SM4: | ||
| 169 | case RV_SM4S: | ||
| 170 | set_mode(WINDOWS, keycode == RV_SM4S); | ||
| 171 | return false; | ||
| 172 | |||
| 173 | case RV_SAYM: | ||
| 174 | switch (mode) { | ||
| 175 | case MAC: | ||
| 176 | send_string("MacOS (normal)"); | ||
| 177 | break; | ||
| 178 | case WINDOWS: | ||
| 179 | send_string("Windows (normal)"); | ||
| 180 | break; | ||
| 181 | case MAC_UNI: | ||
| 182 | send_string("MacOS (unicode)"); | ||
| 183 | break; | ||
| 184 | case WINDOWS_UNI: | ||
| 185 | send_string("Windows (unicode)"); | ||
| 186 | break; | ||
| 187 | case LINUX_UNI: | ||
| 188 | send_string("Linux (unicode)"); | ||
| 189 | break; | ||
| 190 | } | ||
| 191 | return false; | ||
| 192 | |||
| 193 | // Lock computer | ||
| 194 | case RV_LOCK: | ||
| 195 | if (mode == MAC || mode == MAC_UNI) { | ||
| 196 | register_code(KC_LGUI); | ||
| 197 | register_code(KC_LCTL); | ||
| 198 | tap_code(KC_Q); | ||
| 199 | unregister_code(KC_LCTL); | ||
| 200 | unregister_code(KC_LGUI); | ||
| 201 | } else if (mode == WINDOWS || mode == WINDOWS_UNI) { | ||
| 202 | register_code(KC_LGUI); | ||
| 203 | tap_code(KC_L); | ||
| 204 | register_code(KC_LGUI); | ||
| 205 | } | ||
| 206 | return false; | ||
| 207 | |||
| 208 | // Screenshot | ||
| 209 | case RV_SNAP: | ||
| 210 | if (mode == MAC || mode == MAC_UNI) { | ||
| 211 | if (ls) unregister_code(KC_LSFT); | ||
| 212 | if (rs) unregister_code(KC_RSFT); | ||
| 213 | |||
| 214 | register_code(KC_LGUI); | ||
| 215 | register_code(KC_LSFT); | ||
| 216 | if (as) | ||
| 217 | tap_code(KC_5); | ||
| 218 | else | ||
| 219 | tap_code(KC_4); | ||
| 220 | unregister_code(KC_LSFT); | ||
| 221 | unregister_code(KC_LGUI); | ||
| 222 | |||
| 223 | if (ls) register_code(KC_LSFT); | ||
| 224 | if (rs) register_code(KC_RSFT); | ||
| 225 | } else if (mode == WINDOWS || mode == WINDOWS_UNI) { | ||
| 226 | register_code(KC_LGUI); | ||
| 227 | register_code(KC_LSFT); | ||
| 228 | tap_code(KC_S); | ||
| 229 | register_code(KC_LSFT); | ||
| 230 | register_code(KC_LGUI); | ||
| 231 | } | ||
| 232 | return false; | ||
| 233 | |||
| 234 | // Umlauts - äÄöÖüÜ | ||
| 235 | case RV_AUML: | ||
| 236 | case RV_OUML: | ||
| 237 | case RV_UUML: | ||
| 238 | if (is_unicode(mode)) { | ||
| 239 | if (keycode == RV_AUML) { | ||
| 240 | if (as) | ||
| 241 | send_unicode_string("Ä"); | ||
| 242 | else | ||
| 243 | send_unicode_string("ä"); | ||
| 244 | } else if (keycode == RV_OUML) { | ||
| 245 | if (as) | ||
| 246 | send_unicode_string("Ö"); | ||
| 247 | else | ||
| 248 | send_unicode_string("ö"); | ||
| 249 | } else if (keycode == RV_UUML) { | ||
| 250 | if (as) | ||
| 251 | send_unicode_string("Ü"); | ||
| 252 | else | ||
| 253 | send_unicode_string("ü"); | ||
| 254 | } | ||
| 255 | } else if (mode == MAC) { | ||
| 256 | if (ls) unregister_code(KC_LSFT); | ||
| 257 | if (rs) unregister_code(KC_RSFT); | ||
| 258 | |||
| 259 | register_code(KC_LALT); | ||
| 260 | tap_code(KC_U); | ||
| 261 | unregister_code(KC_LALT); | ||
| 262 | |||
| 263 | if (as) register_code(KC_LSFT); | ||
| 264 | if (keycode == RV_AUML) { | ||
| 265 | tap_code(KC_A); | ||
| 266 | } else if (keycode == RV_OUML) { | ||
| 267 | tap_code(KC_O); | ||
| 268 | } else if (keycode == RV_UUML) { | ||
| 269 | tap_code(KC_U); | ||
| 270 | } | ||
| 271 | if (rs) { | ||
| 272 | unregister_code(KC_LSFT); | ||
| 273 | register_code(KC_RSFT); | ||
| 274 | } | ||
| 275 | } else if (mode == WINDOWS) { | ||
| 276 | if (ls) unregister_code(KC_LSFT); | ||
| 277 | if (rs) unregister_code(KC_RSFT); | ||
| 278 | |||
| 279 | register_code(KC_RALT); | ||
| 280 | tap_code(KC_1); | ||
| 281 | if (keycode == RV_AUML) { | ||
| 282 | if (as) | ||
| 283 | tap_code(KC_4); | ||
| 284 | else | ||
| 285 | tap_code(KC_3); | ||
| 286 | tap_code(KC_2); | ||
| 287 | } else if (keycode == RV_OUML) { | ||
| 288 | if (as) { | ||
| 289 | tap_code(KC_5); | ||
| 290 | tap_code(KC_3); | ||
| 291 | } else { | ||
| 292 | tap_code(KC_4); | ||
| 293 | tap_code(KC_8); | ||
| 294 | } | ||
| 295 | } else if (keycode == RV_UUML) { | ||
| 296 | if (as) { | ||
| 297 | tap_code(KC_5); | ||
| 298 | tap_code(KC_4); | ||
| 299 | } else { | ||
| 300 | tap_code(KC_2); | ||
| 301 | tap_code(KC_9); | ||
| 302 | } | ||
| 303 | } | ||
| 304 | unregister_code(KC_RALT); | ||
| 305 | |||
| 306 | if (ls) register_code(KC_LSFT); | ||
| 307 | if (rs) register_code(KC_RSFT); | ||
| 308 | } | ||
| 309 | return false; | ||
| 310 | |||
| 311 | // Euro sign - € | ||
| 312 | // with legacy-mode for MAC and WINDOWS without unicode support | ||
| 313 | case RV_EUR: | ||
| 314 | if (is_unicode(mode)) { | ||
| 315 | send_unicode_string("€"); | ||
| 316 | } else if (mode == MAC) { | ||
| 317 | register_code(KC_LALT); | ||
| 318 | register_code(KC_LSFT); | ||
| 319 | tap_code(KC_2); | ||
| 320 | unregister_code(KC_LSFT); | ||
| 321 | unregister_code(KC_LALT); | ||
| 322 | } else if (mode == WINDOWS) { | ||
| 323 | register_code(KC_RALT); | ||
| 324 | tap_code(KC_0); | ||
| 325 | tap_code(KC_1); | ||
| 326 | tap_code(KC_2); | ||
| 327 | tap_code(KC_8); | ||
| 328 | unregister_code(KC_RALT); | ||
| 329 | } | ||
| 330 | return false; | ||
| 331 | |||
| 332 | // Sharp-S - ß | ||
| 333 | // with legacy-mode for MAC and WINDOWS without unicode support | ||
| 334 | case RV_SZ: | ||
| 335 | if (is_unicode(mode)) { | ||
| 336 | if (as) { | ||
| 337 | send_unicode_string("§"); | ||
| 338 | } else { | ||
| 339 | send_unicode_string("ß"); | ||
| 340 | } | ||
| 341 | } else if (mode == MAC) { | ||
| 342 | register_code(KC_LALT); | ||
| 343 | tap_code(KC_S); | ||
| 344 | unregister_code(KC_LALT); | ||
| 345 | } else if (mode == WINDOWS) { | ||
| 346 | register_code(KC_RALT); | ||
| 347 | tap_code(KC_2); | ||
| 348 | tap_code(KC_2); | ||
| 349 | tap_code(KC_5); | ||
| 350 | unregister_code(KC_RALT); | ||
| 351 | } | ||
| 352 | return false; | ||
| 353 | |||
| 354 | // Trademark - ™ | ||
| 355 | case RV_TM: | ||
| 356 | if (is_unicode(mode)) { | ||
| 357 | send_unicode_string("™"); | ||
| 358 | } | ||
| 359 | return false; | ||
| 360 | |||
| 361 | // Registered trademark - ® | ||
| 362 | case RV_RT: | ||
| 363 | if (is_unicode(mode)) { | ||
| 364 | send_unicode_string("®"); | ||
| 365 | } | ||
| 366 | return false; | ||
| 367 | |||
| 368 | // Copyright - © | ||
| 369 | case RV_CC: | ||
| 370 | if (is_unicode(mode)) { | ||
| 371 | send_unicode_string("©"); | ||
| 372 | } | ||
| 373 | return false; | ||
| 374 | |||
| 375 | // Degree - ° | ||
| 376 | case RV_DEG: | ||
| 377 | if (is_unicode(mode)) { | ||
| 378 | send_unicode_string("°"); | ||
| 379 | } | ||
| 380 | return false; | ||
| 381 | |||
| 382 | // Plus-minus - ± | ||
| 383 | case RV_PM: | ||
| 384 | if (is_unicode(mode)) { | ||
| 385 | send_unicode_string("±"); | ||
| 386 | } | ||
| 387 | return false; | ||
| 388 | |||
| 389 | // Not equal - ≠ | ||
| 390 | case RV_UNEQ: | ||
| 391 | if (is_unicode(mode)) { | ||
| 392 | send_unicode_string("≠"); | ||
| 393 | } | ||
| 394 | return false; | ||
| 395 | |||
| 396 | // Superscript one - ¹ | ||
| 397 | case RV_SUP1: | ||
| 398 | if (is_unicode(mode)) { | ||
| 399 | send_unicode_string("¹"); | ||
| 400 | } | ||
| 401 | return false; | ||
| 402 | |||
| 403 | // Superscript two - ² | ||
| 404 | case RV_SUP2: | ||
| 405 | if (is_unicode(mode)) { | ||
| 406 | send_unicode_string("²"); | ||
| 407 | } | ||
| 408 | return false; | ||
| 409 | |||
| 410 | // Superscript three - ³ | ||
| 411 | case RV_SUP3: | ||
| 412 | if (is_unicode(mode)) { | ||
| 413 | send_unicode_string("³"); | ||
| 414 | } | ||
| 415 | return false; | ||
| 416 | } | ||
| 417 | |||
| 418 | return true; | ||
| 419 | } | ||
diff --git a/users/rverst/rverst.h b/users/rverst/rverst.h new file mode 100644 index 000000000..b7aea556c --- /dev/null +++ b/users/rverst/rverst.h | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | /* Copyright 2021 Robert Verst <robert@verst.eu> @rverst | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include QMK_KEYBOARD_H | ||
| 20 | |||
| 21 | enum userspace_mode { | ||
| 22 | MAC = 0, | ||
| 23 | WINDOWS, | ||
| 24 | MAC_UNI, | ||
| 25 | WINDOWS_UNI, | ||
| 26 | LINUX_UNI, | ||
| 27 | }; | ||
| 28 | |||
| 29 | enum userspace_keycodes { | ||
| 30 | RV_NON = SAFE_RANGE, | ||
| 31 | RV_SM0, // set Mac Unicode mode | ||
| 32 | RV_SM1, // set Window Unicode mode | ||
| 33 | RV_SM2, // set Linux Unicode mode | ||
| 34 | RV_SM3, // set Mac lagecy mode | ||
| 35 | RV_SM4, // set Windows legacy mode | ||
| 36 | RV_SM0S, // set Mac Unicode mode and save | ||
| 37 | RV_SM1S, // set Windows Unicode mode and save | ||
| 38 | RV_SM2S, // set Linux Unicode and save | ||
| 39 | RV_SM3S, // set Mac legacy mode | ||
| 40 | RV_SM4S, // set Windows legacy and save | ||
| 41 | RV_SAYM, // say mode | ||
| 42 | RV_LOCK, // lock computer | ||
| 43 | RV_AUML, // äÄ | ||
| 44 | RV_OUML, // öÖ | ||
| 45 | RV_UUML, // üÜ | ||
| 46 | RV_EUR, // € | ||
| 47 | RV_SZ, // ß§ | ||
| 48 | RV_TM, // ™ | ||
| 49 | RV_RT, // ® | ||
| 50 | RV_CC, // © | ||
| 51 | RV_DEG, // ° | ||
| 52 | RV_SNAP, // Screenshot | ||
| 53 | RV_PM, // ± | ||
| 54 | RV_UNEQ, // ≠ | ||
| 55 | RV_SUP1, // ¹ | ||
| 56 | RV_SUP2, // ² | ||
| 57 | RV_SUP3, // ³ | ||
| 58 | |||
| 59 | }; | ||
| 60 | |||
| 61 | typedef union { | ||
| 62 | uint32_t raw; | ||
| 63 | struct { | ||
| 64 | bool mode_1 : 1; | ||
| 65 | bool mode_2 : 1; | ||
| 66 | bool mode_3 : 1; | ||
| 67 | }; | ||
| 68 | } userspace_config_t; | ||
| 69 | |||
| 70 | extern userspace_config_t userspace_config; | ||
| 71 | |||
| 72 | uint8_t get_mode(void); | ||
| 73 | void set_mode(uint8_t mode, bool save); | ||
| 74 | void switch_mode(uint8_t mode); | ||
| 75 | bool is_unicode(uint8_t mode); | ||
| 76 | |||
| 77 | void keyboard_pre_init_keymap(void); | ||
| 78 | void keyboard_post_init_keymap(void); | ||
| 79 | void eeconfig_init_keymap(void); | ||
| 80 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record); | ||
| 81 | |||
diff --git a/users/rverst/unicode.h b/users/rverst/unicode.h new file mode 100644 index 000000000..2268ffb59 --- /dev/null +++ b/users/rverst/unicode.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* Copyright 2021 Robert Verst <robert@verst.eu> @rverst | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #ifdef UNICODE_SELECTED_MODES | ||
| 20 | # undef UNICODE_SELECTED_MODES | ||
| 21 | # define UNICODE_SELECTED_MODES UC_MAC, UC_LNX, UC_WINC | ||
| 22 | #endif | ||
| 23 | |||
| 24 | enum unicode_names { BANG, IRONY, SNEK }; | ||
| 25 | |||
| 26 | const uint32_t PROGMEM unicode_map[] = { | ||
| 27 | [BANG] = 0x203D, | ||
| 28 | [IRONY] = 0x2E2E, | ||
| 29 | [SNEK] = 0x1F40D, | ||
| 30 | }; | ||
| 31 | |||
