From d024666839526c04a2e23fe9428425cee8f67f98 Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Fri, 27 May 2022 21:30:18 -0500 Subject: [PATCH 1/7] Add mapping for Keebio FoldKB --- .../keebio/foldkb/keymaps/forrcaho/keymap.c | 100 ++++++++++++++++++ .../keebio/foldkb/keymaps/forrcaho/rules.mk | 1 + 2 files changed, 101 insertions(+) create mode 100644 keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c create mode 100644 keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c new file mode 100644 index 000000000000..f5abd1537a70 --- /dev/null +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c @@ -0,0 +1,100 @@ +/* Copyright 2021 Danny Nguyen + +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 . +*/ + +#include QMK_KEYBOARD_H + +enum custom_keycodes { + PG_LPAR = SAFE_RANGE, + PG_RPAR, + PG_LBRK, + PG_RBRK, + PG_VBAR, + PG_BANG, + PG_SLAS +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT( + KC_MUTE, KC_ESC, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_HOME, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_END, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_PGUP, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1), + KC_PGDN, KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RCTL, TG(1), KC_RGUI + ), + [1] = LAYOUT( + KC_MUTE, RESET, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + BL_STEP, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, _______, _______, KC_HOME, KC_UP, KC_PGUP, _______, _______, _______, _______, + RGB_MOD, _______, _______, PG_VBAR, PG_LBRK, PG_RBRK, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, + KC_VOLU, _______, _______, KC_MINS, KC_EQL, PG_BANG, _______, _______, KC_END, KC_INS, KC_PGDN, _______, _______, _______, + KC_VOLD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + ), +}; + +const key_override_t pg_lpar_none = ko_make_with_layers_and_negmods(0, PG_LPAR, KC_LEFT_PAREN, ~0, ~0); +const key_override_t pg_lpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LPAR, KC_LEFT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); + +const key_override_t pg_rpar_none = ko_make_with_layers_and_negmods(0, PG_RPAR, KC_RIGHT_PAREN, ~0, ~0); +const key_override_t pg_rpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RPAR, KC_RIGHT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); + +const key_override_t pg_lbrk_none = ko_make_with_layers_and_negmods(0, PG_LBRK, KC_LEFT_CURLY_BRACE, ~0, ~0); +const key_override_t pg_lbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LBRK, KC_LEFT_BRACKET, ~0, ~MOD_MASK_SHIFT); + +const key_override_t pg_rbrk_none = ko_make_with_layers_and_negmods(0, PG_RBRK, KC_RIGHT_CURLY_BRACE, ~0, ~0); +const key_override_t pg_rbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RBRK, KC_RIGHT_BRACKET, ~0, ~MOD_MASK_SHIFT); + +const key_override_t pg_bang_none = ko_make_with_layers_and_negmods(0, PG_BANG, KC_EXCLAIM, ~0, ~0); +const key_override_t pg_bang_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_BANG, KC_ASTERISK, ~0, ~MOD_MASK_SHIFT); + +const key_override_t pg_slas_none = ko_make_with_layers_and_negmods(0, PG_SLAS, KC_SLASH, ~0, ~0); +const key_override_t pg_slas_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_SLAS, KC_BACKSLASH, ~0, ~MOD_MASK_SHIFT); + +const key_override_t pg_vbar_none = ko_make_with_layers_and_negmods(0, PG_VBAR, KC_PIPE, ~0, ~0); +const key_override_t pg_vbar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_VBAR, KC_AMPERSAND, ~0, ~MOD_MASK_SHIFT); + + +const key_override_t **key_overrides = (const key_override_t *[]){ + &pg_lpar_none, + &pg_lpar_shift, + &pg_rpar_none, + &pg_rpar_shift, + &pg_lbrk_none, + &pg_lbrk_shift, + &pg_rbrk_none, + &pg_rbrk_shift, + &pg_bang_none, + &pg_bang_shift, + &pg_slas_none, + &pg_slas_shift, + &pg_vbar_none, + &pg_vbar_shift, + NULL +}; + +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case 1: + backlight_level(3); + break; + default: + backlight_level(1); + break; + } + return state; +} + +void keyboard_post_init(void) { + backlight_level(1); +} diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk b/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk new file mode 100644 index 000000000000..90c9b36df0c7 --- /dev/null +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk @@ -0,0 +1 @@ +KEY_OVERRIDE_ENABLE = yes From 9b5582bf71db81d88598ddbcd90301714782a0f1 Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Sat, 28 May 2022 21:46:32 -0500 Subject: [PATCH 2/7] Add (test) macro key; draw box chars around layout --- .../keebio/foldkb/keymaps/forrcaho/keymap.c | 68 +++++++++++++++---- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c index f5abd1537a70..d347fbb5f53b 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c @@ -16,6 +16,11 @@ along with this program. If not, see . #include QMK_KEYBOARD_H +enum layer { + _QWERTY, + _PG, // for "programming" +}; + enum custom_keycodes { PG_LPAR = SAFE_RANGE, PG_RPAR, @@ -23,23 +28,36 @@ enum custom_keycodes { PG_RBRK, PG_VBAR, PG_BANG, - PG_SLAS + PG_SLAS, + PG_ENDC }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [0] = LAYOUT( - KC_MUTE, KC_ESC, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_HOME, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - KC_END, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_PGUP, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1), - KC_PGDN, KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RCTL, TG(1), KC_RGUI + [_QWERTY] = LAYOUT( +// ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ + KC_MUTE, KC_ESC, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, +// ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ + KC_HOME, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, +// ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ + KC_END, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, +// ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ + KC_PGUP, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1), +// ├────────┼───┬──────────┬──┴─────┬──┴──────┬─┴────────┼────────┼────────┤ ├────────┴─┬──────┴───┬────┴─────┬──┴────────┼──────────┬──┴────────┤ + KC_PGDN, KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, TG(1), KC_RALT, KC_RCTL, KC_RGUI +// └────────┴───┴──────────┴─────────┴─────────┴─────────┴────────┴────────┘ └──────────┴──────────┴──────────┴───────────┴──────────┴───────────┘ ), - [1] = LAYOUT( - KC_MUTE, RESET, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, - BL_STEP, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, _______, _______, KC_HOME, KC_UP, KC_PGUP, _______, _______, _______, _______, - RGB_MOD, _______, _______, PG_VBAR, PG_LBRK, PG_RBRK, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, - KC_VOLU, _______, _______, KC_MINS, KC_EQL, PG_BANG, _______, _______, KC_END, KC_INS, KC_PGDN, _______, _______, _______, - KC_VOLD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + [_PG] = LAYOUT( +// ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ + KC_MUTE, RESET, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, +// ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ + BL_STEP, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, _______, _______, KC_HOME, KC_UP, KC_PGUP, _______, _______, _______, _______, +// ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ + RGB_MOD, _______, PG_ENDC, PG_VBAR, PG_LBRK, PG_RBRK, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, KC_BSPC, +// ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ + KC_VOLU, _______, _______, KC_MINS, KC_EQL, PG_BANG, _______, _______, KC_END, KC_INS, KC_PGDN, _______, _______, _______, +// ├────────┼───┬──────────┬──┴─────┬──┴──────┬─┴────────┼────────┼────────┤ ├────────┴─┬──────┴───┬────┴─────┬──┴────────┼──────────┬──┴────────┤ + KC_VOLD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +// └────────┴───┴──────────┴─────────┴─────────┴─────────┴────────┴────────┘ └──────────┴──────────┴──────────┴───────────┴──────────┴───────────┘ ), }; @@ -83,6 +101,30 @@ const key_override_t **key_overrides = (const key_override_t *[]){ NULL }; +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + uint8_t std_mods = get_mods(); + uint8_t oneshot_mods = get_oneshot_mods(); + uint8_t all_mods = std_mods | oneshot_mods; + + switch (keycode) { + case PG_ENDC: + // If any mods other than shift are down, don't handle this + if (all_mods & ~MOD_MASK_SHIFT) return true; + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + SEND_STRING(SS_TAP(X_END) ";"); + if ( !(all_mods & MOD_MASK_SHIFT) ) { + SEND_STRING(SS_TAP(X_ENTER)); + } + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + } + break; + } + return true; +} + layer_state_t layer_state_set_user(layer_state_t state) { switch (get_highest_layer(state)) { case 1: From 063c389c7baf19b17738b4985feb6e9b9fd820b6 Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Sun, 29 May 2022 19:24:24 -0500 Subject: [PATCH 3/7] More programming macro keys added --- .../keebio/foldkb/keymaps/forrcaho/keymap.c | 138 +++++++++++++----- 1 file changed, 103 insertions(+), 35 deletions(-) diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c index d347fbb5f53b..1a350260d393 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c @@ -22,14 +22,18 @@ enum layer { }; enum custom_keycodes { - PG_LPAR = SAFE_RANGE, - PG_RPAR, + PG_BANG = SAFE_RANGE, + PG_ENDC, + PG_EQEQ, + PG_EQL, PG_LBRK, + PG_LPAR, + PG_MINS, + PG_NEEQ, PG_RBRK, - PG_VBAR, - PG_BANG, + PG_RPAR, PG_SLAS, - PG_ENDC + PG_VBAR, }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -42,39 +46,42 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_END, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, // ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ KC_PGUP, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1), -// ├────────┼───┬──────────┬──┴─────┬──┴──────┬─┴────────┼────────┼────────┤ ├────────┴─┬──────┴───┬────┴─────┬──┴────────┼──────────┬──┴────────┤ - KC_PGDN, KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, TG(1), KC_RALT, KC_RCTL, KC_RGUI -// └────────┴───┴──────────┴─────────┴─────────┴─────────┴────────┴────────┘ └──────────┴──────────┴──────────┴───────────┴──────────┴───────────┘ +// ├────────┼───┬──────────┬──┴──────┬─┴────────┼────────┼────────┼────────┤ ├────────┴─┬──────┴──────┬─┴────────┼────────┴─┬─────────┬─┴────────┤ + KC_PGDN, KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, TG(1), KC_RALT, KC_RCTL, KC_RGUI +// └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ ), [_PG] = LAYOUT( // ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ - KC_MUTE, RESET, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_MUTE, RESET, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, // ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ - BL_STEP, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, _______, _______, KC_HOME, KC_UP, KC_PGUP, _______, _______, _______, _______, + BL_STEP, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, PG_NEEQ, _______, KC_HOME, KC_UP, KC_PGUP, _______, _______, _______, _______, // ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ - RGB_MOD, _______, PG_ENDC, PG_VBAR, PG_LBRK, PG_RBRK, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, KC_BSPC, + RGB_MOD, _______, PG_ENDC, PG_VBAR, PG_LBRK, PG_RBRK, PG_EQEQ, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, KC_BSPC, // ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ - KC_VOLU, _______, _______, KC_MINS, KC_EQL, PG_BANG, _______, _______, KC_END, KC_INS, KC_PGDN, _______, _______, _______, -// ├────────┼───┬──────────┬──┴─────┬──┴──────┬─┴────────┼────────┼────────┤ ├────────┴─┬──────┴───┬────┴─────┬──┴────────┼──────────┬──┴────────┤ - KC_VOLD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ -// └────────┴───┴──────────┴─────────┴─────────┴─────────┴────────┴────────┘ └──────────┴──────────┴──────────┴───────────┴──────────┴───────────┘ + KC_VOLU, _______, _______, PG_MINS, PG_EQL, PG_BANG, _______, _______, KC_END, KC_INS, KC_PGDN, _______, _______, _______, +// ├────────┼───┬──────────┬──┴──────┬─┴────────┼────────┼────────┼────────┤ ├────────┴─┬──────┴──────┬─┴────────┼────────┴─┬─────────┬─┴────────┤ + KC_VOLD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +// └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ ), }; -const key_override_t pg_lpar_none = ko_make_with_layers_and_negmods(0, PG_LPAR, KC_LEFT_PAREN, ~0, ~0); -const key_override_t pg_lpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LPAR, KC_LEFT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); - -const key_override_t pg_rpar_none = ko_make_with_layers_and_negmods(0, PG_RPAR, KC_RIGHT_PAREN, ~0, ~0); -const key_override_t pg_rpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RPAR, KC_RIGHT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); +const key_override_t pg_bang_none = ko_make_with_layers_and_negmods(0, PG_BANG, KC_EXCLAIM, ~0, ~0); +// Shifted PG_BANG is macro const key_override_t pg_lbrk_none = ko_make_with_layers_and_negmods(0, PG_LBRK, KC_LEFT_CURLY_BRACE, ~0, ~0); const key_override_t pg_lbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LBRK, KC_LEFT_BRACKET, ~0, ~MOD_MASK_SHIFT); +const key_override_t pg_lpar_none = ko_make_with_layers_and_negmods(0, PG_LPAR, KC_LEFT_PAREN, ~0, ~0); +const key_override_t pg_lpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LPAR, KC_LEFT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); + +// Unshifted PG_MINS is macro +const key_override_t pg_mins_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_MINS, KC_UNDERSCORE, ~0, ~MOD_MASK_SHIFT); + const key_override_t pg_rbrk_none = ko_make_with_layers_and_negmods(0, PG_RBRK, KC_RIGHT_CURLY_BRACE, ~0, ~0); const key_override_t pg_rbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RBRK, KC_RIGHT_BRACKET, ~0, ~MOD_MASK_SHIFT); -const key_override_t pg_bang_none = ko_make_with_layers_and_negmods(0, PG_BANG, KC_EXCLAIM, ~0, ~0); -const key_override_t pg_bang_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_BANG, KC_ASTERISK, ~0, ~MOD_MASK_SHIFT); +const key_override_t pg_rpar_none = ko_make_with_layers_and_negmods(0, PG_RPAR, KC_RIGHT_PAREN, ~0, ~0); +const key_override_t pg_rpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RPAR, KC_RIGHT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); const key_override_t pg_slas_none = ko_make_with_layers_and_negmods(0, PG_SLAS, KC_SLASH, ~0, ~0); const key_override_t pg_slas_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_SLAS, KC_BACKSLASH, ~0, ~MOD_MASK_SHIFT); @@ -84,16 +91,16 @@ const key_override_t pg_vbar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SH const key_override_t **key_overrides = (const key_override_t *[]){ - &pg_lpar_none, - &pg_lpar_shift, - &pg_rpar_none, - &pg_rpar_shift, + &pg_bang_none, &pg_lbrk_none, &pg_lbrk_shift, + &pg_lpar_none, + &pg_lpar_shift, + &pg_mins_shift, &pg_rbrk_none, &pg_rbrk_shift, - &pg_bang_none, - &pg_bang_shift, + &pg_rpar_none, + &pg_rpar_shift, &pg_slas_none, &pg_slas_shift, &pg_vbar_none, @@ -105,18 +112,79 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint8_t std_mods = get_mods(); uint8_t oneshot_mods = get_oneshot_mods(); uint8_t all_mods = std_mods | oneshot_mods; + bool shift_on = all_mods & MOD_MASK_SHIFT; + bool alt_on = all_mods & MOD_MASK_ALT; + + // None of our special keycodes use CTRL or GUI mods (so far), so we + // check once here at the top and let other code handle it if any of + // these are set. + if (all_mods & (MOD_MASK_CTRL | MOD_MASK_GUI)) return true; switch (keycode) { + case PG_BANG: + if (!shift_on) return true; // key override handles it + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!alt_on) SEND_STRING(" "); + SEND_STRING("*"); + if (!alt_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + } + break; case PG_ENDC: - // If any mods other than shift are down, don't handle this - if (all_mods & ~MOD_MASK_SHIFT) return true; if (record->event.pressed) { clear_mods(); clear_oneshot_mods(); - SEND_STRING(SS_TAP(X_END) ";"); - if ( !(all_mods & MOD_MASK_SHIFT) ) { - SEND_STRING(SS_TAP(X_ENTER)); - } + SEND_STRING(SS_TAP(X_END)); + if (!shift_on) SEND_STRING(";"); + if (!alt_on) SEND_STRING(SS_TAP(X_ENTER)); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + } + break; + case PG_EQEQ: + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!alt_on) SEND_STRING(" "); + shift_on ? SEND_STRING("==") : SEND_STRING("==="); + if (!alt_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + } + break; + case PG_EQL: + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!alt_on) SEND_STRING(" "); + shift_on ? SEND_STRING("+") : SEND_STRING("="); + if (!alt_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + } + break; + case PG_MINS: + if (!shift_on) return true; // key override handles it + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!alt_on) SEND_STRING(" "); + SEND_STRING("-"); + if (!alt_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + } + break; + case PG_NEEQ: + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!alt_on) SEND_STRING(" "); + shift_on ? SEND_STRING("!=") : SEND_STRING("!=="); + if (!alt_on) SEND_STRING(" "); set_mods(std_mods); set_oneshot_mods(oneshot_mods); } @@ -127,7 +195,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { layer_state_t layer_state_set_user(layer_state_t state) { switch (get_highest_layer(state)) { - case 1: + case _PG: backlight_level(3); break; default: From feb2cfdf943d2289682ab31d657fd2108594c8fc Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Tue, 31 May 2022 06:53:04 -0500 Subject: [PATCH 4/7] Fix stupid bug: return false when key has been handled --- keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c index ce5329a6049b..38984cd832d4 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c @@ -131,6 +131,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!ctrl_on) SEND_STRING(" "); set_mods(std_mods); set_oneshot_mods(oneshot_mods); + return false; } break; case PG_ENDC: @@ -142,6 +143,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!ctrl_on) SEND_STRING(SS_TAP(X_ENTER)); set_mods(std_mods); set_oneshot_mods(oneshot_mods); + return false; } break; case PG_EQEQ: @@ -153,6 +155,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!ctrl_on) SEND_STRING(" "); set_mods(std_mods); set_oneshot_mods(oneshot_mods); + return false; } break; case PG_EQL: @@ -164,10 +167,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!ctrl_on) SEND_STRING(" "); set_mods(std_mods); set_oneshot_mods(oneshot_mods); + return false; } break; case PG_MINS: - if (!shift_on) return true; // key override handles it + if (shift_on) return true; // key override handles it if (record->event.pressed) { clear_mods(); clear_oneshot_mods(); @@ -176,6 +180,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!ctrl_on) SEND_STRING(" "); set_mods(std_mods); set_oneshot_mods(oneshot_mods); + return false; } break; case PG_NEEQ: @@ -187,6 +192,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!ctrl_on) SEND_STRING(" "); set_mods(std_mods); set_oneshot_mods(oneshot_mods); + return false; } break; } From 7fd4df707c99622302269b06ab5099611bb5617b Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Sun, 5 Jun 2022 23:01:02 -0500 Subject: [PATCH 5/7] Add mouse layer --- .../keebio/foldkb/keymaps/forrcaho/keymap.c | 69 ++++++++++++------- .../keebio/foldkb/keymaps/forrcaho/rules.mk | 1 + 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c index 38984cd832d4..eea30c18fb5c 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c @@ -19,6 +19,7 @@ along with this program. If not, see . enum layer { _QWERTY, _PG, // for "programming" + _MS, // for "mouse" }; enum custom_keycodes { @@ -41,42 +42,49 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ KC_MUTE, KC_ESC, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, // ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ - KC_HOME, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + MO(_PG), KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, // ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ - KC_END, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + MO(_MS), KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, // ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ - KC_PGUP, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(1), + TG(_PG), KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(_PG), // ├────────┼───┬──────────┬──┴──────┬─┴────────┼────────┼────────┼────────┤ ├────────┴─┬──────┴──────┬─┴────────┼────────┴─┬─────────┬─┴────────┤ - KC_PGDN, KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, TG(1), KC_RALT, KC_RCTL, KC_RGUI + TG(_MS), KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, TG(_MS), KC_RALT, KC_RCTL, KC_RGUI // └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ ), [_PG] = LAYOUT( // ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ KC_MUTE, RESET, _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, // ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ - BL_STEP, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, PG_NEEQ, _______, KC_HOME, KC_UP, KC_PGUP, _______, _______, _______, _______, + _______, _______, _______, PG_SLAS, PG_LPAR, PG_RPAR, PG_NEEQ, _______, KC_HOME, KC_UP, KC_PGUP, KC_INS, _______, _______, _______, // ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ - RGB_MOD, _______, PG_ENDC, PG_VBAR, PG_LBRK, PG_RBRK, PG_EQEQ, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, KC_BSPC, + _______, _______, PG_ENDC, PG_VBAR, PG_LBRK, PG_RBRK, PG_EQEQ, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, KC_BSPC, // ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ - KC_VOLU, _______, _______, PG_MINS, PG_EQL, PG_BANG, _______, _______, KC_END, KC_INS, KC_PGDN, _______, _______, _______, + _______, _______, _______, PG_MINS, PG_EQL, PG_BANG, _______, _______, KC_END, KC_DOWN, KC_PGDN, KC_DEL, _______, _______, // ├────────┼───┬──────────┬──┴──────┬─┴────────┼────────┼────────┼────────┤ ├────────┴─┬──────┴──────┬─┴────────┼────────┴─┬─────────┬─┴────────┤ - KC_VOLD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ +// └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ + ), + [_MS] = LAYOUT( +// ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, +// ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ + _______, _______, _______, _______, _______, _______, _______, _______, KC_BTN1, KC_MS_U, KC_BTN2, _______, _______, _______, _______, +// ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ + _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, _______, +// ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_D, _______, _______, _______, _______, +// ├────────┼───┬──────────┬──┴──────┬─┴────────┼────────┼────────┼────────┤ ├────────┴─┬──────┴──────┬─┴────────┼────────┴─┬─────────┬─┴────────┤ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ // └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ ), }; -const key_override_t pg_bang_none = ko_make_with_layers_and_negmods(0, PG_BANG, KC_EXCLAIM, ~0, ~0); -// Shifted PG_BANG is macro - const key_override_t pg_lbrk_none = ko_make_with_layers_and_negmods(0, PG_LBRK, KC_LEFT_CURLY_BRACE, ~0, ~0); const key_override_t pg_lbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LBRK, KC_LEFT_BRACKET, ~0, ~MOD_MASK_SHIFT); const key_override_t pg_lpar_none = ko_make_with_layers_and_negmods(0, PG_LPAR, KC_LEFT_PAREN, ~0, ~0); const key_override_t pg_lpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LPAR, KC_LEFT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); -// Unshifted PG_MINS is macro -const key_override_t pg_mins_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_MINS, KC_UNDERSCORE, ~0, ~MOD_MASK_SHIFT); - const key_override_t pg_rbrk_none = ko_make_with_layers_and_negmods(0, PG_RBRK, KC_RIGHT_CURLY_BRACE, ~0, ~0); const key_override_t pg_rbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RBRK, KC_RIGHT_BRACKET, ~0, ~MOD_MASK_SHIFT); @@ -91,12 +99,10 @@ const key_override_t pg_vbar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SH const key_override_t **key_overrides = (const key_override_t *[]){ - &pg_bang_none, &pg_lbrk_none, &pg_lbrk_shift, &pg_lpar_none, &pg_lpar_shift, - &pg_mins_shift, &pg_rbrk_none, &pg_rbrk_shift, &pg_rpar_none, @@ -122,13 +128,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case PG_BANG: - if (!shift_on) return true; // key override handles it if (record->event.pressed) { clear_mods(); clear_oneshot_mods(); - if (!ctrl_on) SEND_STRING(" "); - SEND_STRING("*"); - if (!ctrl_on) SEND_STRING(" "); + if (shift_on) { + if (!ctrl_on) SEND_STRING(" "); + SEND_STRING("*"); + if (!ctrl_on) SEND_STRING(" "); + } else { + if (ctrl_on) SEND_STRING(" "); + SEND_STRING("!"); + if (!ctrl_on) SEND_STRING(" "); + } set_mods(std_mods); set_oneshot_mods(oneshot_mods); return false; @@ -171,13 +182,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } break; case PG_MINS: - if (shift_on) return true; // key override handles it if (record->event.pressed) { clear_mods(); clear_oneshot_mods(); - if (!ctrl_on) SEND_STRING(" "); - SEND_STRING("-"); - if (!ctrl_on) SEND_STRING(" "); + if (shift_on) { + if (ctrl_on) SEND_STRING(" "); + SEND_STRING("_"); + if (ctrl_on) SEND_STRING(" "); + } else { + if (!ctrl_on) SEND_STRING(" "); + SEND_STRING("-"); + if (!ctrl_on) SEND_STRING(" "); + } set_mods(std_mods); set_oneshot_mods(oneshot_mods); return false; @@ -201,9 +217,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { layer_state_t layer_state_set_user(layer_state_t state) { switch (get_highest_layer(state)) { - case _PG: + case _MS: backlight_level(3); break; + case _PG: + backlight_level(2); + break; default: backlight_level(1); break; diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk b/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk index 90c9b36df0c7..5ac74d5320e7 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk @@ -1 +1,2 @@ KEY_OVERRIDE_ENABLE = yes +MOUSEKEY_ENABLE = yes From 538b3f1790134983f3c90769f5baa2927b2299e7 Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Sat, 11 Jun 2022 22:01:18 -0500 Subject: [PATCH 6/7] Encoder functions as mouse scroll wheel --- .../keebio/foldkb/keymaps/forrcaho/keymap.c | 219 +++++++++--------- .../keebio/foldkb/keymaps/forrcaho/rules.mk | 1 + 2 files changed, 116 insertions(+), 104 deletions(-) diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c index eea30c18fb5c..9ff1315f7358 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/keymap.c @@ -1,4 +1,4 @@ -/* Copyright 2021 Danny Nguyen +/* Copyright 2022 Forrest Cahoon 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 @@ -35,12 +35,14 @@ enum custom_keycodes { PG_RPAR, PG_SLAS, PG_VBAR, + MS_BTN, }; +// clang-format off const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT( // ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ - KC_MUTE, KC_ESC, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + MS_BTN, KC_ESC, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, // ├────────┼───┬────┴────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ MO(_PG), KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, // ├────────┼───┼─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┴────────┤ @@ -48,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // ├────────┼───┴─────────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┴────┬────────┬───┘ TG(_PG), KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(_PG), // ├────────┼───┬──────────┬──┴──────┬─┴────────┼────────┼────────┼────────┤ ├────────┴─┬──────┴──────┬─┴────────┼────────┴─┬─────────┬─┴────────┤ - TG(_MS), KC_LGUI, KC_LCTL, KC_LALT, MO(1), KC_SPC, KC_SPC, KC_SPC, KC_SPC, TG(_MS), KC_RALT, KC_RCTL, KC_RGUI + TG(_MS), KC_LGUI, KC_LCTL, KC_LALT, MO(_PG), KC_SPC, KC_SPC, KC_SPC, KC_SPC, MO(_MS), KC_RALT, KC_RCTL, KC_RGUI // └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ ), [_PG] = LAYOUT( @@ -78,48 +80,47 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // └────────┴───┴──────────┴─────────┴──────────┴────────┴────────┴────────┘ └──────────┴─────────────┴──────────┴──────────┴─────────┴──────────┘ ), }; +// clang-format on -const key_override_t pg_lbrk_none = ko_make_with_layers_and_negmods(0, PG_LBRK, KC_LEFT_CURLY_BRACE, ~0, ~0); +const key_override_t pg_lbrk_none = ko_make_with_layers_and_negmods(0, PG_LBRK, KC_LEFT_CURLY_BRACE, ~0, ~0); const key_override_t pg_lbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LBRK, KC_LEFT_BRACKET, ~0, ~MOD_MASK_SHIFT); -const key_override_t pg_lpar_none = ko_make_with_layers_and_negmods(0, PG_LPAR, KC_LEFT_PAREN, ~0, ~0); +const key_override_t pg_lpar_none = ko_make_with_layers_and_negmods(0, PG_LPAR, KC_LEFT_PAREN, ~0, ~0); const key_override_t pg_lpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_LPAR, KC_LEFT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); -const key_override_t pg_rbrk_none = ko_make_with_layers_and_negmods(0, PG_RBRK, KC_RIGHT_CURLY_BRACE, ~0, ~0); +const key_override_t pg_rbrk_none = ko_make_with_layers_and_negmods(0, PG_RBRK, KC_RIGHT_CURLY_BRACE, ~0, ~0); const key_override_t pg_rbrk_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RBRK, KC_RIGHT_BRACKET, ~0, ~MOD_MASK_SHIFT); -const key_override_t pg_rpar_none = ko_make_with_layers_and_negmods(0, PG_RPAR, KC_RIGHT_PAREN, ~0, ~0); +const key_override_t pg_rpar_none = ko_make_with_layers_and_negmods(0, PG_RPAR, KC_RIGHT_PAREN, ~0, ~0); const key_override_t pg_rpar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_RPAR, KC_RIGHT_ANGLE_BRACKET, ~0, ~MOD_MASK_SHIFT); -const key_override_t pg_slas_none = ko_make_with_layers_and_negmods(0, PG_SLAS, KC_SLASH, ~0, ~0); +const key_override_t pg_slas_none = ko_make_with_layers_and_negmods(0, PG_SLAS, KC_SLASH, ~0, ~0); const key_override_t pg_slas_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_SLAS, KC_BACKSLASH, ~0, ~MOD_MASK_SHIFT); -const key_override_t pg_vbar_none = ko_make_with_layers_and_negmods(0, PG_VBAR, KC_PIPE, ~0, ~0); +const key_override_t pg_vbar_none = ko_make_with_layers_and_negmods(0, PG_VBAR, KC_PIPE, ~0, ~0); const key_override_t pg_vbar_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, PG_VBAR, KC_AMPERSAND, ~0, ~MOD_MASK_SHIFT); +const key_override_t ms_btn_none = ko_make_with_layers_and_negmods(0, MS_BTN, KC_MS_BTN1, ~0, ~0); +const key_override_t ms_btn_shift = ko_make_with_layers_and_negmods(MOD_MASK_SHIFT, MS_BTN, KC_MS_BTN2, ~0, ~MOD_MASK_SHIFT); +// clang-format off const key_override_t **key_overrides = (const key_override_t *[]){ - &pg_lbrk_none, - &pg_lbrk_shift, - &pg_lpar_none, - &pg_lpar_shift, - &pg_rbrk_none, - &pg_rbrk_shift, - &pg_rpar_none, - &pg_rpar_shift, - &pg_slas_none, - &pg_slas_shift, - &pg_vbar_none, - &pg_vbar_shift, - NULL -}; + &pg_lbrk_none, &pg_lbrk_shift, + &pg_lpar_none, &pg_lpar_shift, + &pg_rbrk_none, &pg_rbrk_shift, + &pg_rpar_none, &pg_rpar_shift, + &pg_slas_none, &pg_slas_shift, + &pg_vbar_none, &pg_vbar_shift, + &ms_btn_none, &ms_btn_shift, + NULL}; +// clang-format on bool process_record_user(uint16_t keycode, keyrecord_t *record) { - uint8_t std_mods = get_mods(); + uint8_t std_mods = get_mods(); uint8_t oneshot_mods = get_oneshot_mods(); - uint8_t all_mods = std_mods | oneshot_mods; - bool shift_on = all_mods & MOD_MASK_SHIFT; - bool ctrl_on = all_mods & MOD_MASK_CTRL; + uint8_t all_mods = std_mods | oneshot_mods; + bool shift_on = all_mods & MOD_MASK_SHIFT; + bool ctrl_on = all_mods & MOD_MASK_CTRL; // None of our special keycodes use ALT or GUI mods (so far), so we // check once here at the top and let other code handle it if any of @@ -128,100 +129,110 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case PG_BANG: - if (record->event.pressed) { - clear_mods(); - clear_oneshot_mods(); - if (shift_on) { - if (!ctrl_on) SEND_STRING(" "); - SEND_STRING("*"); - if (!ctrl_on) SEND_STRING(" "); - } else { - if (ctrl_on) SEND_STRING(" "); - SEND_STRING("!"); - if (!ctrl_on) SEND_STRING(" "); + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (shift_on) { + if (!ctrl_on) SEND_STRING(" "); + SEND_STRING("*"); + if (!ctrl_on) SEND_STRING(" "); + } else { + if (ctrl_on) SEND_STRING(" "); + SEND_STRING("!"); + if (!ctrl_on) SEND_STRING(" "); + } + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + return false; } - set_mods(std_mods); - set_oneshot_mods(oneshot_mods); - return false; - } - break; + break; case PG_ENDC: - if (record->event.pressed) { - clear_mods(); - clear_oneshot_mods(); - SEND_STRING(SS_TAP(X_END)); - if (!shift_on) SEND_STRING(";"); - if (!ctrl_on) SEND_STRING(SS_TAP(X_ENTER)); - set_mods(std_mods); - set_oneshot_mods(oneshot_mods); - return false; - } - break; + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + SEND_STRING(SS_TAP(X_END)); + if (!shift_on) SEND_STRING(";"); + if (!ctrl_on) SEND_STRING(SS_TAP(X_ENTER)); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + return false; + } + break; case PG_EQEQ: - if (record->event.pressed) { - clear_mods(); - clear_oneshot_mods(); - if (!ctrl_on) SEND_STRING(" "); - shift_on ? SEND_STRING("==") : SEND_STRING("==="); - if (!ctrl_on) SEND_STRING(" "); - set_mods(std_mods); - set_oneshot_mods(oneshot_mods); - return false; - } - break; + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!ctrl_on) SEND_STRING(" "); + shift_on ? SEND_STRING("==") : SEND_STRING("==="); + if (!ctrl_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + return false; + } + break; case PG_EQL: - if (record->event.pressed) { - clear_mods(); - clear_oneshot_mods(); - if (!ctrl_on) SEND_STRING(" "); - shift_on ? SEND_STRING("+") : SEND_STRING("="); - if (!ctrl_on) SEND_STRING(" "); - set_mods(std_mods); - set_oneshot_mods(oneshot_mods); - return false; - } - break; - case PG_MINS: - if (record->event.pressed) { - clear_mods(); - clear_oneshot_mods(); - if (shift_on) { - if (ctrl_on) SEND_STRING(" "); - SEND_STRING("_"); - if (ctrl_on) SEND_STRING(" "); - } else { + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); if (!ctrl_on) SEND_STRING(" "); - SEND_STRING("-"); + shift_on ? SEND_STRING("+") : SEND_STRING("="); if (!ctrl_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + return false; } - set_mods(std_mods); - set_oneshot_mods(oneshot_mods); - return false; - } - break; + break; + case PG_MINS: + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (shift_on) { + if (ctrl_on) SEND_STRING(" "); + SEND_STRING("_"); + if (ctrl_on) SEND_STRING(" "); + } else { + if (!ctrl_on) SEND_STRING(" "); + SEND_STRING("-"); + if (!ctrl_on) SEND_STRING(" "); + } + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + return false; + } + break; case PG_NEEQ: - if (record->event.pressed) { - clear_mods(); - clear_oneshot_mods(); - if (!ctrl_on) SEND_STRING(" "); - shift_on ? SEND_STRING("!=") : SEND_STRING("!=="); - if (!ctrl_on) SEND_STRING(" "); - set_mods(std_mods); - set_oneshot_mods(oneshot_mods); - return false; - } - break; + if (record->event.pressed) { + clear_mods(); + clear_oneshot_mods(); + if (!ctrl_on) SEND_STRING(" "); + shift_on ? SEND_STRING("!=") : SEND_STRING("!=="); + if (!ctrl_on) SEND_STRING(" "); + set_mods(std_mods); + set_oneshot_mods(oneshot_mods); + return false; + } + break; } return true; } +// I have only one encoder on my FoldKB and I want it to always be a scroll wheel. +bool encoder_update_user(uint8_t index, bool clockwise) { + if (clockwise) { + tap_code(KC_MS_WH_DOWN); + } else { + tap_code(KC_MS_WH_UP); + } + return false; +} + layer_state_t layer_state_set_user(layer_state_t state) { switch (get_highest_layer(state)) { case _MS: - backlight_level(3); + backlight_level(2); break; case _PG: - backlight_level(2); + backlight_level(3); break; default: backlight_level(1); diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk b/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk index 5ac74d5320e7..959e42866154 100644 --- a/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/rules.mk @@ -1,2 +1,3 @@ KEY_OVERRIDE_ENABLE = yes MOUSEKEY_ENABLE = yes +ENCODER_ENABLE = yes From a07ac583df70bcdb05d387129f3e78f5058a9072 Mon Sep 17 00:00:00 2001 From: Forrest Cahoon Date: Sat, 11 Jun 2022 22:44:21 -0500 Subject: [PATCH 7/7] add readme.md for my foldkb layout --- .../keebio/foldkb/keymaps/forrcaho/readme.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 keyboards/keebio/foldkb/keymaps/forrcaho/readme.md diff --git a/keyboards/keebio/foldkb/keymaps/forrcaho/readme.md b/keyboards/keebio/foldkb/keymaps/forrcaho/readme.md new file mode 100644 index 000000000000..74ac4507b862 --- /dev/null +++ b/keyboards/keebio/foldkb/keymaps/forrcaho/readme.md @@ -0,0 +1,23 @@ +# Keebio FoldKB rev1 + +My layout for the FoldKB has three layers: + +* A default standard QWERTY layer, + +* a second "programming" layer with + * function keys for the corresponding numbers + * arrow and other navigation keys (such as home) on the right half, and + * various alternate keymappings and macros useful for programming on the + left half. + +* a third "mouse" layer with mouse keys on the right half. No special functions +have been added to the left half for this layer (yet). + +This was written for a FoldKB with one encoder, and that is made to function as +a mouse scroll wheel on all layers. Pressing it is a mouse left click and +shift-pressing it is a mouse right click. (Presumably both encoders would do the +same thing on a FoldKB with two.) + +The backgound lighting levels indicate the layer: dimmest for the default +QWERTY layer, middle brightness for the mouse layer, and brightest for the +programming layer.