diff options
| author | uqs <uqs@FreeBSD.org> | 2022-02-12 04:22:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-11 19:22:47 -0800 |
| commit | 40529e89de5a49b6d7978aedef9dd425d24f746d (patch) | |
| tree | 2127329443049d59b133446483fd760877710025 /users/uqs | |
| parent | 8b48bab54f7af72a2c073961b4faf2e7495e239c (diff) | |
| download | qmk_firmware-40529e89de5a49b6d7978aedef9dd425d24f746d.tar.gz qmk_firmware-40529e89de5a49b6d7978aedef9dd425d24f746d.zip | |
[Keymap] Add uqs' keymaps for various boards and ploopy mouse (#16265)
Diffstat (limited to 'users/uqs')
| -rw-r--r-- | users/uqs/config.h | 40 | ||||
| -rw-r--r-- | users/uqs/rules.mk | 24 | ||||
| -rw-r--r-- | users/uqs/uqs.c | 584 | ||||
| -rw-r--r-- | users/uqs/uqs.h | 77 |
4 files changed, 725 insertions, 0 deletions
diff --git a/users/uqs/config.h b/users/uqs/config.h new file mode 100644 index 000000000..b8a140fe8 --- /dev/null +++ b/users/uqs/config.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // Copyright 2022 Ulrich Spörlein (@uqs) | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #ifdef RGBLIGHT_ENABLE | ||
| 6 | # define RGBLIGHT_SLEEP | ||
| 7 | //# define RGBLIGHT_ANIMATIONS // disabled to save space | ||
| 8 | # define RGBLIGHT_LAYERS | ||
| 9 | # define RGBLIGHT_MAX_LAYERS 8 // default is 16 | ||
| 10 | # define RGBLIGHT_DISABLE_KEYCODES // RGB_foo keys no longer work, saves 600 bytes | ||
| 11 | # define RGBLIGHT_DEFAULT_HUE 15 | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #define DYNAMIC_KEYMAP_LAYER_COUNT 6 // default is 4 for VIA builds | ||
| 15 | |||
| 16 | #define TAPPING_TOGGLE 2 // number of taps for a toggle-on-tap | ||
| 17 | #define TAPPING_TERM 170 // ms to trigger tap | ||
| 18 | // https://precondition.github.io/home-row-mods | ||
| 19 | #define TAPPING_FORCE_HOLD // make tap-then-hold _not_ do key auto repeat | ||
| 20 | #define IGNORE_MOD_TAP_INTERRUPT | ||
| 21 | #define PERMISSIVE_HOLD // I don't think this works for me, hence I rolled my own implementation. | ||
| 22 | |||
| 23 | #define LEADER_TIMEOUT 400 | ||
| 24 | #define LEADER_PER_KEY_TIMING | ||
| 25 | |||
| 26 | #define UNICODE_SELECTED_MODES UC_LNX | ||
| 27 | |||
| 28 | // make KC_ACL0 et al work when held. | ||
| 29 | #define MK_COMBINED | ||
| 30 | #define MOUSEKEY_WHEEL_INTERVAL 40 // default is 50, lower means more scroll events, 40 works ok. | ||
| 31 | |||
| 32 | // From https://michael.stapelberg.ch/posts/2021-05-08-keyboard-input-latency-qmk-kinesis/ | ||
| 33 | #define USB_POLLING_INTERVAL_MS 1 | ||
| 34 | |||
| 35 | #ifdef KEYBOARD_preonic_rev3 | ||
| 36 | // Some games seem to not register Esc otherwise when tapped, maybe try with this delay? | ||
| 37 | # define TAP_CODE_DELAY 30 | ||
| 38 | #else | ||
| 39 | # define TAP_CODE_DELAY 10 | ||
| 40 | #endif | ||
diff --git a/users/uqs/rules.mk b/users/uqs/rules.mk new file mode 100644 index 000000000..605036295 --- /dev/null +++ b/users/uqs/rules.mk | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | # don't include for keyboards/ploopyco/mouse/keymaps/uqs | ||
| 2 | ifeq ($(filter $(strip $(KEYBOARD)),ploopyco/mouse),) | ||
| 3 | SRC += uqs.c | ||
| 4 | |||
| 5 | RGBLIGHT_ENABLE ?= yes # Enable keyboard RGB underglow | ||
| 6 | LTO_ENABLE ?= yes # disables the legacy TMK Macros and Functions features | ||
| 7 | |||
| 8 | UCIS_ENABLE = yes | ||
| 9 | LEADER_ENABLE = yes | ||
| 10 | COMBO_ENABLE = yes | ||
| 11 | MOUSEKEY_ENABLE = yes | ||
| 12 | |||
| 13 | # Disable all the unused stuff. | ||
| 14 | SPACE_CADET_ENABLE = no | ||
| 15 | COMMAND_ENABLE = no | ||
| 16 | MAGIC_ENABLE = no | ||
| 17 | endif | ||
| 18 | |||
| 19 | # From https://michael.stapelberg.ch/posts/2021-05-08-keyboard-input-latency-qmk-kinesis/ | ||
| 20 | # adds about 900 bytes! Don't use it on puny AVR though. | ||
| 21 | # ifeq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162)) # doesn't work MCU not set yet | ||
| 22 | ifneq (,$(filter $(KEYBOARD),ploopyco/mouse preonic/rev3)) | ||
| 23 | DEBOUNCE_TYPE = asym_eager_defer_pk | ||
| 24 | endif | ||
diff --git a/users/uqs/uqs.c b/users/uqs/uqs.c new file mode 100644 index 000000000..72284143c --- /dev/null +++ b/users/uqs/uqs.c | |||
| @@ -0,0 +1,584 @@ | |||
| 1 | // Copyright 2022 Ulrich Spörlein (@uqs) | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | // vi:et sw=4: | ||
| 4 | |||
| 5 | #include "uqs.h" | ||
| 6 | |||
| 7 | // LOG: | ||
| 8 | // late Jan 2020, got Ohkeycaps Dactyl Manuform 5x6 | ||
| 9 | // https://play.typeracer.com shows about 75-80wpm (en) or ~400cpm (de) on my classic keeb. | ||
| 10 | // Never did proper touch typing, basically didn't use ring finger much, mostly index/middle and pinky (only to hold down modifiers, really). | ||
| 11 | // Feb 2020, switching to Colemak DH after 30 years of Qwerty, uh oh... | ||
| 12 | // mid Feb, 20wpm/87% on monkeytype.com (no punct, numbers) | ||
| 13 | // early March, 28wpm/90% on MT (plus punct./numbers from here on); 25wpm on typeracer | ||
| 14 | // early April, 35wpm/92% on MT; 41wpm on typeracer | ||
| 15 | // early May, 45wpm/96% on MT; 46wpm on typeracer; my qwerty is deteriorating, I need to look at the keys more and more o_O | ||
| 16 | // early June, 49wpm/95% on MT (sigh ...); 50wpm on typeracer; | ||
| 17 | // early July, 50wpm/96% on MT (...); 52wpm/96% on typeracer; | ||
| 18 | // early August, 55wpm/96% on MT; 55wpm/98% on typeracer; | ||
| 19 | // early September, 57wpm/97% on MT; 58wpm/97% on typeracer; | ||
| 20 | // early October, 59wpm/96% on MT; 61wpm/97% on typeracer; | ||
| 21 | // November, 56wpm/97% on MT; 62wpm/98% on typeracer; | ||
| 22 | // December, 62wpm/96% on MT; 66wpm/98% on typeracer; | ||
| 23 | // January, 61wpm/97% on MT; 65wpm/98% on typeracer; | ||
| 24 | // February, 64wpm/97% on MT; 67wpm/98% on typeracer; my qwerty on the laptop is still fine, but I miss my shortcuts badly. | ||
| 25 | // | ||
| 26 | // So that's one year on Colemak. Was it worth the switch? Probably not, though | ||
| 27 | // I also had to first learn proper technique, but that was actually swift, as | ||
| 28 | // the keyboard nicely forces that on you. I really like home row mods though, | ||
| 29 | // they are so comfy. Need to rethink my combos some more, still. | ||
| 30 | |||
| 31 | |||
| 32 | #ifdef RGBLIGHT_LAYERS | ||
| 33 | layer_state_t default_layer_state_set_user(layer_state_t state) { | ||
| 34 | rgblight_set_layer_state(L_QWER, layer_state_cmp(state, L_QWER)); | ||
| 35 | rgblight_set_layer_state(L_WASD, layer_state_cmp(state, L_WASD)); | ||
| 36 | rgblight_set_layer_state(L_COLM, layer_state_cmp(state, L_COLM)); | ||
| 37 | return state; | ||
| 38 | } | ||
| 39 | #endif | ||
| 40 | |||
| 41 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 42 | #if 0 | ||
| 43 | // defining layer L_FUNC when both keys are pressed | ||
| 44 | state = update_tri_layer_state(state, L_EXTD, L_NUM, L_FUNC); | ||
| 45 | #endif | ||
| 46 | #ifdef RGBLIGHT_LAYERS | ||
| 47 | rgblight_set_layer_state(L_EXTD, layer_state_cmp(state, L_EXTD)); | ||
| 48 | rgblight_set_layer_state(L_NUM, layer_state_cmp(state, L_NUM)); | ||
| 49 | rgblight_set_layer_state(L_FUNC, layer_state_cmp(state, L_FUNC)); | ||
| 50 | rgblight_set_layer_state(L_MOUSE, layer_state_cmp(state, L_MOUSE)); | ||
| 51 | #else | ||
| 52 | #endif | ||
| 53 | return state; | ||
| 54 | } | ||
| 55 | |||
| 56 | #ifdef RGBLIGHT_LAYERS | ||
| 57 | // NOTE: at most 2 elements, last one needs to be RGBLIGHT_END_SEGMENTS | ||
| 58 | typedef rgblight_segment_t rgblight_layer_t[3]; | ||
| 59 | |||
| 60 | const rgblight_layer_t PROGMEM my_rgb_segments[] = { | ||
| 61 | [L_QWER] = {{0, RGBLED_NUM, HSV_WHITE}, RGBLIGHT_END_SEGMENTS}, | ||
| 62 | [L_WASD] = {{0, RGBLED_NUM/2, HSV_RED}, {RGBLED_NUM/2, RGBLED_NUM/2, HSV_OFF}, RGBLIGHT_END_SEGMENTS}, | ||
| 63 | [L_COLM] = {{0, RGBLED_NUM, HSV_GREEN}, RGBLIGHT_END_SEGMENTS}, | ||
| 64 | [L_EXTD] = {{0, RGBLED_NUM, HSV_BLUE}, RGBLIGHT_END_SEGMENTS}, | ||
| 65 | [L_NUM] = {{0, RGBLED_NUM, HSV_ORANGE}, RGBLIGHT_END_SEGMENTS}, | ||
| 66 | [L_FUNC] = {{0, RGBLED_NUM, HSV_YELLOW}, RGBLIGHT_END_SEGMENTS}, | ||
| 67 | [L_MOUSE]= {{0, RGBLED_NUM, HSV_PURPLE}, RGBLIGHT_END_SEGMENTS}, | ||
| 68 | }; | ||
| 69 | |||
| 70 | // This array needs pointers, :/ | ||
| 71 | const rgblight_segment_t* const PROGMEM my_rgb_layers[] = { | ||
| 72 | my_rgb_segments[L_QWER], | ||
| 73 | my_rgb_segments[L_WASD], | ||
| 74 | my_rgb_segments[L_COLM], | ||
| 75 | my_rgb_segments[L_EXTD], | ||
| 76 | my_rgb_segments[L_NUM], | ||
| 77 | my_rgb_segments[L_FUNC], | ||
| 78 | my_rgb_segments[L_MOUSE], | ||
| 79 | }; | ||
| 80 | |||
| 81 | _Static_assert(sizeof(my_rgb_layers) / sizeof(my_rgb_layers[0]) == | ||
| 82 | sizeof(my_rgb_segments) / sizeof(my_rgb_segments[0]), | ||
| 83 | "Number of rgb_segment definitions does not match up!"); | ||
| 84 | #endif | ||
| 85 | |||
| 86 | #ifdef COMBO_ENABLE | ||
| 87 | enum combo_events { | ||
| 88 | C_AUML, | ||
| 89 | C_OUML, | ||
| 90 | C_UUML, | ||
| 91 | C_SZ, | ||
| 92 | C_CBR, | ||
| 93 | C_PRN, | ||
| 94 | C_BRC, | ||
| 95 | }; | ||
| 96 | |||
| 97 | // Maybe use this? | ||
| 98 | // #define COMBO_ONLY_FROM_LAYER L_COLM | ||
| 99 | |||
| 100 | // The official way has way too much duplication and intermediate names for my taste... | ||
| 101 | const uint16_t PROGMEM my_action_combos[][3] = { | ||
| 102 | [C_AUML] = {KC_G_A, KC_W, COMBO_END}, | ||
| 103 | [C_OUML] = {KC_G_O, KC_Y, COMBO_END}, | ||
| 104 | [C_UUML] = {KC_C_N, KC_U, COMBO_END}, | ||
| 105 | [C_SZ] = {KC_S_S, KC_Z, COMBO_END}, | ||
| 106 | [C_CBR] = {KC_COLN, KC_LCBR, COMBO_END}, | ||
| 107 | [C_PRN] = {KC_LCBR, KC_LPRN, COMBO_END}, | ||
| 108 | [C_BRC] = {KC_LPRN, KC_LBRC, COMBO_END}, | ||
| 109 | }; | ||
| 110 | const uint16_t PROGMEM my_combos[][4] = { | ||
| 111 | {KC_LPRN, KC_F, KC_P, COMBO_END}, | ||
| 112 | {KC_RPRN, KC_C, KC_D, COMBO_END}, | ||
| 113 | {KC_LCBR, KC_W, KC_F, COMBO_END}, | ||
| 114 | {KC_RCBR, KC_X, KC_C, COMBO_END}, | ||
| 115 | {KC_TAB, KC_G_A, KC_A_R, COMBO_END}, | ||
| 116 | {KC_BSLS, KC_B, KC_J, COMBO_END}, // remove this? | ||
| 117 | {KC_BSLS, KC_F, KC_U, COMBO_END}, | ||
| 118 | {LSFT(KC_BSLS), KC_P, KC_L, COMBO_END}, | ||
| 119 | {KC_MINUS, KC_C_T, KC_C_N, COMBO_END}, | ||
| 120 | {LSFT(KC_MINUS), KC_D, KC_H, COMBO_END}, | ||
| 121 | {KC_GRV, KC_Q, KC_W, COMBO_END}, // remove this? | ||
| 122 | {KC_GRV, KC_C, KC_COMM, COMBO_END}, | ||
| 123 | {LSFT(KC_GRV), KC_G, KC_M, COMBO_END}, | ||
| 124 | {KC_BTN3, KC_BTN1, KC_BTN2, COMBO_END}, | ||
| 125 | {KC_BTN1, KC_BTN2, KC_BTN3, COMBO_END}, | ||
| 126 | }; | ||
| 127 | |||
| 128 | const uint16_t COMBO_LEN = sizeof(my_action_combos) / sizeof(my_action_combos[0]) + sizeof(my_combos) / sizeof(my_combos[0]); | ||
| 129 | |||
| 130 | #define MY_ACTION_COMBO(ck) \ | ||
| 131 | [ck] = { .keys = &(my_action_combos[ck][0]) } | ||
| 132 | #define MY_COMBO(ck) \ | ||
| 133 | { .keys = &(my_combos[ck][1]), .keycode = my_combos[ck][0] } | ||
| 134 | |||
| 135 | // NOTE: while my_combos can live in PROGMEM, the key_combos data also | ||
| 136 | // contains state that is tweaked at runtime, so we need to indirect. Ugh. | ||
| 137 | #define COMBO_STATICALLY | ||
| 138 | #ifdef COMBO_STATICALLY | ||
| 139 | // TODO: fill this at runtime with a loop? | ||
| 140 | combo_t key_combos[] = { | ||
| 141 | MY_ACTION_COMBO(0), | ||
| 142 | MY_ACTION_COMBO(1), | ||
| 143 | MY_ACTION_COMBO(2), | ||
| 144 | MY_ACTION_COMBO(3), | ||
| 145 | MY_ACTION_COMBO(4), | ||
| 146 | MY_ACTION_COMBO(5), | ||
| 147 | MY_ACTION_COMBO(6), | ||
| 148 | MY_COMBO(0), | ||
| 149 | MY_COMBO(1), | ||
| 150 | MY_COMBO(2), | ||
| 151 | MY_COMBO(3), | ||
| 152 | MY_COMBO(4), | ||
| 153 | MY_COMBO(5), | ||
| 154 | MY_COMBO(6), | ||
| 155 | MY_COMBO(7), | ||
| 156 | MY_COMBO(8), | ||
| 157 | MY_COMBO(9), | ||
| 158 | MY_COMBO(10), | ||
| 159 | MY_COMBO(11), | ||
| 160 | MY_COMBO(12), | ||
| 161 | MY_COMBO(13), | ||
| 162 | MY_COMBO(14), | ||
| 163 | }; | ||
| 164 | |||
| 165 | _Static_assert(sizeof(key_combos) / sizeof(key_combos[0]) == | ||
| 166 | (sizeof(my_action_combos) / sizeof(my_action_combos[0]) + sizeof(my_combos) / sizeof(my_combos[0])), | ||
| 167 | "Number of combo definitions does not match up!"); | ||
| 168 | #else | ||
| 169 | combo_t key_combos[sizeof(my_action_combos) / sizeof(my_action_combos[0]) + sizeof(my_combos) / sizeof(my_combos[0])]; | ||
| 170 | #endif | ||
| 171 | |||
| 172 | void process_combo_event(uint16_t combo_index, bool pressed) { | ||
| 173 | switch (combo_index) { | ||
| 174 | case C_AUML: | ||
| 175 | if (pressed) { | ||
| 176 | tap_code16(KC_RALT); | ||
| 177 | tap_code16(LSFT(KC_QUOT)); | ||
| 178 | tap_code16(KC_A); | ||
| 179 | } | ||
| 180 | break; | ||
| 181 | case C_OUML: | ||
| 182 | if (pressed) { | ||
| 183 | tap_code16(KC_RALT); | ||
| 184 | tap_code16(LSFT(KC_QUOT)); | ||
| 185 | tap_code16(KC_O); | ||
| 186 | } | ||
| 187 | break; | ||
| 188 | case C_UUML: | ||
| 189 | if (pressed) { | ||
| 190 | tap_code16(KC_RALT); | ||
| 191 | tap_code16(LSFT(KC_QUOT)); | ||
| 192 | tap_code16(KC_U); | ||
| 193 | } | ||
| 194 | break; | ||
| 195 | case C_SZ: | ||
| 196 | if (pressed) { | ||
| 197 | tap_code16(KC_RALT); | ||
| 198 | tap_code16(KC_S); | ||
| 199 | tap_code16(KC_S); | ||
| 200 | } | ||
| 201 | break; | ||
| 202 | case C_CBR: | ||
| 203 | if (pressed) { | ||
| 204 | tap_code16(KC_LCBR); | ||
| 205 | tap_code16(KC_RCBR); | ||
| 206 | tap_code16(KC_LEFT); | ||
| 207 | } | ||
| 208 | break; | ||
| 209 | case C_PRN: | ||
| 210 | if (pressed) { | ||
| 211 | tap_code16(KC_LPRN); | ||
| 212 | tap_code16(KC_RPRN); | ||
| 213 | tap_code16(KC_LEFT); | ||
| 214 | } | ||
| 215 | break; | ||
| 216 | case C_BRC: | ||
| 217 | if (pressed) { | ||
| 218 | tap_code16(KC_LBRC); | ||
| 219 | tap_code16(KC_RBRC); | ||
| 220 | tap_code16(KC_LEFT); | ||
| 221 | } | ||
| 222 | break; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | #endif | ||
| 226 | |||
| 227 | void keyboard_post_init_user(void) { | ||
| 228 | #ifndef KEYBOARD_preonic_rev3 | ||
| 229 | default_layer_set(1ul << L_COLM); | ||
| 230 | #endif | ||
| 231 | #ifdef RGBLIGHT_LAYERS | ||
| 232 | // Enable the LED layers | ||
| 233 | rgblight_layers = my_rgb_layers; | ||
| 234 | rgblight_set_layer_state(0, true); | ||
| 235 | #endif | ||
| 236 | #if defined(COMBO_ENABLE) && !defined(COMBO_STATICALLY) | ||
| 237 | uint8_t i = 0; | ||
| 238 | for (; i < sizeof(my_action_combos) / sizeof(my_action_combos[0]); i++) { | ||
| 239 | key_combos[i].keys = &(my_action_combos[i][0]); | ||
| 240 | } | ||
| 241 | for (uint8_t j = 0; j < sizeof(my_combos) / sizeof(my_combos[0]); j++, i++) { | ||
| 242 | key_combos[i].keycode = my_combos[j][0]; | ||
| 243 | key_combos[i].keys = &(my_combos[j][1]); | ||
| 244 | } | ||
| 245 | #endif | ||
| 246 | } | ||
| 247 | |||
| 248 | uint16_t key_timer; | ||
| 249 | bool delkey_registered; | ||
| 250 | bool num_layer_was_used; | ||
| 251 | bool extd_layer_was_used; | ||
| 252 | // These keep state about the long-press-means-umlaut keys. | ||
| 253 | bool auml_pressed; | ||
| 254 | bool ouml_pressed; | ||
| 255 | bool uuml_pressed; | ||
| 256 | |||
| 257 | void maybe_send_umlaut(uint16_t keycode, bool *is_pressed) { | ||
| 258 | // Some other key did _not_ already re-arm this key, so now we need to do | ||
| 259 | // that ourselves. | ||
| 260 | if (*is_pressed) { | ||
| 261 | *is_pressed = false; | ||
| 262 | // If released within the timer, then just KC_A, KC_O, KC_U | ||
| 263 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 264 | tap_code16(keycode); | ||
| 265 | } else { | ||
| 266 | tap_code16(KC_RALT); | ||
| 267 | tap_code16(LSFT(KC_QUOT)); | ||
| 268 | tap_code16(keycode); | ||
| 269 | } | ||
| 270 | } | ||
| 271 | } | ||
| 272 | |||
| 273 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 274 | // TODO: why not use key_timer here? is it dynamic or not? | ||
| 275 | static uint16_t extd_layer_timer; | ||
| 276 | if (layer_state_is(L_EXTD) && record->event.pressed) { | ||
| 277 | extd_layer_was_used = true; | ||
| 278 | } | ||
| 279 | if (layer_state_is(L_NUM) && record->event.pressed) { | ||
| 280 | num_layer_was_used = true; | ||
| 281 | } | ||
| 282 | |||
| 283 | // An umlaut key was pressed previously (but will only emit the key on | ||
| 284 | // release), but we've pressed a different key now, so fire the regular key, | ||
| 285 | // re-arm it and continue with whatever actual key was pressed just now. | ||
| 286 | if (record->event.pressed) { | ||
| 287 | if (auml_pressed) { | ||
| 288 | tap_code16(KC_A); | ||
| 289 | auml_pressed = false; | ||
| 290 | } | ||
| 291 | if (ouml_pressed) { | ||
| 292 | tap_code16(KC_O); | ||
| 293 | ouml_pressed = false; | ||
| 294 | } | ||
| 295 | if (uuml_pressed) { | ||
| 296 | tap_code16(KC_U); | ||
| 297 | uuml_pressed = false; | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | switch (keycode) { | ||
| 302 | // From https://github.com/qmk/qmk_firmware/issues/6053 | ||
| 303 | case LT_EXTD_ESC: | ||
| 304 | if (record->event.pressed) { | ||
| 305 | extd_layer_was_used = false; | ||
| 306 | extd_layer_timer = timer_read(); | ||
| 307 | layer_on(L_EXTD); | ||
| 308 | } else { | ||
| 309 | layer_off(L_EXTD); | ||
| 310 | unregister_mods(MOD_BIT(KC_LALT)); // undo what ALT_TAB might've set | ||
| 311 | // NOTE: need to track whether we made use of the extd layer and | ||
| 312 | // that all happened within the tapping term. Otherwise we'd emit | ||
| 313 | // that layer key code _plus_ an extra Esc. | ||
| 314 | if (timer_elapsed(extd_layer_timer) < TAPPING_TERM && !extd_layer_was_used) { | ||
| 315 | tap_code(KC_ESC); | ||
| 316 | } | ||
| 317 | } | ||
| 318 | return true; | ||
| 319 | case LT_NUM_BSPC: | ||
| 320 | if (record->event.pressed){ | ||
| 321 | num_layer_was_used = false; | ||
| 322 | extd_layer_timer = timer_read(); | ||
| 323 | layer_on(L_NUM); | ||
| 324 | } else { | ||
| 325 | layer_off(L_NUM); | ||
| 326 | // NOTE: Custom LT method so that any press of a key on that layer will prevent the backspace. | ||
| 327 | if (timer_elapsed(extd_layer_timer) < TAPPING_TERM && !num_layer_was_used) { | ||
| 328 | tap_code(KC_BSPC); | ||
| 329 | } | ||
| 330 | } | ||
| 331 | return true; | ||
| 332 | case LT_MOUSE_ALT_SHIFT_INS: | ||
| 333 | if (record->event.pressed) { | ||
| 334 | key_timer = timer_read(); | ||
| 335 | layer_on(L_MOUSE); | ||
| 336 | } else { | ||
| 337 | layer_off(L_MOUSE); | ||
| 338 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 339 | tap_code16(LALT(LSFT(KC_INS))); | ||
| 340 | } | ||
| 341 | } | ||
| 342 | return true; | ||
| 343 | case LT_FUNC_SHIFT_INS: | ||
| 344 | if (record->event.pressed) { | ||
| 345 | key_timer = timer_read(); | ||
| 346 | layer_on(L_FUNC); | ||
| 347 | } else { | ||
| 348 | layer_off(L_FUNC); | ||
| 349 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 350 | tap_code16(LSFT(KC_INS)); | ||
| 351 | } | ||
| 352 | } | ||
| 353 | return true; | ||
| 354 | #if 1 | ||
| 355 | /* Looks like PERMISSIVE_HOLD on LT and OSM doesn't work properly. This | ||
| 356 | * is probaby https://github.com/qmk/qmk_firmware/issues/8971 | ||
| 357 | */ | ||
| 358 | case OSM_GUI: | ||
| 359 | /* OSM(MOD_LGUI) is delaying the event, but I need immediate triggering | ||
| 360 | * of the modifier to move windows around with the mouse. If only | ||
| 361 | * tapped, however, have it be a win OSM */ | ||
| 362 | if (record->event.pressed) { | ||
| 363 | key_timer = timer_read(); | ||
| 364 | register_mods(MOD_BIT(KC_LGUI)); | ||
| 365 | } else { | ||
| 366 | unregister_mods(MOD_BIT(KC_LGUI)); | ||
| 367 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 368 | add_oneshot_mods(MOD_BIT(KC_LGUI)); | ||
| 369 | } else { | ||
| 370 | del_oneshot_mods(MOD_BIT(KC_LGUI)); | ||
| 371 | } | ||
| 372 | } | ||
| 373 | return true; | ||
| 374 | // Why do I have to roll my own? It seems the original ones work on | ||
| 375 | // keyrelease, at which time I might have let go of the layer tap | ||
| 376 | // already, so I cannot roll them fast... | ||
| 377 | case OSM_SFT: | ||
| 378 | if (record->event.pressed) { | ||
| 379 | key_timer = timer_read(); | ||
| 380 | register_mods(MOD_BIT(KC_LSFT)); | ||
| 381 | } else { | ||
| 382 | unregister_mods(MOD_BIT(KC_LSFT)); | ||
| 383 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 384 | add_oneshot_mods(MOD_BIT(KC_LSFT)); | ||
| 385 | } /*else { | ||
| 386 | del_oneshot_mods(MOD_BIT(KC_LSFT)); | ||
| 387 | }*/ | ||
| 388 | } | ||
| 389 | return true; | ||
| 390 | case OSM_CTL: | ||
| 391 | if (record->event.pressed) { | ||
| 392 | key_timer = timer_read(); | ||
| 393 | register_mods(MOD_BIT(KC_LCTL)); | ||
| 394 | } else { | ||
| 395 | unregister_mods(MOD_BIT(KC_LCTL)); | ||
| 396 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 397 | add_oneshot_mods(MOD_BIT(KC_LCTL)); | ||
| 398 | } /*else { | ||
| 399 | del_oneshot_mods(MOD_BIT(KC_LCTL)); | ||
| 400 | }*/ | ||
| 401 | } | ||
| 402 | return true; | ||
| 403 | case OSM_ALT: | ||
| 404 | if (record->event.pressed) { | ||
| 405 | key_timer = timer_read(); | ||
| 406 | register_mods(MOD_BIT(KC_LALT)); | ||
| 407 | } else { | ||
| 408 | unregister_mods(MOD_BIT(KC_LALT)); | ||
| 409 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 410 | add_oneshot_mods(MOD_BIT(KC_LALT)); | ||
| 411 | } /*else { | ||
| 412 | del_oneshot_mods(MOD_BIT(KC_LALT)); | ||
| 413 | }*/ | ||
| 414 | } | ||
| 415 | return true; | ||
| 416 | #else | ||
| 417 | #define OSM_ALT OSM(MOD_LALT) | ||
| 418 | #define OSM_CTL OSM(MOD_LCTL) | ||
| 419 | #define OSM_GUI OSM(MOD_LGUI) | ||
| 420 | #define OSM_SFT OSM(MOD_LSFT) | ||
| 421 | #endif | ||
| 422 | // Obsoleted by using combos for umlauts now. | ||
| 423 | case KC_A_AE: | ||
| 424 | if (record->event.pressed) { | ||
| 425 | key_timer = timer_read(); | ||
| 426 | auml_pressed = true; | ||
| 427 | } else { | ||
| 428 | maybe_send_umlaut(KC_A, ä_pressed); | ||
| 429 | } | ||
| 430 | break; | ||
| 431 | case KC_O_OE: | ||
| 432 | if (record->event.pressed) { | ||
| 433 | key_timer = timer_read(); | ||
| 434 | ouml_pressed = true; | ||
| 435 | } else { | ||
| 436 | maybe_send_umlaut(KC_O, ö_pressed); | ||
| 437 | } | ||
| 438 | break; | ||
| 439 | case KC_U_UE: | ||
| 440 | if (record->event.pressed) { | ||
| 441 | key_timer = timer_read(); | ||
| 442 | uuml_pressed = true; | ||
| 443 | } else { | ||
| 444 | maybe_send_umlaut(KC_U, ü_pressed); | ||
| 445 | } | ||
| 446 | break; | ||
| 447 | case MINS_UNDSCR: | ||
| 448 | if (record->event.pressed) { | ||
| 449 | key_timer = timer_read(); | ||
| 450 | } else { | ||
| 451 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 452 | // Can't send KC_KP_MINUS, it doesn't compose to, say → | ||
| 453 | tap_code16(KC_MINUS); | ||
| 454 | } else { | ||
| 455 | tap_code16(KC_UNDERSCORE); | ||
| 456 | } | ||
| 457 | } | ||
| 458 | break; | ||
| 459 | case ALT_TAB: | ||
| 460 | if (record->event.pressed) { | ||
| 461 | register_mods(MOD_BIT(KC_LALT)); | ||
| 462 | tap_code16(KC_TAB); | ||
| 463 | } | ||
| 464 | break; | ||
| 465 | case INS_HARD: | ||
| 466 | // Do Alt-Shift-Ins first to have xdotool copy from SELECTION to CLIPBOARD, then Shift-Ins to paste. | ||
| 467 | if (record->event.pressed) { | ||
| 468 | tap_code16(LSFT(LALT(KC_INS))); | ||
| 469 | } else { | ||
| 470 | tap_code16(LSFT(KC_INS)); | ||
| 471 | } | ||
| 472 | break; | ||
| 473 | case SHIFT_INS: | ||
| 474 | if (record->event.pressed) { | ||
| 475 | // when keycode is pressed | ||
| 476 | key_timer = timer_read(); | ||
| 477 | // Shift when held ... | ||
| 478 | register_mods(MOD_BIT(KC_RSFT)); | ||
| 479 | } else { | ||
| 480 | // If released within the timer, then Shift+Ins | ||
| 481 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 482 | tap_code16(KC_INS); | ||
| 483 | } | ||
| 484 | unregister_mods(MOD_BIT(KC_RSFT)); | ||
| 485 | } | ||
| 486 | break; | ||
| 487 | case ALT_SHIFT_INS: | ||
| 488 | if (record->event.pressed) { | ||
| 489 | key_timer = timer_read(); | ||
| 490 | // Shift when held ... | ||
| 491 | register_mods(MOD_BIT(KC_LSFT)); | ||
| 492 | } else { | ||
| 493 | // If released within the timer, then Shift+Alt+Ins | ||
| 494 | if (timer_elapsed(key_timer) < TAPPING_TERM) { | ||
| 495 | register_mods(MOD_BIT(KC_LALT)); | ||
| 496 | tap_code16(KC_INS); | ||
| 497 | } | ||
| 498 | // Note: this makes xev(1) see KeyPress for Meta_L but KeyRelease for Alt_L | ||
| 499 | unregister_mods(MOD_BIT(KC_LSFT) | MOD_BIT(KC_LALT)); | ||
| 500 | } | ||
| 501 | break; | ||
| 502 | /* | ||
| 503 | * Obsoleted by making tmux understand Ctrl-(Shift)-Tab natively. | ||
| 504 | case TM_NEXT: | ||
| 505 | if (record->event.pressed) SEND_STRING(SS_LCTRL("a") "n"); | ||
| 506 | break; | ||
| 507 | case TM_PREV: | ||
| 508 | if (record->event.pressed) SEND_STRING(SS_LCTRL("a") "p"); | ||
| 509 | break; | ||
| 510 | */ | ||
| 511 | // TODO: use key overrides to turn, e.g. Win+Ctrl-Tab into VIM_NEXT. | ||
| 512 | // Not sure why Ctrl-Pgup works in vim, but not in vim-inside-tmux. | ||
| 513 | case VIM_NEXT: | ||
| 514 | if (record->event.pressed) SEND_STRING(SS_TAP(X_ESC) SS_TAP(X_G) SS_TAP(X_T)); | ||
| 515 | break; | ||
| 516 | case VIM_PREV: | ||
| 517 | if (record->event.pressed) SEND_STRING(SS_TAP(X_ESC) SS_TAP(X_G) SS_LSFT("t")); | ||
| 518 | break; | ||
| 519 | case WIN_LEFT: | ||
| 520 | if (record->event.pressed) SEND_STRING(SS_LCTRL("w") SS_TAP(X_H)); | ||
| 521 | break; | ||
| 522 | case WIN_DN: | ||
| 523 | if (record->event.pressed) SEND_STRING(SS_LCTRL("w") SS_TAP(X_J)); | ||
| 524 | break; | ||
| 525 | case WIN_UP: | ||
| 526 | if (record->event.pressed) SEND_STRING(SS_LCTRL("w") SS_TAP(X_K)); | ||
| 527 | break; | ||
| 528 | case WIN_RGHT: | ||
| 529 | if (record->event.pressed) SEND_STRING(SS_LCTRL("w") SS_TAP(X_L)); | ||
| 530 | break; | ||
| 531 | } | ||
| 532 | |||
| 533 | return true; | ||
| 534 | } | ||
| 535 | |||
| 536 | #ifdef LEADER_ENABLE | ||
| 537 | LEADER_EXTERNS(); | ||
| 538 | |||
| 539 | void matrix_scan_user(void) { | ||
| 540 | LEADER_DICTIONARY() { | ||
| 541 | leading = false; | ||
| 542 | leader_end(); | ||
| 543 | |||
| 544 | #ifdef UCIS_ENABLE | ||
| 545 | SEQ_ONE_KEY(KC_U) { | ||
| 546 | qk_ucis_start(); | ||
| 547 | } | ||
| 548 | #endif | ||
| 549 | SEQ_ONE_KEY(KC_H) { | ||
| 550 | send_unicode_string("ᕕ( ᐛ )ᕗ"); // happy | ||
| 551 | } | ||
| 552 | SEQ_ONE_KEY(KC_D) { | ||
| 553 | send_unicode_string("ಠ_ಠ"); // disapproval | ||
| 554 | } | ||
| 555 | SEQ_ONE_KEY(KC_L) { | ||
| 556 | send_unicode_string("( ͡° ͜ʖ ͡°)"); // lenny | ||
| 557 | } | ||
| 558 | SEQ_ONE_KEY(KC_S) { | ||
| 559 | send_unicode_string("¯\\_(ツ)_/¯"); // shrug | ||
| 560 | } | ||
| 561 | // tableflip (LEADER - TF) | ||
| 562 | SEQ_TWO_KEYS(KC_T, KC_F) { | ||
| 563 | //set_unicode_input_mode(UC_LNX); | ||
| 564 | //send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); | ||
| 565 | send_unicode_string("(╯°□°)╯︵ ┻━┻"); | ||
| 566 | } | ||
| 567 | // untableflip | ||
| 568 | SEQ_THREE_KEYS(KC_U, KC_T, KC_F) { | ||
| 569 | //set_unicode_input_mode(UC_LNX); | ||
| 570 | //send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); | ||
| 571 | send_unicode_string("┬─┬ノ( º _ ºノ)"); | ||
| 572 | } | ||
| 573 | } | ||
| 574 | } | ||
| 575 | #endif | ||
| 576 | |||
| 577 | #ifdef UCIS_ENABLE | ||
| 578 | // 3 codepoints at most, otherwise increase UCIS_MAX_CODE_POINTS | ||
| 579 | const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE( | ||
| 580 | UCIS_SYM("poop", 0x1F4A9), // 💩 | ||
| 581 | UCIS_SYM("rofl", 0x1F923), // 🤣 | ||
| 582 | UCIS_SYM("look", 0x0CA0, 0x005F, 0x0CA0) // ಠ_ಠ | ||
| 583 | ); | ||
| 584 | #endif | ||
diff --git a/users/uqs/uqs.h b/users/uqs/uqs.h new file mode 100644 index 000000000..f8b30caf7 --- /dev/null +++ b/users/uqs/uqs.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | // Copyright 2022 Ulrich Spörlein (@uqs) | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | // vi:et sw=4: | ||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include QMK_KEYBOARD_H | ||
| 7 | |||
| 8 | enum layers { | ||
| 9 | L_QWER = 0, | ||
| 10 | L_WASD, // wasd gaming | ||
| 11 | L_COLM, // Colemak DHm | ||
| 12 | L_EXTD, | ||
| 13 | L_NUM, | ||
| 14 | L_FUNC, | ||
| 15 | L_MOUSE, | ||
| 16 | L_LAST, // unused | ||
| 17 | }; | ||
| 18 | |||
| 19 | #ifdef VIA_ENABLE | ||
| 20 | _Static_assert(DYNAMIC_KEYMAP_LAYER_COUNT >= L_LAST, "VIA enabled, but not enough DYNAMIC_KEYMAP_LAYER_COUNT for all layers"); | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #define KC_CTAB LCTL(KC_TAB) | ||
| 24 | #define KC_SCTAB LCTL(LSFT(KC_TAB)) | ||
| 25 | |||
| 26 | // Custom single-key codes, see uqs.c for the combos. | ||
| 27 | enum custom_keycodes { | ||
| 28 | SHIFT_INS = SAFE_RANGE, | ||
| 29 | ALT_SHIFT_INS, | ||
| 30 | INS_HARD, | ||
| 31 | KC_A_AE, | ||
| 32 | KC_O_OE, | ||
| 33 | KC_U_UE, | ||
| 34 | MINS_UNDSCR, // obsoleted by combos, remove this! | ||
| 35 | TM_NEXT, | ||
| 36 | TM_PREV, | ||
| 37 | VIM_NEXT, | ||
| 38 | VIM_PREV, | ||
| 39 | WIN_LEFT, | ||
| 40 | WIN_RGHT, | ||
| 41 | WIN_UP, | ||
| 42 | WIN_DN, | ||
| 43 | LT_EXTD_ESC, | ||
| 44 | LT_NUM_BSPC, | ||
| 45 | LT_MOUSE_ALT_SHIFT_INS, | ||
| 46 | LT_FUNC_SHIFT_INS, | ||
| 47 | OSM_GUI, | ||
| 48 | OSM_SFT, | ||
| 49 | OSM_CTL, | ||
| 50 | OSM_ALT, | ||
| 51 | ALT_TAB, | ||
| 52 | }; | ||
| 53 | |||
| 54 | #ifndef LEADER_ENABLE | ||
| 55 | #define KC_LEAD KC_NO | ||
| 56 | #endif | ||
| 57 | |||
| 58 | // Shorter names | ||
| 59 | #define MS_WHDN KC_MS_WH_DOWN | ||
| 60 | #define MS_WHUP KC_MS_WH_UP | ||
| 61 | #define MS_WHLEFT KC_MS_WH_LEFT | ||
| 62 | #define MS_WHRGHT KC_MS_WH_RIGHT | ||
| 63 | |||
| 64 | // GASC/◆⎇⇧⎈ home row mod, read all about it here: | ||
| 65 | // https://precondition.github.io/home-row-mods | ||
| 66 | // Left-hand home row mods | ||
| 67 | #define KC_G_A LGUI_T(KC_A) | ||
| 68 | #define KC_A_R LALT_T(KC_R) | ||
| 69 | #define KC_S_S LSFT_T(KC_S) | ||
| 70 | #define KC_C_T LCTL_T(KC_T) | ||
| 71 | |||
| 72 | // Right-hand home row mods | ||
| 73 | #define KC_C_N RCTL_T(KC_N) | ||
| 74 | #define KC_S_E RSFT_T(KC_E) | ||
| 75 | #define KC_A_I LALT_T(KC_I) // RALT is special, it's AltGr and my compose key under Win (layout UScmpse) and *nix (setxkbmap -option compose:ralt) | ||
| 76 | #define KC_G_O RGUI_T(KC_O) | ||
| 77 | |||
