diff --git a/keyboards/sofle/keymaps/keyhive_via/config.h b/keyboards/sofle/keymaps/keyhive_via/config.h index 94bdd92d809b..9d6b67083554 100644 --- a/keyboards/sofle/keymaps/keyhive_via/config.h +++ b/keyboards/sofle/keymaps/keyhive_via/config.h @@ -29,3 +29,11 @@ for more options. #define RGBLIGHT_HUE_STEP 10 #define RGBLIGHT_SAT_STEP 17 #define RGBLIGHT_VAL_STEP 17 + +#define DYNAMIC_KEYMAP_LAYER_COUNT 5 + +// Disabled to save space +#define NO_ACTION_ONESHOT // -332 +#define NO_ACTION_MACRO // -0 +#define NO_ACTION_FUNCTION // -0 +#define DISABLE_LEADER // -0 diff --git a/keyboards/sofle/keymaps/keyhive_via/keymap.c b/keyboards/sofle/keymaps/keyhive_via/keymap.c index fdff9d4f87d8..670b213e28fd 100644 --- a/keyboards/sofle/keymaps/keyhive_via/keymap.c +++ b/keyboards/sofle/keymaps/keyhive_via/keymap.c @@ -20,15 +20,22 @@ #include "oled.c" #include "encoder.c" +#define BASE_LAYERS 3 + +enum custom_keycodes { + // cycle BASE_LAYERS (62 bytes) + CYCLE_L = SAFE_RANGE +}; + enum custom_layers { _QWERTY, _COLEMAK, + _COLEMAK_DH, _LOWER, _RAISE }; -//Default keymap. This can be changed in Via. Use oled.c and encoder.c to change beavior that Via cannot change. - +//Default keymap. This can be changed in Via. Use oled.c to change beavior that Via cannot change. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* * QWERTY @@ -51,7 +58,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_ESC, KC_Q , KC_W , KC_E , KC_R , KC_T , KC_VOLU, KC_PGUP, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_BSPC, KC_TAB, KC_A , KC_S , KC_D , KC_F , KC_G , KC_MUTE, KC_NO , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_VOLD, KC_PGDN, KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, - KC_LGUI,KC_LALT ,KC_LCTRL, MO(2) , KC_ENT , KC_SPC , MO(3) ,KC_RCTRL, KC_RALT, KC_RGUI + KC_LGUI,KC_LALT ,KC_LCTRL,MO(_LOWER), KC_ENT , KC_SPC ,MO(_RAISE),KC_RCTRL, KC_RALT, KC_RGUI ), /* * COLEMAK @@ -74,8 +81,33 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_ESC , KC_Q , KC_W , KC_F , KC_P , KC_G , KC_VOLU, KC_PGUP, KC_J , KC_L , KC_U , KC_Y , KC_SCLN, KC_BSPC, KC_TAB , KC_A , KC_R , KC_S , KC_T , KC_D , KC_MUTE, KC_NO , KC_H , KC_N , KC_E , KC_I , KC_O , KC_QUOT, KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_VOLD, KC_PGDN, KC_N , KC_M , KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, - KC_LGUI, KC_LALT,KC_LCTRL, KC_TRNS, KC_ENT , KC_SPC , KC_TRNS,KC_RCTRL, KC_RALT, KC_RGUI + KC_LGUI, KC_LALT,KC_LCTRL,MO(_LOWER), KC_ENT , KC_SPC ,MO(_RAISE),KC_RCTRL, KC_RALT, KC_RGUI +), + +/* + * COLEMAK-DH + * ,-----------------------------------------. ,-----------------------------------------. + * | ` | 1 | 2 | 3 | 4 | 5 |-------. E ,-------| 6 | 7 | 8 | 9 | 0 | ` | + * |------+------+------+------+------+------| VolUp |< N >| Pg Up |------+------+------+------+------+------| + * | ESC | Q | W | F | P | B |-------. C ,-------| J | L | U | Y | ; | Bspc | + * |------+------+------+------+------+------| Mute |< O >| |------+------+------+------+------+------| + * | TAB | A | R | S | T | G |-------. D ,-------| M | N | E | I | O | ' | + * |------+------+------+------+------+------| VolDn |< E >| Pg Dn |------+------+------+------+------+------| + * |LShift| Z | X | C | D | V |-------| R |-------| K | H | , | . | / |RShift| + * `-----------------------------------------/ / \ \-----------------------------------------' + * | LGUI | LAlt | LCTR |LOWER | /Enter / \Space \ |RAISE | RCTR | RAlt | RGUI | + * | | | | |/ / \ \ | | | | | + * `-----------------------------------' '------''---------------------------' + */ + +[_COLEMAK_DH] = LAYOUT_via( + KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_GRV , + KC_ESC , KC_Q , KC_W , KC_F , KC_P , KC_B , KC_VOLU, KC_PGUP, KC_J , KC_L , KC_U , KC_Y , KC_SCLN, KC_BSPC, + KC_TAB , KC_A , KC_R , KC_S , KC_T , KC_G , KC_MUTE, KC_NO , KC_M , KC_N , KC_E , KC_I , KC_O , KC_QUOT, + KC_LSFT, KC_Z , KC_X , KC_C , KC_D , KC_V , KC_VOLD, KC_PGDN, KC_K , KC_H , KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + KC_LGUI, KC_LALT,KC_LCTRL,MO(_LOWER), KC_ENT , KC_SPC ,MO(_RAISE),KC_RCTRL, KC_RALT, KC_RGUI ), + /* LOWER * ,-----------------------------------------. ,-----------------------------------------. * | | F1 | F2 | F3 | F4 | F5 |-------. E ,-------| F6 | F7 | F8 | F9 | F10 | F11 | @@ -99,7 +131,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), /* RAISE * ,----------------------------------------. ,-----------------------------------------. - * | | | | | | |-------. E ,-------| | | | | | | + * |Cycle | | | | | |-------. E ,-------| | | | | | | * |------+------+------+------+------+------| |< N >| |------+------+------+------+------+------| * | Esc | Ins | Pscr | Menu | | |-------. C ,-------| | | Up | | DLine| Bspc | * |------+------+------+------+------+------| |< O >| |------+------+------+------+------+------| @@ -112,10 +144,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `----------------------------------' '------''---------------------------' */ [_RAISE] = LAYOUT_via( - _______, _______, _______, _______, _______ , _______, _______, _______, _______, _______, _______, _______, + CYCLE_L, _______, _______, _______, _______ , _______, _______, _______, _______, _______, _______, _______, _______, KC_INS , KC_PSCR, KC_APP , XXXXXXX , XXXXXXX, _______, _______, KC_PGUP, _______, KC_UP , _______, _______, KC_BSPC, _______, KC_LALT, KC_LCTL, KC_LSFT, XXXXXXX , KC_CAPS, _______, _______, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_DEL , KC_BSPC, _______, KC_UNDO, KC_CUT , KC_COPY, KC_PASTE, XXXXXXX, _______, _______, XXXXXXX, _______, XXXXXXX, _______, XXXXXXX, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ) }; + +// Custom keycode handling. +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // handling this once instead of in each keycode uses less program memory. + if ((keycode >= SAFE_RANGE) && !(record->event.pressed)) { + return false; + } + + switch (keycode) { + case CYCLE_L: + set_single_persistent_default_layer((1+get_highest_layer(default_layer_state)) % BASE_LAYERS); + break; + } + + // this uses less memory than returning in each case. + return keycode < SAFE_RANGE; +}; diff --git a/keyboards/sofle/keymaps/keyhive_via/oled.c b/keyboards/sofle/keymaps/keyhive_via/oled.c index 8a230f000111..3bb9a7b5d50a 100644 --- a/keyboards/sofle/keymaps/keyhive_via/oled.c +++ b/keyboards/sofle/keymaps/keyhive_via/oled.c @@ -33,31 +33,35 @@ static void print_status_narrow(void) { // Print current mode oled_write_P(PSTR("\n\n"), false); - switch (get_highest_layer(layer_state)) { - case 0: - oled_write_ln_P(PSTR("Qwrt"), false); + switch (get_highest_layer(default_layer_state)) { + case 0: // _QWERTY + oled_write_ln_P(PSTR("Qwrt\n"), false); + break; + case 1: // _COLEMAK + oled_write_ln_P(PSTR("Clmk\n"), false); break; - case 1: - oled_write_ln_P(PSTR("Clmk"), false); + case 2: // _COLEMAK_DH + oled_write_ln_P(PSTR("Clmk\n DH"), false); break; default: - oled_write_P(PSTR("Mod\n"), false); + oled_write_P(PSTR("Mod"), false); break; } oled_write_P(PSTR("\n\n"), false); // Print current layer oled_write_ln_P(PSTR("LAYER"), false); switch (get_highest_layer(layer_state)) { - case 0: - case 1: + case 0: // _QWERTY + case 1: // _COLEMAK + case 2: // _COLEMAK_DH oled_write_P(PSTR("Base\n"), false); break; - case 2: - oled_write_P(PSTR("Raise"), false); - break; case 3: oled_write_P(PSTR("Lower"), false); break; + case 4: + oled_write_P(PSTR("Raise"), false); + break; default: oled_write_ln_P(PSTR("Undef"), false); }