From 00abe5d8edf801cad351bf428a24532ed80f652c Mon Sep 17 00:00:00 2001 From: Daniel Shields Date: Wed, 25 Sep 2019 17:21:07 +0100 Subject: [PATCH] [Keymap] Various enhancements for dshields user space and keymaps. (#6816) - Add oneshot mod/layer unlocking - Fix Planck rev 3 backlight breathing - Fix Planck rev 6 build with arm gcc 9.2.0 - General code clean up --- keyboards/model01/keymaps/dshields/keymap.c | 14 +++---- keyboards/planck/keymaps/dshields/keymap.c | 16 +++----- users/dshields/config.h | 1 + users/dshields/dshields.c | 43 +++++++++++---------- users/dshields/dshields.h | 12 +++++- users/dshields/rules.mk | 15 ++++--- 6 files changed, 54 insertions(+), 47 deletions(-) diff --git a/keyboards/model01/keymaps/dshields/keymap.c b/keyboards/model01/keymaps/dshields/keymap.c index 6b9a541321..f79ef2c7b0 100644 --- a/keyboards/model01/keymaps/dshields/keymap.c +++ b/keyboards/model01/keymaps/dshields/keymap.c @@ -1,17 +1,13 @@ #include QMK_KEYBOARD_H #include "dshields.h" - -enum { DEF, FUN }; -enum { DYNAMIC_MACRO_RANGE = SAFE_RANGE }; - #include "dynamic_macro.h" const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [DEF] = LAYOUT( RESET , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , _______, - KC_GRV , KC_Q , KC_W , KC_E , KC_R , KC_T , RGB_TOG, DM_PLAY, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_EQL , + KC_GRV , KC_Q , KC_W , KC_E , KC_R , KC_T , RGB_TOG, _______, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_EQL , KC_PGUP, KC_A , KC_S , KC_D , KC_F , KC_G , KC_TAB , KC_ENT , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, - KC_PGDN, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_ESC , _______, KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_MINS, + KC_PGDN, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_ESC , DM_PLAY, KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_MINS, OSMLCTL, KC_RCTL, KC_BSPC, KC_SPC , KC_LGUI, OSMRALT, @@ -19,10 +15,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { OSL_FUN, OSL_FUN ), [FUN] = LAYOUT( - _______, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , + EEP_RST, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_TAB , _______, KC_MS_U, _______, KC_BTN3, _______, RGB_MOD, DM_STRT, _______, KC_LCBR, KC_RCBR, KC_LBRC, KC_RBRC, KC_F12 , - KC_HOME, KC_MS_L, KC_MS_D, KC_MS_R, KC_BTN1, _______, _______, DM_STOP, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, _______, _______, - KC_END , KC_PSCR, KC_INS , _______, KC_BTN2, _______, _______, _______, _______, _______, _______, _______, KC_BSLS, KC_PIPE, + KC_HOME, KC_MS_L, KC_MS_D, KC_MS_R, KC_BTN1, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, _______, _______, + KC_END , KC_PSCR, KC_INS , _______, KC_BTN2, _______, _______, DM_STOP, _______, _______, _______, _______, KC_BSLS, KC_PIPE, _______, _______, KC_DEL , KC_ENT , _______, _______, diff --git a/keyboards/planck/keymaps/dshields/keymap.c b/keyboards/planck/keymaps/dshields/keymap.c index 18b026da44..1c4a00b965 100644 --- a/keyboards/planck/keymaps/dshields/keymap.c +++ b/keyboards/planck/keymaps/dshields/keymap.c @@ -1,9 +1,5 @@ #include QMK_KEYBOARD_H #include "dshields.h" - -enum planck_layers { DEF, LWR, RSE, FUN }; -enum planck_keycodes { DYNAMIC_MACRO_RANGE = SAFE_RANGE }; - #include "dynamic_macro.h" const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -14,21 +10,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { OSMLCTL, KC_LGUI, OSMLALT, OSL_FUN, OSL_LWR, MT_SPC, MT_SPC, OSL_RSE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT ), [LWR] = LAYOUT_planck_grid( - KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, _______, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, + KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, _______, KC_DEL, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TILD, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, _______, KC_LCBR, KC_RCBR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DQUO, KC_PIPE, - _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END + _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END ), [RSE] = LAYOUT_planck_grid( - KC_1, KC_2, KC_3, KC_4, KC_5, _______, _______, KC_6, KC_7, KC_8, KC_9, KC_0 , + KC_1, KC_2, KC_3, KC_4, KC_5, _______, KC_DEL, KC_6, KC_7, KC_8, KC_9, KC_0 , KC_GRV, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, _______, KC_LBRC, KC_RBRC, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_QUOT, KC_BSLS, - _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END + _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END ), [FUN] = LAYOUT_planck_grid( - KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, RESET, KC_DEL, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 , + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, RESET, EEP_RST, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 , KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, - LGT_TOG, LGT_MOD, _______, _______, _______, DM_STRT, DM_STOP, _______, _______, KC_BTN1, KC_BTN2, KC_BTN3, + LGT_TOG, LGT_MOD, LGT_BRT, _______, _______, DM_STRT, DM_STOP, _______, _______, KC_BTN1, KC_BTN2, KC_BTN3, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R ) }; diff --git a/users/dshields/config.h b/users/dshields/config.h index 743f16f999..17eb98bd4f 100644 --- a/users/dshields/config.h +++ b/users/dshields/config.h @@ -5,6 +5,7 @@ #define ONESHOT_TAP_TOGGLE 2 #define ONESHOT_TIMEOUT 3000 #define RETRO_TAPPING +#define BACKLIGHT_BREATHING #define MOUSEKEY_INTERVAL 20 #define MOUSEKEY_DELAY 0 diff --git a/users/dshields/dshields.c b/users/dshields/dshields.c index 6aff5c6716..bc88cae561 100644 --- a/users/dshields/dshields.c +++ b/users/dshields/dshields.c @@ -1,30 +1,31 @@ -extern keymap_config_t keymap_config; +#include "quantum.h" +#include "dshields.h" -/* uncomment to reset -void matrix_init_user(void) { - eeconfig_init(); -}; -*/ +extern bool process_record_dynamic_macro(uint16_t keycode, keyrecord_t *record); bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!process_record_dynamic_macro(keycode, record)) { return false; } + if (keycode == KC_ESC && record->event.pressed) { + bool rc = true; + uint8_t mods = 0; + if ((mods = get_oneshot_mods()) && !has_oneshot_mods_timed_out()) { + clear_oneshot_mods(); + unregister_mods(mods); + rc = false; + } + if ((mods = get_oneshot_locked_mods())) { + clear_oneshot_locked_mods(); + unregister_mods(mods); + rc = false; + } + if (is_oneshot_layer_active()) { + layer_clear(); + rc = false; + } + return rc; + } return true; } -// work in progress -uint32_t layer_state_set_user(uint32_t state) { - switch (biton32(state)) { - case DEF: - set_all_leds_to(0,0,0); - break; - case FUN: - // TODO light the fn keys - // set_led_to(?, 0, 128, 0); - // set_led_to(?, 0, 128, 0); - break; - } - return state; -} - diff --git a/users/dshields/dshields.h b/users/dshields/dshields.h index c746e74fb5..a65ccfea00 100644 --- a/users/dshields/dshields.h +++ b/users/dshields/dshields.h @@ -24,8 +24,18 @@ #ifdef KEYBOARD_planck_light #define LGT_TOG RGB_TOG #define LGT_MOD RGB_MOD -#else + #define LGT_BRT _______ +#endif +#ifdef KEYBOARD_planck_rev3 #define LGT_TOG BL_TOGG #define LGT_MOD BL_STEP + #define LGT_BRT BL_BRTG +#endif +#ifdef KEYBOARD_planck_rev6 + #define LGT_TOG _______ + #define LGT_MOD _______ + #define LGT_BRT _______ #endif +enum layers { DEF, LWR, RSE, FUN }; +enum keycodes { DYNAMIC_MACRO_RANGE = SAFE_RANGE }; diff --git a/users/dshields/rules.mk b/users/dshields/rules.mk index a2bec43357..06f6e5e9fa 100644 --- a/users/dshields/rules.mk +++ b/users/dshields/rules.mk @@ -1,9 +1,11 @@ -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -COMMAND_ENABLE = no # Commands for debug and configuration -CONSOLE_ENABLE = no # Console for debug(+400) -EXTRAKEY_ENABLE = no -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend -API_SYSEX_ENABLE = no +SRC += dshields.c + +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +COMMAND_ENABLE = no # Commands for debug and configuration +CONSOLE_ENABLE = no # Console for debug(+400) +EXTRAKEY_ENABLE = no +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +API_SYSEX_ENABLE = no ifeq ($(strip $(KEYBOARD)), planck/rev3) AUDIO_ENABLE = no @@ -11,6 +13,7 @@ ifeq ($(strip $(KEYBOARD)), planck/rev3) RGB_MATRIX_ENABLE = no endif ifeq ($(strip $(KEYBOARD)), planck/rev6) + CFLAGS += -Wno-error=deprecated EXTRALDFLAGS = -Wl,--build-id=none AUDIO_ENABLE = no BACKLIGHT_ENABLE = no