diff options
| author | Joel Elkins <joel@elkins.co> | 2021-06-02 15:59:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-03 06:59:52 +1000 |
| commit | 35dbe8ba035c8eefc1051226aa8e3dd7cd63a912 (patch) | |
| tree | f152e98a0953238771853d1462a26e10d3540633 /users/jdelkins | |
| parent | 93496c8364369f72e2db90c3c59dfa3ecc8657b4 (diff) | |
| download | qmk_firmware-35dbe8ba035c8eefc1051226aa8e3dd7cd63a912.tar.gz qmk_firmware-35dbe8ba035c8eefc1051226aa8e3dd7cd63a912.zip | |
[Keymap] merge jdelkins userspace and associated keymaps (#11276)
* [Keymap] merge jdelkins userspace and associated keymaps
* Add copyright & license info
* Change rgblight_config.enable to rgblight_is_enabled()
* Update keyboards/dz60/keymaps/jdelkins/keymap.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
* Update keyboards/dz60/keymaps/jdelkins/keymap.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
* Update keyboards/dz60/keymaps/jdelkins/keymap.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
* Remove superfluous includes
* Change EXTRAFLAGS+=-flto to LTO_ENABLE=yes
* Remove unnecessary jdelkins_ss symlink in users
* Add copyright and license notices
* Use preferred way to determine capslock / numlock state
Co-authored-by: Drashna Jaelre <drashna@live.com>
* Add #pragma once to a header
Co-authored-by: Drashna Jaelre <drashna@live.com>
* Include QMK_KEYBOARD_H only once, in userspace header
* Remove unnecessary initialization in matrix_init_keymap
* Do process_record_keymap before cases handled in process_record_user
* Reorganize & simplify secrets feature enablement
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove superfluous break
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove copyright from rules.mk
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove copyright from rules.mk
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* include "print.h" instead of <print.h>
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_cod16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove copyright from rules.mk
Co-authored-by: Ryan <fauxpark@gmail.com>
* add #pragma once to a header
Co-authored-by: Ryan <fauxpark@gmail.com>
* include "print.h" instead of <print.h>
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove copyright from rules.mk
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove copyright from rules.mk
Co-authored-by: Ryan <fauxpark@gmail.com>
* Remove copyright from rules.mk
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use tap_code16
Co-authored-by: Ryan <fauxpark@gmail.com>
* Use :flash target where possible
* Remove special case flash target and use PROGRAM_CMD
* dz60/jdelkins_ss: use tap_code16
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'users/jdelkins')
| -rw-r--r-- | users/jdelkins/.gitignore | 1 | ||||
| -rw-r--r-- | users/jdelkins/jdelkins.c | 274 | ||||
| -rw-r--r-- | users/jdelkins/jdelkins.h | 134 | ||||
| -rw-r--r-- | users/jdelkins/rules.mk | 10 |
4 files changed, 419 insertions, 0 deletions
diff --git a/users/jdelkins/.gitignore b/users/jdelkins/.gitignore new file mode 100644 index 000000000..03b2b4666 --- /dev/null +++ b/users/jdelkins/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| secrets.h | |||
diff --git a/users/jdelkins/jdelkins.c b/users/jdelkins/jdelkins.c new file mode 100644 index 000000000..7577512ec --- /dev/null +++ b/users/jdelkins/jdelkins.c | |||
| @@ -0,0 +1,274 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2020 Joel Elkins <joel@elkins.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 "jdelkins.h" | ||
| 19 | #include "version.h" | ||
| 20 | |||
| 21 | #ifdef DO_SECRETS | ||
| 22 | # include "secrets.h" | ||
| 23 | #else | ||
| 24 | # ifndef NO_SECRETS | ||
| 25 | # pragma message("Warning: secrets.h not found") | ||
| 26 | # endif | ||
| 27 | #endif | ||
| 28 | |||
| 29 | user_config_t user_config; | ||
| 30 | |||
| 31 | __attribute__ ((weak)) | ||
| 32 | bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { | ||
| 33 | return true; | ||
| 34 | } | ||
| 35 | |||
| 36 | void send_secret_string(uint8_t n) { | ||
| 37 | #ifdef DO_SECRETS | ||
| 38 | send_string(secret[n]); | ||
| 39 | #else | ||
| 40 | SEND_STRING(""); | ||
| 41 | #endif | ||
| 42 | } | ||
| 43 | |||
| 44 | #ifdef TAP_DANCE_ENABLE | ||
| 45 | |||
| 46 | // To activate SINGLE_HOLD, you will need to hold for 200ms first. | ||
| 47 | // This tap dance favors keys that are used frequently in typing like 'f' | ||
| 48 | int cur_dance(qk_tap_dance_state_t *state) { | ||
| 49 | if (state->count == 1) { | ||
| 50 | // If count = 1, and it has been interrupted - it doesn't matter if it | ||
| 51 | // is pressed or not: Send SINGLE_TAP | ||
| 52 | if (state->interrupted) { | ||
| 53 | // if (!state->pressed) return SINGLE_TAP; | ||
| 54 | // need "permissive hold" here. | ||
| 55 | // else return SINsGLE_HOLD; | ||
| 56 | // If the interrupting key is released before the tap-dance key, | ||
| 57 | // then it is a single HOLD However, if the tap-dance key is | ||
| 58 | // released first, then it is a single TAP But how to get access to | ||
| 59 | // the state of the interrupting key???? | ||
| 60 | return SINGLE_TAP; | ||
| 61 | } else { | ||
| 62 | if (!state->pressed) | ||
| 63 | return SINGLE_TAP; | ||
| 64 | else | ||
| 65 | return SINGLE_HOLD; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | // If count = 2, and it has been interrupted - assume that user is trying to | ||
| 69 | // type the letter associated with single tap. | ||
| 70 | else if (state->count == 2) { | ||
| 71 | if (state->interrupted) | ||
| 72 | return DOUBLE_SINGLE_TAP; | ||
| 73 | else if (state->pressed) | ||
| 74 | return DOUBLE_HOLD; | ||
| 75 | else | ||
| 76 | return DOUBLE_TAP; | ||
| 77 | } else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) | ||
| 78 | return TRIPLE_TAP; | ||
| 79 | else if (state->count == 3) | ||
| 80 | return TRIPLE_HOLD; | ||
| 81 | else | ||
| 82 | return 8; // magic number. At some point this method will expand to work for more presses | ||
| 83 | } | ||
| 84 | |||
| 85 | // This works well if you want this key to work as a "fast modifier". It favors | ||
| 86 | // being held over being tapped. | ||
| 87 | int hold_cur_dance(qk_tap_dance_state_t *state) { | ||
| 88 | if (state->count == 1) { | ||
| 89 | if (state->interrupted) { | ||
| 90 | if (!state->pressed) | ||
| 91 | return SINGLE_TAP; | ||
| 92 | else | ||
| 93 | return SINGLE_HOLD; | ||
| 94 | } else { | ||
| 95 | if (!state->pressed) | ||
| 96 | return SINGLE_TAP; | ||
| 97 | else | ||
| 98 | return SINGLE_HOLD; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | // If count = 2, and it has been interrupted - assume that user is trying to | ||
| 102 | // type the letter associated with single tap. | ||
| 103 | else if (state->count == 2) { | ||
| 104 | if (state->pressed) | ||
| 105 | return DOUBLE_HOLD; | ||
| 106 | else | ||
| 107 | return DOUBLE_TAP; | ||
| 108 | } else if (state->count == 3) { | ||
| 109 | if (!state->pressed) | ||
| 110 | return TRIPLE_TAP; | ||
| 111 | else | ||
| 112 | return TRIPLE_HOLD; | ||
| 113 | } else | ||
| 114 | return 8; // magic number. At some point this method will expand to work for more presses | ||
| 115 | } | ||
| 116 | |||
| 117 | #endif // TAP_DANCE_ENABLE | ||
| 118 | |||
| 119 | __attribute__ ((weak)) | ||
| 120 | void keyboard_post_init_keymap(void) { | ||
| 121 | } | ||
| 122 | |||
| 123 | void keyboard_post_init_user(void) { | ||
| 124 | user_config.raw = eeconfig_read_user(); | ||
| 125 | keyboard_post_init_keymap(); | ||
| 126 | } | ||
| 127 | |||
| 128 | void eeconfig_init_user(void) { | ||
| 129 | user_config.raw = 0; | ||
| 130 | user_config.system_mac = false; | ||
| 131 | eeconfig_update_user(user_config.raw); | ||
| 132 | } | ||
| 133 | |||
| 134 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 135 | static uint32_t boot_timer; | ||
| 136 | |||
| 137 | if (!process_record_keymap(keycode, record)) { | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | |||
| 141 | switch (keycode) { | ||
| 142 | case FW_WRD: | ||
| 143 | do_mac_key(LCTL(KC_RIGHT), ROPT(KC_RIGHT), record); | ||
| 144 | break; | ||
| 145 | |||
| 146 | case BK_WRD: | ||
| 147 | do_mac_key(LCTL(KC_LEFT), ROPT(KC_LEFT), record); | ||
| 148 | break; | ||
| 149 | |||
| 150 | case KB_BOL: | ||
| 151 | do_mac_key(KC_HOME, RCMD(KC_LEFT), record); | ||
| 152 | break; | ||
| 153 | |||
| 154 | case KB_EOL: | ||
| 155 | do_mac_key(KC_END, RCMD(KC_RIGHT), record); | ||
| 156 | break; | ||
| 157 | |||
| 158 | case TG_SYS: | ||
| 159 | if (record->event.pressed) { | ||
| 160 | user_config.system_mac ^= 1; | ||
| 161 | eeconfig_update_user(user_config.raw); | ||
| 162 | } | ||
| 163 | break; | ||
| 164 | |||
| 165 | case KB_COPY: | ||
| 166 | do_mac_key(LCTL(KC_INS), RCMD(KC_C), record); | ||
| 167 | break; | ||
| 168 | |||
| 169 | case KB_PASTE: | ||
| 170 | do_mac_key(LSFT(KC_INS), RCMD(KC_V), record); | ||
| 171 | break; | ||
| 172 | |||
| 173 | case MY_GUI: | ||
| 174 | do_mac_key(KC_LGUI, KC_LOPT, record); | ||
| 175 | break; | ||
| 176 | |||
| 177 | case MY_ALT: | ||
| 178 | do_mac_key(KC_LALT, KC_LCMD, record); | ||
| 179 | break; | ||
| 180 | |||
| 181 | case MY_RGUI: | ||
| 182 | do_mac_key(KC_RGUI, KC_ROPT, record); | ||
| 183 | break; | ||
| 184 | |||
| 185 | case MY_RALT: | ||
| 186 | do_mac_key(KC_RALT, KC_RCMD, record); | ||
| 187 | break; | ||
| 188 | |||
| 189 | case MY_CALC: | ||
| 190 | do_mac_key(KC_CALC, KC_F14, record); | ||
| 191 | break; | ||
| 192 | |||
| 193 | case KB_MAKE: | ||
| 194 | if (!get_mods()) { | ||
| 195 | if (!record->event.pressed) | ||
| 196 | SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP SS_TAP(X_ENTER)); | ||
| 197 | return false; | ||
| 198 | } | ||
| 199 | break; | ||
| 200 | |||
| 201 | case KB_VRSN: | ||
| 202 | if (!get_mods()) { | ||
| 203 | if (!record->event.pressed) { | ||
| 204 | if (user_config.system_mac) { | ||
| 205 | SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " (mac mode)"); | ||
| 206 | } else { | ||
| 207 | SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " (non-mac mode)"); | ||
| 208 | } | ||
| 209 | } | ||
| 210 | return false; | ||
| 211 | } | ||
| 212 | break; | ||
| 213 | |||
| 214 | case KB_BOOT: | ||
| 215 | if (!get_mods()) { | ||
| 216 | if (record->event.pressed) { | ||
| 217 | boot_timer = timer_read32(); | ||
| 218 | } else { | ||
| 219 | if (timer_elapsed32(boot_timer) >= 500) { | ||
| 220 | reset_keyboard(); | ||
| 221 | } | ||
| 222 | } | ||
| 223 | return false; | ||
| 224 | } | ||
| 225 | break; | ||
| 226 | |||
| 227 | case KB_FLSH: | ||
| 228 | if (!get_mods()) { | ||
| 229 | if (!record->event.pressed) { | ||
| 230 | SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP ":flash\n"); | ||
| 231 | reset_keyboard(); | ||
| 232 | } | ||
| 233 | return false; | ||
| 234 | } | ||
| 235 | break; | ||
| 236 | |||
| 237 | #ifdef DO_SECRETS | ||
| 238 | case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo | ||
| 239 | if (!record->event.pressed) { | ||
| 240 | clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); | ||
| 241 | send_secret_string(keycode - KC_SECRET_1); | ||
| 242 | } | ||
| 243 | return false; | ||
| 244 | break; | ||
| 245 | #endif | ||
| 246 | } | ||
| 247 | |||
| 248 | return true; | ||
| 249 | } | ||
| 250 | |||
| 251 | __attribute__ ((weak)) | ||
| 252 | void matrix_init_keymap(void) { | ||
| 253 | } | ||
| 254 | |||
| 255 | void matrix_init_user(void) { | ||
| 256 | matrix_init_keymap(); | ||
| 257 | } | ||
| 258 | |||
| 259 | __attribute__ ((weak)) | ||
| 260 | void matrix_scan_keymap(void) { | ||
| 261 | } | ||
| 262 | |||
| 263 | void matrix_scan_user(void) { | ||
| 264 | matrix_scan_keymap(); | ||
| 265 | } | ||
| 266 | |||
| 267 | __attribute__ ((weak)) | ||
| 268 | layer_state_t layer_state_set_keymap(layer_state_t state) { | ||
| 269 | return state; | ||
| 270 | } | ||
| 271 | |||
| 272 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 273 | return layer_state_set_keymap(state); | ||
| 274 | } | ||
diff --git a/users/jdelkins/jdelkins.h b/users/jdelkins/jdelkins.h new file mode 100644 index 000000000..ddec8dc4a --- /dev/null +++ b/users/jdelkins/jdelkins.h | |||
| @@ -0,0 +1,134 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2020 Joel Elkins <joel@elkins.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 | |||
| 20 | #include QMK_KEYBOARD_H | ||
| 21 | |||
| 22 | // Secrets | ||
| 23 | |||
| 24 | #if !defined(NO_SECRETS) && __has_include("secrets.h") | ||
| 25 | # define DO_SECRETS | ||
| 26 | #endif | ||
| 27 | |||
| 28 | void send_secret_string(uint8_t n); | ||
| 29 | |||
| 30 | // standard layers | ||
| 31 | |||
| 32 | enum jdelkins_layers { | ||
| 33 | _QWERTY = 0, | ||
| 34 | _RPT, | ||
| 35 | _GAME, | ||
| 36 | _FUNC, | ||
| 37 | _KP, | ||
| 38 | _SECRETS, | ||
| 39 | _ADJUST, | ||
| 40 | _LAYER_MAX | ||
| 41 | }; | ||
| 42 | |||
| 43 | // key definitions | ||
| 44 | |||
| 45 | typedef union { | ||
| 46 | uint32_t raw; | ||
| 47 | struct { | ||
| 48 | bool system_mac :1; | ||
| 49 | }; | ||
| 50 | } user_config_t; | ||
| 51 | |||
| 52 | extern user_config_t user_config; | ||
| 53 | |||
| 54 | static inline void do_mac_key(uint16_t norm_key, uint16_t mac_key, keyrecord_t *record) { | ||
| 55 | uint16_t key = user_config.system_mac ? mac_key : norm_key; | ||
| 56 | if (record->event.pressed) | ||
| 57 | register_code16(key); | ||
| 58 | else | ||
| 59 | unregister_code16(key); | ||
| 60 | } | ||
| 61 | |||
| 62 | enum jdelkins_keycodes { | ||
| 63 | KB_MAKE = SAFE_RANGE, | ||
| 64 | KB_FLSH, | ||
| 65 | KB_VRSN, | ||
| 66 | KB_BOOT, | ||
| 67 | FW_WRD, | ||
| 68 | BK_WRD, | ||
| 69 | KB_BOL, | ||
| 70 | KB_EOL, | ||
| 71 | TG_SYS, | ||
| 72 | KB_COPY, | ||
| 73 | KB_PASTE, | ||
| 74 | MY_GUI, | ||
| 75 | MY_ALT, | ||
| 76 | MY_RGUI, | ||
| 77 | MY_RALT, | ||
| 78 | MY_CALC, | ||
| 79 | |||
| 80 | #ifdef DO_SECRETS | ||
| 81 | KC_SECRET_1, | ||
| 82 | KC_SECRET_2, | ||
| 83 | KC_SECRET_3, | ||
| 84 | KC_SECRET_4, | ||
| 85 | KC_SECRET_5, | ||
| 86 | KC_SECRET_6, | ||
| 87 | #endif | ||
| 88 | |||
| 89 | USER_SAFE_RANGE, | ||
| 90 | }; | ||
| 91 | |||
| 92 | #ifdef DO_SECRETS | ||
| 93 | # define KC_SEC1 KC_SECRET_1 | ||
| 94 | # define KC_SEC2 KC_SECRET_2 | ||
| 95 | # define KC_SEC3 KC_SECRET_3 | ||
| 96 | # define KC_SEC4 KC_SECRET_4 | ||
| 97 | # define KC_SEC5 KC_SECRET_5 | ||
| 98 | # define KC_SEC6 KC_SECRET_6 | ||
| 99 | #else | ||
| 100 | # define KC_SEC1 KC_NO | ||
| 101 | # define KC_SEC2 KC_NO | ||
| 102 | # define KC_SEC3 KC_NO | ||
| 103 | # define KC_SEC4 KC_NO | ||
| 104 | # define KC_SEC5 KC_NO | ||
| 105 | # define KC_SEC6 KC_NO | ||
| 106 | #endif | ||
| 107 | |||
| 108 | #define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT) | ||
| 109 | #define MODS_CTRL (get_mods() & MOD_MASK_CTRL) | ||
| 110 | #define MODS_ALT (get_mods() & MOD_MASK_ALT) | ||
| 111 | #define MODS_GUI (get_mods() & MOD_MASK_GUI) | ||
| 112 | |||
| 113 | #define MY_CAPS LCTL_T(KC_CAPS) | ||
| 114 | #define MY_SPC LT(_FUNC, KC_SPC) | ||
| 115 | |||
| 116 | #define NUMLOCK_ON host_keyboard_led_state().num_lock | ||
| 117 | #define CAPSLOCK_ON host_keyboard_led_state().caps_lock | ||
| 118 | |||
| 119 | #ifdef TAP_DANCE_ENABLE | ||
| 120 | |||
| 121 | enum { | ||
| 122 | SINGLE_TAP = 1, | ||
| 123 | SINGLE_HOLD = 2, | ||
| 124 | DOUBLE_TAP = 3, | ||
| 125 | DOUBLE_HOLD = 4, | ||
| 126 | DOUBLE_SINGLE_TAP = 5, //send two single taps | ||
| 127 | TRIPLE_TAP = 6, | ||
| 128 | TRIPLE_HOLD = 7 | ||
| 129 | }; | ||
| 130 | |||
| 131 | int cur_dance(qk_tap_dance_state_t *state); // prefer tap | ||
| 132 | int hold_cur_dance(qk_tap_dance_state_t *state); // prefer hold | ||
| 133 | |||
| 134 | #endif // TAP_DANCE_ENABLE | ||
diff --git a/users/jdelkins/rules.mk b/users/jdelkins/rules.mk new file mode 100644 index 000000000..b9d377b28 --- /dev/null +++ b/users/jdelkins/rules.mk | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | SRC += jdelkins.c | ||
| 2 | |||
| 3 | ifeq ($(strip $(NO_SECRETS)), yes) | ||
| 4 | OPT_DEFS += -DNO_SECRETS | ||
| 5 | endif | ||
| 6 | |||
| 7 | users/jdelkins/secrets.h: users/jdelkins/secrets.h.gpg | ||
| 8 | gpg -d $< >$@ | ||
| 9 | |||
| 10 | BOOTMAGIC_ENABLE = no | ||
