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 | |
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')
-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 0000000000..03b2b46668 --- /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 0000000000..7577512ec5 --- /dev/null +++ b/users/jdelkins/jdelkins.c @@ -0,0 +1,274 @@ +/* + Copyright 2020 Joel Elkins <joel@elkins.com> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "jdelkins.h" +#include "version.h" + +#ifdef DO_SECRETS +# include "secrets.h" +#else +# ifndef NO_SECRETS +# pragma message("Warning: secrets.h not found") +# endif +#endif + +user_config_t user_config; + +__attribute__ ((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +void send_secret_string(uint8_t n) { +#ifdef DO_SECRETS + send_string(secret[n]); +#else + SEND_STRING(""); +#endif +} + +#ifdef TAP_DANCE_ENABLE + +// To activate SINGLE_HOLD, you will need to hold for 200ms first. +// This tap dance favors keys that are used frequently in typing like 'f' +int cur_dance(qk_tap_dance_state_t *state) { + if (state->count == 1) { + // If count = 1, and it has been interrupted - it doesn't matter if it + // is pressed or not: Send SINGLE_TAP + if (state->interrupted) { + // if (!state->pressed) return SINGLE_TAP; + // need "permissive hold" here. + // else return SINsGLE_HOLD; + // If the interrupting key is released before the tap-dance key, + // then it is a single HOLD However, if the tap-dance key is + // released first, then it is a single TAP But how to get access to + // the state of the interrupting key???? + return SINGLE_TAP; + } else { + if (!state->pressed) + return SINGLE_TAP; + else + return SINGLE_HOLD; + } + } + // If count = 2, and it has been interrupted - assume that user is trying to + // type the letter associated with single tap. + else if (state->count == 2) { + if (state->interrupted) + return DOUBLE_SINGLE_TAP; + else if (state->pressed) + return DOUBLE_HOLD; + else + return DOUBLE_TAP; + } else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) + return TRIPLE_TAP; + else if (state->count == 3) + return TRIPLE_HOLD; + else + return 8; // magic number. At some point this method will expand to work for more presses +} + +// This works well if you want this key to work as a "fast modifier". It favors +// being held over being tapped. +int hold_cur_dance(qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted) { + if (!state->pressed) + return SINGLE_TAP; + else + return SINGLE_HOLD; + } else { + if (!state->pressed) + return SINGLE_TAP; + else + return SINGLE_HOLD; + } + } + // If count = 2, and it has been interrupted - assume that user is trying to + // type the letter associated with single tap. + else if (state->count == 2) { + if (state->pressed) + return DOUBLE_HOLD; + else + return DOUBLE_TAP; + } else if (state->count == 3) { + if (!state->pressed) + return TRIPLE_TAP; + else + return TRIPLE_HOLD; + } else + return 8; // magic number. At some point this method will expand to work for more presses +} + +#endif // TAP_DANCE_ENABLE + +__attribute__ ((weak)) +void keyboard_post_init_keymap(void) { +} + +void keyboard_post_init_user(void) { + user_config.raw = eeconfig_read_user(); + keyboard_post_init_keymap(); +} + +void eeconfig_init_user(void) { + user_config.raw = 0; + user_config.system_mac = false; + eeconfig_update_user(user_config.raw); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + static uint32_t boot_timer; + + if (!process_record_keymap(keycode, record)) { + return false; + } + + switch (keycode) { + case FW_WRD: + do_mac_key(LCTL(KC_RIGHT), ROPT(KC_RIGHT), record); + break; + + case BK_WRD: + do_mac_key(LCTL(KC_LEFT), ROPT(KC_LEFT), record); + break; + + case KB_BOL: + do_mac_key(KC_HOME, RCMD(KC_LEFT), record); + break; + + case KB_EOL: + do_mac_key(KC_END, RCMD(KC_RIGHT), record); + break; + + case TG_SYS: + if (record->event.pressed) { + user_config.system_mac ^= 1; + eeconfig_update_user(user_config.raw); + } + break; + + case KB_COPY: + do_mac_key(LCTL(KC_INS), RCMD(KC_C), record); + break; + + case KB_PASTE: + do_mac_key(LSFT(KC_INS), RCMD(KC_V), record); + break; + + case MY_GUI: + do_mac_key(KC_LGUI, KC_LOPT, record); + break; + + case MY_ALT: + do_mac_key(KC_LALT, KC_LCMD, record); + break; + + case MY_RGUI: + do_mac_key(KC_RGUI, KC_ROPT, record); + break; + + case MY_RALT: + do_mac_key(KC_RALT, KC_RCMD, record); + break; + + case MY_CALC: + do_mac_key(KC_CALC, KC_F14, record); + break; + + case KB_MAKE: + if (!get_mods()) { + if (!record->event.pressed) + SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP SS_TAP(X_ENTER)); + return false; + } + break; + + case KB_VRSN: + if (!get_mods()) { + if (!record->event.pressed) { + if (user_config.system_mac) { + SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " (mac mode)"); + } else { + SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " (non-mac mode)"); + } + } + return false; + } + break; + + case KB_BOOT: + if (!get_mods()) { + if (record->event.pressed) { + boot_timer = timer_read32(); + } else { + if (timer_elapsed32(boot_timer) >= 500) { + reset_keyboard(); + } + } + return false; + } + break; + + case KB_FLSH: + if (!get_mods()) { + if (!record->event.pressed) { + SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP ":flash\n"); + reset_keyboard(); + } + return false; + } + break; + +#ifdef DO_SECRETS + case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo + if (!record->event.pressed) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + send_secret_string(keycode - KC_SECRET_1); + } + return false; + break; +#endif + } + + return true; +} + +__attribute__ ((weak)) +void matrix_init_keymap(void) { +} + +void matrix_init_user(void) { + matrix_init_keymap(); +} + +__attribute__ ((weak)) +void matrix_scan_keymap(void) { +} + +void matrix_scan_user(void) { + matrix_scan_keymap(); +} + +__attribute__ ((weak)) +layer_state_t layer_state_set_keymap(layer_state_t state) { + return state; +} + +layer_state_t layer_state_set_user(layer_state_t state) { + return layer_state_set_keymap(state); +} diff --git a/users/jdelkins/jdelkins.h b/users/jdelkins/jdelkins.h new file mode 100644 index 0000000000..ddec8dc4ae --- /dev/null +++ b/users/jdelkins/jdelkins.h @@ -0,0 +1,134 @@ +/* + Copyright 2020 Joel Elkins <joel@elkins.com> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#pragma once + +#include QMK_KEYBOARD_H + +// Secrets + +#if !defined(NO_SECRETS) && __has_include("secrets.h") +# define DO_SECRETS +#endif + +void send_secret_string(uint8_t n); + +// standard layers + +enum jdelkins_layers { + _QWERTY = 0, + _RPT, + _GAME, + _FUNC, + _KP, + _SECRETS, + _ADJUST, + _LAYER_MAX +}; + +// key definitions + +typedef union { + uint32_t raw; + struct { + bool system_mac :1; + }; +} user_config_t; + +extern user_config_t user_config; + +static inline void do_mac_key(uint16_t norm_key, uint16_t mac_key, keyrecord_t *record) { + uint16_t key = user_config.system_mac ? mac_key : norm_key; + if (record->event.pressed) + register_code16(key); + else + unregister_code16(key); +} + +enum jdelkins_keycodes { + KB_MAKE = SAFE_RANGE, + KB_FLSH, + KB_VRSN, + KB_BOOT, + FW_WRD, + BK_WRD, + KB_BOL, + KB_EOL, + TG_SYS, + KB_COPY, + KB_PASTE, + MY_GUI, + MY_ALT, + MY_RGUI, + MY_RALT, + MY_CALC, + +#ifdef DO_SECRETS + KC_SECRET_1, + KC_SECRET_2, + KC_SECRET_3, + KC_SECRET_4, + KC_SECRET_5, + KC_SECRET_6, +#endif + + USER_SAFE_RANGE, +}; + +#ifdef DO_SECRETS +# define KC_SEC1 KC_SECRET_1 +# define KC_SEC2 KC_SECRET_2 +# define KC_SEC3 KC_SECRET_3 +# define KC_SEC4 KC_SECRET_4 +# define KC_SEC5 KC_SECRET_5 +# define KC_SEC6 KC_SECRET_6 +#else +# define KC_SEC1 KC_NO +# define KC_SEC2 KC_NO +# define KC_SEC3 KC_NO +# define KC_SEC4 KC_NO +# define KC_SEC5 KC_NO +# define KC_SEC6 KC_NO +#endif + +#define MODS_SHIFT (get_mods() & MOD_MASK_SHIFT) +#define MODS_CTRL (get_mods() & MOD_MASK_CTRL) +#define MODS_ALT (get_mods() & MOD_MASK_ALT) +#define MODS_GUI (get_mods() & MOD_MASK_GUI) + +#define MY_CAPS LCTL_T(KC_CAPS) +#define MY_SPC LT(_FUNC, KC_SPC) + +#define NUMLOCK_ON host_keyboard_led_state().num_lock +#define CAPSLOCK_ON host_keyboard_led_state().caps_lock + +#ifdef TAP_DANCE_ENABLE + +enum { + SINGLE_TAP = 1, + SINGLE_HOLD = 2, + DOUBLE_TAP = 3, + DOUBLE_HOLD = 4, + DOUBLE_SINGLE_TAP = 5, //send two single taps + TRIPLE_TAP = 6, + TRIPLE_HOLD = 7 +}; + +int cur_dance(qk_tap_dance_state_t *state); // prefer tap +int hold_cur_dance(qk_tap_dance_state_t *state); // prefer hold + +#endif // TAP_DANCE_ENABLE diff --git a/users/jdelkins/rules.mk b/users/jdelkins/rules.mk new file mode 100644 index 0000000000..b9d377b281 --- /dev/null +++ b/users/jdelkins/rules.mk @@ -0,0 +1,10 @@ +SRC += jdelkins.c + +ifeq ($(strip $(NO_SECRETS)), yes) + OPT_DEFS += -DNO_SECRETS +endif + +users/jdelkins/secrets.h: users/jdelkins/secrets.h.gpg + gpg -d $< >$@ + +BOOTMAGIC_ENABLE = no |