diff options
| author | QMK Bot <hello@qmk.fm> | 2021-07-01 17:12:52 +0000 |
|---|---|---|
| committer | QMK Bot <hello@qmk.fm> | 2021-07-01 17:12:52 +0000 |
| commit | 0b7936c4e8837cd4e761df3e2ada5b35936e9020 (patch) | |
| tree | 4ddb20653949fb9c28380809a4cd5cba1b099a9a /users | |
| parent | 0bde920817ef458f2ad61a66ce76a2535bbc261b (diff) | |
| parent | bef73f44aacf49d0969e3cdd6718b9a594d49066 (diff) | |
| download | qmk_firmware-0b7936c4e8837cd4e761df3e2ada5b35936e9020.tar.gz qmk_firmware-0b7936c4e8837cd4e761df3e2ada5b35936e9020.zip | |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users')
| -rw-r--r-- | users/haervig/config.h | 19 | ||||
| -rw-r--r-- | users/haervig/haervig.c | 234 | ||||
| -rw-r--r-- | users/haervig/haervig.h | 297 | ||||
| -rw-r--r-- | users/haervig/readme.md | 11 | ||||
| -rw-r--r-- | users/haervig/rules.mk | 5 |
5 files changed, 566 insertions, 0 deletions
diff --git a/users/haervig/config.h b/users/haervig/config.h new file mode 100644 index 000000000..6a7d67737 --- /dev/null +++ b/users/haervig/config.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 Jakob Hærvig <jakob.haervig@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | #define TAPPING_TERM 200 | ||
diff --git a/users/haervig/haervig.c b/users/haervig/haervig.c new file mode 100644 index 000000000..d03b43edc --- /dev/null +++ b/users/haervig/haervig.c | |||
| @@ -0,0 +1,234 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 Jakob Hærvig <jakob.haervig@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "haervig.h" | ||
| 19 | |||
| 20 | #ifdef DANISH_ENABLE | ||
| 21 | // These indicate if left and right shift are physically pressed | ||
| 22 | bool lshift = false; | ||
| 23 | bool rshift = false; | ||
| 24 | |||
| 25 | // Interrupt and times for space cadet shift | ||
| 26 | bool lshiftp = false; | ||
| 27 | bool rshiftp = false; | ||
| 28 | uint16_t lshift_timer = 0; | ||
| 29 | uint16_t rshift_timer = 0; | ||
| 30 | |||
| 31 | // Number of items that are saved in prev_kcs | ||
| 32 | uint8_t prev_indx = 0; | ||
| 33 | // Used to save the last 6 actual keycodes activated by frankenkeycodes | ||
| 34 | uint16_t prev_kcs[6] = {0, 0, 0, 0, 0, 0}; | ||
| 35 | |||
| 36 | // If true the deadkey characters grave and circonflexe are not automatically escaped | ||
| 37 | bool esct = false; | ||
| 38 | |||
| 39 | /* | ||
| 40 | Used to add a keycode to a prev_kcs to remember it. | ||
| 41 | When full the last code gets discarded and replaced by | ||
| 42 | the new one. | ||
| 43 | */ | ||
| 44 | void add_to_prev(uint16_t kc){ | ||
| 45 | for (int i=0; i<prev_indx; i++){ | ||
| 46 | if (kc == prev_kcs[i]) | ||
| 47 | return; | ||
| 48 | } | ||
| 49 | if (prev_indx == 6){ | ||
| 50 | for (int i=5; i>0; i--){ | ||
| 51 | prev_kcs[i] = prev_kcs[i-1]; | ||
| 52 | } | ||
| 53 | prev_kcs[0] = kc; | ||
| 54 | } else { | ||
| 55 | prev_kcs[prev_indx] = kc; | ||
| 56 | prev_indx++; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | /* | ||
| 61 | Unregisters all codes saved in prev_kcs and resets prev_indx. | ||
| 62 | gets called on multiple occasions mainly when shift is released | ||
| 63 | and when frankenkeycodes are pressed. Prevents output of | ||
| 64 | wrong characters when really specific key combinations | ||
| 65 | that would never occur during normal usage are pressed. | ||
| 66 | */ | ||
| 67 | void unreg_prev(void){ | ||
| 68 | if (prev_indx == 0) | ||
| 69 | return; | ||
| 70 | for (int i=0; i<prev_indx; i++){ | ||
| 71 | unregister_code(prev_kcs[i]); | ||
| 72 | } | ||
| 73 | prev_indx = 0; | ||
| 74 | } | ||
| 75 | #endif | ||
| 76 | |||
| 77 | // Interrupt and times for Nav/Esc | ||
| 78 | bool navesc = false; | ||
| 79 | uint16_t navesc_timer = 0; | ||
| 80 | |||
| 81 | // Interrupts all timers | ||
| 82 | void timer_timeout(void){ | ||
| 83 | #ifdef DANISH_ENABLE | ||
| 84 | lshiftp = false; | ||
| 85 | rshiftp = false; | ||
| 86 | #endif | ||
| 87 | navesc = false; | ||
| 88 | timer_timeout_keymap(); | ||
| 89 | } | ||
| 90 | |||
| 91 | __attribute__((weak)) | ||
| 92 | void timer_timeout_keymap(void){ | ||
| 93 | } | ||
| 94 | |||
| 95 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 96 | switch (keycode) { | ||
| 97 | case KC_LGUI: | ||
| 98 | case KC_RGUI: | ||
| 99 | if (record->event.pressed) | ||
| 100 | timer_timeout(); | ||
| 101 | return true; | ||
| 102 | case CU_NAV: | ||
| 103 | if(record->event.pressed) { | ||
| 104 | navesc = true; | ||
| 105 | navesc_timer = timer_read(); | ||
| 106 | layer_on(_NAV); | ||
| 107 | } else { | ||
| 108 | if (timer_elapsed(navesc_timer) < TAPPING_TERM && navesc) { | ||
| 109 | tap_code(KC_ESC); | ||
| 110 | } | ||
| 111 | layer_off(_NAV); | ||
| 112 | } | ||
| 113 | return false; | ||
| 114 | |||
| 115 | #ifdef DANISH_ENABLE | ||
| 116 | case CU_LSFT: | ||
| 117 | if(record->event.pressed) { | ||
| 118 | lshiftp = true; | ||
| 119 | lshift_timer = timer_read(); | ||
| 120 | unregister_code(KC_LSFT); | ||
| 121 | register_code(KC_LSFT); | ||
| 122 | lshift = true; | ||
| 123 | } else { | ||
| 124 | if (timer_elapsed(lshift_timer) < TAPPING_TERM && lshiftp) { | ||
| 125 | register_code(KC_LSFT); | ||
| 126 | tap_code(KC_8); | ||
| 127 | unregister_code(KC_LSFT); | ||
| 128 | } | ||
| 129 | unreg_prev(); | ||
| 130 | if (!rshift) | ||
| 131 | unregister_code(KC_LSFT); | ||
| 132 | lshift = false; | ||
| 133 | } | ||
| 134 | return false; | ||
| 135 | case CU_RSFT: | ||
| 136 | if(record->event.pressed) { | ||
| 137 | rshiftp = true; | ||
| 138 | rshift_timer = timer_read(); | ||
| 139 | unregister_code(KC_LSFT); | ||
| 140 | register_code(KC_LSFT); | ||
| 141 | rshift = true; | ||
| 142 | } else { | ||
| 143 | if (timer_elapsed(rshift_timer) < TAPPING_TERM && rshiftp) { | ||
| 144 | register_code(KC_LSFT); | ||
| 145 | tap_code(KC_9); | ||
| 146 | unregister_code(KC_LSFT); | ||
| 147 | } | ||
| 148 | unreg_prev(); | ||
| 149 | if (!lshift) | ||
| 150 | unregister_code(KC_LSFT); | ||
| 151 | rshift = false; | ||
| 152 | } | ||
| 153 | return false; | ||
| 154 | case CU_COMM: | ||
| 155 | SHIFT_NO(DK_COMM, KC_GRV) | ||
| 156 | case CU_DOT: | ||
| 157 | SHIFT_NORM(DK_DOT, KC_GRV) | ||
| 158 | case CU_SLSH: | ||
| 159 | SHIFT_ALL(DK_7, KC_MINS) | ||
| 160 | case CU_SCLN: | ||
| 161 | SHIFT_ALL(DK_COMM, DK_DOT) | ||
| 162 | case CU_QUOT: | ||
| 163 | SHIFT_NORM(DK_QUOT, DK_2) | ||
| 164 | case CU_2: | ||
| 165 | NORM_ALGR(DK_2, KC_NUHS) | ||
| 166 | case CU_4: | ||
| 167 | if (record->event.pressed) { \ | ||
| 168 | timer_timeout(); \ | ||
| 169 | if (lshift || rshift) { \ | ||
| 170 | register_code(KC_LSFT); \ | ||
| 171 | register_code(KC_ALGR); \ | ||
| 172 | unregister_code(KC_3); \ | ||
| 173 | tap_code(KC_3); \ | ||
| 174 | unregister_code(KC_3); \ | ||
| 175 | } else { \ | ||
| 176 | unregister_code(KC_4); \ | ||
| 177 | tap_code(KC_4); \ | ||
| 178 | } \ | ||
| 179 | unregister_code(KC_ALGR); \ | ||
| 180 | unregister_code(KC_LSFT); \ | ||
| 181 | } \ | ||
| 182 | return false; | ||
| 183 | case CU_6: | ||
| 184 | SHIFT_NORM(DK_6, KC_RBRC) | ||
| 185 | case CU_7: | ||
| 186 | SHIFT_NORM(DK_7, DK_6) | ||
| 187 | case CU_8: | ||
| 188 | SHIFT_NORM(DK_8, KC_NUHS) | ||
| 189 | case CU_9: | ||
| 190 | SHIFT_NORM(DK_9, DK_8) | ||
| 191 | case CU_0: | ||
| 192 | SHIFT_NORM(DK_0, DK_9) | ||
| 193 | case CU_MINS: | ||
| 194 | SHIFT_NORM(KC_SLSH, KC_SLSH) | ||
| 195 | case CU_EQL: | ||
| 196 | SHIFT_SWITCH(DK_0, DK_PLUS) | ||
| 197 | case CU_BSPC: | ||
| 198 | SHIFT_NO(KC_BSPC, KC_DEL) | ||
| 199 | case CU_LBRC: | ||
| 200 | NORM_ALGRSHIFT(DK_8, DK_8) | ||
| 201 | case CU_RBRC: | ||
| 202 | NORM_ALGRSHIFT(DK_9, DK_9) | ||
| 203 | case CU_BSLS: | ||
| 204 | ALGR_SWITCH(DK_7, DK_I) | ||
| 205 | case KC_LCTL: | ||
| 206 | case KC_RCTL: | ||
| 207 | if(!record->event.pressed) { | ||
| 208 | timer_timeout(); | ||
| 209 | unregister_code(KC_Z); | ||
| 210 | unregister_code(KC_Y); | ||
| 211 | } | ||
| 212 | return true; | ||
| 213 | #endif | ||
| 214 | |||
| 215 | default: | ||
| 216 | if(record->event.pressed) { | ||
| 217 | timer_timeout(); | ||
| 218 | |||
| 219 | #ifdef DANISH_ENABLE | ||
| 220 | if (lshift || rshift) | ||
| 221 | register_code(KC_LSFT); | ||
| 222 | else | ||
| 223 | unregister_code(KC_LSFT); | ||
| 224 | #endif | ||
| 225 | |||
| 226 | } | ||
| 227 | return process_record_keymap(keycode, record); | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | __attribute__((weak)) | ||
| 232 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | ||
| 233 | return true; | ||
| 234 | } | ||
diff --git a/users/haervig/haervig.h b/users/haervig/haervig.h new file mode 100644 index 000000000..e0d47e4cc --- /dev/null +++ b/users/haervig/haervig.h | |||
| @@ -0,0 +1,297 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 Jakob Hærvig <jakob.haervig@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "quantum.h" | ||
| 19 | #include "keymap_danish.h" | ||
| 20 | |||
| 21 | enum userspace_layers { | ||
| 22 | _DEADKEY = 14, // Change if more than 16 layers are required | ||
| 23 | _NAV | ||
| 24 | }; | ||
| 25 | |||
| 26 | enum userspace_custom_keycodes { | ||
| 27 | //CU_GAME = SAFE_RANGE, // Toggle game mode on/off | ||
| 28 | CU_NAV = SAFE_RANGE, // NAV | ESC | ||
| 29 | |||
| 30 | #ifdef DANISH_ENABLE | ||
| 31 | CU_LSFT, // LSFT | ( | ||
| 32 | CU_RSFT, // LSFT | ) | ||
| 33 | CU_COMM, // , | < | ||
| 34 | CU_DOT, // . | > | ||
| 35 | CU_SLSH, // / | ? | ||
| 36 | CU_SCLN, // ; | : | ||
| 37 | CU_QUOT, // ' | " | ||
| 38 | CU_2, // 2 | @ | ||
| 39 | CU_4, // 4 | $ | ||
| 40 | CU_6, // 6 | ^ | ||
| 41 | CU_7, // 7 | & | ||
| 42 | CU_8, // 8 | * | ||
| 43 | CU_9, // 9 | ( | ||
| 44 | CU_0, // 0 | ) | ||
| 45 | CU_MINS, // - | _ | ||
| 46 | CU_EQL, // = | + | ||
| 47 | CU_BSPC, // backspace | delete | ||
| 48 | CU_LBRC, // [ | { | ||
| 49 | CU_RBRC, // ] | } | ||
| 50 | CU_BSLS, // \ | | | ||
| 51 | #endif | ||
| 52 | |||
| 53 | NEW_SAFE_RANGE // Use for keymap specific keycodes | ||
| 54 | }; | ||
| 55 | |||
| 56 | #ifdef DANISH_ENABLE | ||
| 57 | extern bool lshift; | ||
| 58 | extern bool rshift; | ||
| 59 | extern bool lshiftp; | ||
| 60 | extern bool rshiftp; | ||
| 61 | extern uint16_t lshift_timer; | ||
| 62 | extern uint16_t rshift_timer; | ||
| 63 | |||
| 64 | extern uint8_t prev_indx; | ||
| 65 | extern uint16_t prev_kcs[6]; | ||
| 66 | void add_to_prev(uint16_t kc); | ||
| 67 | void unreg_prev(void); | ||
| 68 | |||
| 69 | extern bool esct; | ||
| 70 | #endif | ||
| 71 | |||
| 72 | extern bool navesc; | ||
| 73 | extern uint16_t navesc_timer; | ||
| 74 | |||
| 75 | void timer_timeout(void); | ||
| 76 | |||
| 77 | void timer_timeout_keymap(void); | ||
| 78 | |||
| 79 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record); | ||
| 80 | |||
| 81 | #define CTRLX LCTL(KC_X) | ||
| 82 | #define CTRLC LCTL(KC_C) | ||
| 83 | #define CTRLV LCTL(KC_V) | ||
| 84 | |||
| 85 | #define ALTF4 LALT(KC_F4) | ||
| 86 | |||
| 87 | #define GUIU LGUI(KC_UP) | ||
| 88 | #define GUID LGUI(KC_DOWN) | ||
| 89 | #define GUIL LGUI(KC_LEFT) | ||
| 90 | #define GUIR RGUI(KC_RIGHT) | ||
| 91 | |||
| 92 | #define CTLENT CTL_T(KC_ENT) | ||
| 93 | |||
| 94 | #define EMOJI LWIN(KC_DOT) | ||
| 95 | |||
| 96 | /* | ||
| 97 | Templates for Keys, with custom shifted and non shifted Characters | ||
| 98 | */ | ||
| 99 | |||
| 100 | // Normal shift status | ||
| 101 | #define SHIFT_NORM(kc1, kc2) \ | ||
| 102 | if (record->event.pressed) { \ | ||
| 103 | timer_timeout(); \ | ||
| 104 | if (lshift || rshift) { \ | ||
| 105 | register_code(KC_LSFT); \ | ||
| 106 | unregister_code(kc2); \ | ||
| 107 | register_code(kc2); \ | ||
| 108 | add_to_prev(kc2); \ | ||
| 109 | } else { \ | ||
| 110 | unregister_code(KC_LSFT); \ | ||
| 111 | unregister_code(kc1); \ | ||
| 112 | register_code(kc1); \ | ||
| 113 | } \ | ||
| 114 | } else { \ | ||
| 115 | unregister_code(kc1); \ | ||
| 116 | unregister_code(kc2); \ | ||
| 117 | } \ | ||
| 118 | return false; | ||
| 119 | |||
| 120 | // Inverted shift status | ||
| 121 | #define SHIFT_SWITCH(kc1, kc2) \ | ||
| 122 | if (record->event.pressed) { \ | ||
| 123 | timer_timeout(); \ | ||
| 124 | if (lshift || rshift) { \ | ||
| 125 | unregister_code(KC_LSFT); \ | ||
| 126 | unregister_code(kc2); \ | ||
| 127 | register_code(kc2); \ | ||
| 128 | add_to_prev(kc2); \ | ||
| 129 | } else { \ | ||
| 130 | register_code(KC_LSFT); \ | ||
| 131 | unregister_code(kc1); \ | ||
| 132 | register_code(kc1); \ | ||
| 133 | add_to_prev(kc1); \ | ||
| 134 | } \ | ||
| 135 | } else { \ | ||
| 136 | unregister_code(kc1); \ | ||
| 137 | unregister_code(kc2); \ | ||
| 138 | unreg_prev(); \ | ||
| 139 | if (lshift || rshift) \ | ||
| 140 | register_code(KC_LSFT); \ | ||
| 141 | else \ | ||
| 142 | unregister_code(KC_LSFT); \ | ||
| 143 | } \ | ||
| 144 | return false; | ||
| 145 | |||
| 146 | // Always shifted | ||
| 147 | #define SHIFT_ALL(kc1, kc2) \ | ||
| 148 | if (record->event.pressed) { \ | ||
| 149 | timer_timeout(); \ | ||
| 150 | register_code(KC_LSFT); \ | ||
| 151 | if (lshift || rshift) { \ | ||
| 152 | tap_code(kc2); \ | ||
| 153 | add_to_prev(kc2); \ | ||
| 154 | } else { \ | ||
| 155 | tap_code(kc1); \ | ||
| 156 | add_to_prev(kc1); \ | ||
| 157 | } \ | ||
| 158 | } else { \ | ||
| 159 | unregister_code(kc1); \ | ||
| 160 | unregister_code(kc2); \ | ||
| 161 | unreg_prev(); \ | ||
| 162 | if (lshift || rshift) \ | ||
| 163 | register_code(KC_LSFT); \ | ||
| 164 | else \ | ||
| 165 | unregister_code(KC_LSFT); \ | ||
| 166 | } \ | ||
| 167 | return false; | ||
| 168 | |||
| 169 | // Never shifted | ||
| 170 | #define SHIFT_NO(kc1, kc2) \ | ||
| 171 | if (record->event.pressed) { \ | ||
| 172 | timer_timeout(); \ | ||
| 173 | unregister_code(KC_LSFT); \ | ||
| 174 | if (lshift || rshift) { \ | ||
| 175 | tap_code(kc2); \ | ||
| 176 | add_to_prev(kc2); \ | ||
| 177 | } else { \ | ||
| 178 | tap_code(kc1); \ | ||
| 179 | } \ | ||
| 180 | } else { \ | ||
| 181 | unregister_code(kc1); \ | ||
| 182 | unregister_code(kc2); \ | ||
| 183 | unreg_prev(); \ | ||
| 184 | if (lshift || rshift) \ | ||
| 185 | register_code(KC_LSFT); \ | ||
| 186 | else \ | ||
| 187 | unregister_code(KC_LSFT); \ | ||
| 188 | } \ | ||
| 189 | return false; | ||
| 190 | |||
| 191 | // Norm AltGr | ||
| 192 | #define NORM_ALGR(kc1, kc2) \ | ||
| 193 | if (record->event.pressed) { \ | ||
| 194 | timer_timeout(); \ | ||
| 195 | if (lshift || rshift) { \ | ||
| 196 | register_code(KC_ALGR); \ | ||
| 197 | unregister_code(KC_LSFT); \ | ||
| 198 | tap_code(kc2); \ | ||
| 199 | unregister_code(KC_ALGR); \ | ||
| 200 | } else { \ | ||
| 201 | unregister_code(KC_ALGR); \ | ||
| 202 | unregister_code(KC_LSFT); \ | ||
| 203 | tap_code(kc1); \ | ||
| 204 | } \ | ||
| 205 | } else { \ | ||
| 206 | unregister_code(kc1); \ | ||
| 207 | unregister_code(kc2); \ | ||
| 208 | } \ | ||
| 209 | return false; | ||
| 210 | |||
| 211 | // Norm AltGr shift | ||
| 212 | #define NORM_ALGRSHIFT(kc1, kc2) \ | ||
| 213 | if (record->event.pressed) { \ | ||
| 214 | timer_timeout(); \ | ||
| 215 | register_code(KC_LSFT); \ | ||
| 216 | register_code(KC_ALGR); \ | ||
| 217 | if (lshift || rshift) { \ | ||
| 218 | unregister_code(kc2); \ | ||
| 219 | tap_code(kc2); \ | ||
| 220 | unregister_code(KC_LSFT); \ | ||
| 221 | } else { \ | ||
| 222 | unregister_code(KC_LSFT); \ | ||
| 223 | unregister_code(kc1); \ | ||
| 224 | register_code(kc1); \ | ||
| 225 | } \ | ||
| 226 | unregister_code(KC_ALGR); \ | ||
| 227 | } else { \ | ||
| 228 | unregister_code(kc1); \ | ||
| 229 | unregister_code(kc2); \ | ||
| 230 | } \ | ||
| 231 | return false; | ||
| 232 | |||
| 233 | // Inverted altgr status | ||
| 234 | #define ALGR_SWITCH(kc1, kc2) \ | ||
| 235 | if (record->event.pressed) { \ | ||
| 236 | timer_timeout(); \ | ||
| 237 | register_code(KC_ALGR); \ | ||
| 238 | if (lshift || rshift) { \ | ||
| 239 | unregister_code(KC_LSFT); \ | ||
| 240 | unregister_code(kc2); \ | ||
| 241 | register_code(kc2); \ | ||
| 242 | unregister_code(KC_ALGR); \ | ||
| 243 | add_to_prev(kc2); \ | ||
| 244 | } else { \ | ||
| 245 | register_code(KC_LSFT); \ | ||
| 246 | unregister_code(kc1); \ | ||
| 247 | register_code(kc1); \ | ||
| 248 | unregister_code(KC_ALGR); \ | ||
| 249 | add_to_prev(kc1); \ | ||
| 250 | } \ | ||
| 251 | } else { \ | ||
| 252 | unregister_code(kc1); \ | ||
| 253 | unregister_code(kc2); \ | ||
| 254 | unreg_prev(); \ | ||
| 255 | if (lshift || rshift) \ | ||
| 256 | register_code(KC_LSFT); \ | ||
| 257 | else \ | ||
| 258 | unregister_code(KC_LSFT); \ | ||
| 259 | } \ | ||
| 260 | return false; | ||
| 261 | |||
| 262 | // Always AltGr | ||
| 263 | #define SHIFT_ALGR(kc1, kc2) \ | ||
| 264 | if (record->event.pressed) { \ | ||
| 265 | timer_timeout(); \ | ||
| 266 | unregister_code(KC_LSFT); \ | ||
| 267 | register_code(KC_ALGR); \ | ||
| 268 | if (lshift || rshift) { \ | ||
| 269 | unregister_code(kc2); \ | ||
| 270 | tap_code(kc2); \ | ||
| 271 | register_code(KC_LSFT); \ | ||
| 272 | } else { \ | ||
| 273 | unregister_code(kc1); \ | ||
| 274 | tap_code(kc1); \ | ||
| 275 | } \ | ||
| 276 | unregister_code(KC_ALGR); \ | ||
| 277 | } \ | ||
| 278 | return false; | ||
| 279 | |||
| 280 | // Different keycode when Ctrl is pressed | ||
| 281 | #define CTRL(kc1, kc2) \ | ||
| 282 | if(record->event.pressed) { \ | ||
| 283 | timer_timeout(); \ | ||
| 284 | if (lshift || rshift) \ | ||
| 285 | register_code(KC_LSFT); \ | ||
| 286 | else \ | ||
| 287 | unregister_code(KC_LSFT); \ | ||
| 288 | if (keyboard_report->mods & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL))){ \ | ||
| 289 | register_code(kc2); \ | ||
| 290 | } else { \ | ||
| 291 | register_code(kc1); \ | ||
| 292 | } \ | ||
| 293 | } else { \ | ||
| 294 | unregister_code(kc1); \ | ||
| 295 | unregister_code(kc2); \ | ||
| 296 | } \ | ||
| 297 | return false; | ||
diff --git a/users/haervig/readme.md b/users/haervig/readme.md new file mode 100644 index 000000000..dc2ebbd13 --- /dev/null +++ b/users/haervig/readme.md | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | # haervig Userspace | ||
| 2 | |||
| 3 | This userspace keeps my userdefined codes. I work on a ANSI keyboard on a Danish macOS system. I believe this code might be relevant for similar users. A big shout out to user spacebarracecar for the ideas on how to map keys, which served as the basis of this code. | ||
| 4 | |||
| 5 | ## US Layout Keys for Danish PCs | ||
| 6 | |||
| 7 | By daily work involves a lot of coding. I find an ANSI layout superior and decided to buy a QMK keyboard. However, all PC's here in Denmark are set to input language Danish. Even though I could simply set input language language to US international, I find this inconvenient. I instead decided to map my keys so the ANSI keyboard would will function as expected when the OS inputn language is Danish. | ||
| 8 | |||
| 9 | ## More details | ||
| 10 | |||
| 11 | Tracking the current state of the shift code is nessesary for it to work. User spacebarracecar has documented the idea thoroughly and should serve you as a starting point if you wish to implement this code. I modified the code to suit Danish input language. Additionally, a couple of functions were added to accomodate the altgr key. \ No newline at end of file | ||
diff --git a/users/haervig/rules.mk b/users/haervig/rules.mk new file mode 100644 index 000000000..e06647ff2 --- /dev/null +++ b/users/haervig/rules.mk | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | SRC += haervig.c | ||
| 2 | |||
| 3 | ifeq ($(strip $(DANISH_ENABLE)), yes) | ||
| 4 | OPT_DEFS += -DDANISH_ENABLE | ||
| 5 | endif | ||
