diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2024-04-10 18:37:03 -0400 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2024-04-10 18:37:03 -0400 |
commit | 5c09bd69b68264f787282f321817e1dffc45d758 (patch) | |
tree | 01e19f5eb49d7afb90e68638c9959e16903e4d44 | |
parent | 629179454b6524cf4f76171f5148c6e3fdbdedf5 (diff) |
Refactor orbekk keymap
-rw-r--r-- | keyboards/planck/keymaps/orbekk/keymap.c | 200 | ||||
-rw-r--r-- | keyboards/planck/keymaps/orbekk/layout.h | 31 | ||||
-rw-r--r-- | keyboards/planck/keymaps/orbekk/rules.mk | 4 | ||||
-rw-r--r-- | users/orbekk/achordion.c (renamed from keyboards/planck/keymaps/orbekk/features/achordion.c) | 0 | ||||
-rw-r--r-- | users/orbekk/achordion.h (renamed from keyboards/planck/keymaps/orbekk/features/achordion.h) | 0 | ||||
-rw-r--r-- | users/orbekk/custom_shift_keys.c (renamed from keyboards/planck/keymaps/orbekk/features/custom_shift_keys.c) | 0 | ||||
-rw-r--r-- | users/orbekk/custom_shift_keys.h (renamed from keyboards/planck/keymaps/orbekk/features/custom_shift_keys.h) | 0 | ||||
-rw-r--r-- | users/orbekk/orbekk.c | 200 | ||||
-rw-r--r-- | users/orbekk/rules.mk | 6 |
9 files changed, 206 insertions, 235 deletions
diff --git a/keyboards/planck/keymaps/orbekk/keymap.c b/keyboards/planck/keymaps/orbekk/keymap.c index 8ea9a57fb8..e69de29bb2 100644 --- a/keyboards/planck/keymaps/orbekk/keymap.c +++ b/keyboards/planck/keymaps/orbekk/keymap.c @@ -1,200 +0,0 @@ -#include QMK_KEYBOARD_H -#include "features/custom_shift_keys.h" -#include "features/achordion.h" - -// Based on: -// https://github.com/getreuer/qmk-keymap/blob/main/keymap.c - -enum layers { - GR, // Graphite - DV, // Dvorak - QW, // Qwerty (intended for typing in dvorak mode) - GAMING, - LOW, - RAISE, - NAV, - FN, - GAMELOW, -}; - -#define HL_1(kc) LGUI_T(kc) -#define HL_2(kc) LALT_T(kc) -#define HL_3(kc) LCTL_T(kc) -#define HL_4(kc) LSFT_T(kc) -#define HR_1(kc) LGUI_T(kc) -#define HR_2(kc) LALT_T(kc) -#define HR_3(kc) LCTL_T(kc) -#define HR_4(kc) LSFT_T(kc) - -const uint16_t PROGMEM combo_z[] = {KC_X, KC_M, COMBO_END}; -combo_t key_combos[] = { - COMBO(combo_z, KC_Z), -}; - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [GR] = LAYOUT_LR( - KC_B, KC_L, KC_D, KC_W, KC_COMMA, - HL_1(KC_N), HL_2(KC_R), HL_3(KC_T), HL_4(KC_S), KC_G, - KC_Q, KC_X, KC_M, KC_C, KC_V, - TL_LOWR, LT(NAV, KC_SPC), - - KC_QUOT, KC_F, KC_O, KC_U, KC_J, - KC_Y, HR_4(KC_H), HR_3(KC_A), HR_2(KC_E), HR_1(KC_I), - KC_K, KC_P, KC_DOT, KC_MINUS, KC_SLASH, - KC_LSFT, TL_UPPR - ), - - [DV] = LAYOUT_LR( - KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, - HL_1(KC_A), HL_2(KC_O), HL_3(KC_E), HL_4(KC_U), KC_I, - KC_SCLN, KC_Q, KC_J, KC_K, KC_X, - KC_TRNS, KC_TRNS, - - KC_F, KC_G, KC_C, KC_R, KC_L, - KC_D, HR_4(KC_H), HR_3(KC_T), HR_2(KC_N), HR_1(KC_S), - KC_B, KC_M, KC_W, KC_V, KC_Z, - KC_TRNS, KC_TRNS - ), - - [QW] = LAYOUT_LR( - KC_Q, KC_W, KC_E, KC_R, KC_T, - HL_1(KC_A), HL_2(KC_S), HL_3(KC_D), HL_4(KC_F), KC_G, - KC_Z, KC_X, KC_C, KC_V, KC_B, - KC_TRNS, KC_TRNS, - - KC_Y, KC_U, KC_I, KC_O, KC_P, - KC_H, HR_4(KC_J), HR_3(KC_K), HR_2(KC_L), HR_1(KC_SCLN), - KC_N, KC_M, KC_COMMA, KC_DOT, KC_SLASH, - KC_TRNS, KC_TRNS - ), - - [GAMING] = LAYOUT_LR( - KC_TAB, KC_Q, KC_W, KC_E, KC_R, - KC_LCTL, KC_A, KC_S, KC_D, KC_F, - KC_LSFT, KC_LALT, KC_X, KC_C, KC_V, - MO(GAMELOW), KC_SPC, - - KC_Y, KC_U, KC_I, KC_O, KC_P, - KC_H, KC_J, KC_K, KC_L, KC_SCLN, - KC_N, KC_M, KC_COMMA, KC_DOT, KC_SLASH, - KC_TRNS, TO(GR) - ), - - [LOW] = LAYOUT_LR( - KC_EXLM, KC_AT, KC_HASH, KC_DOLLAR, KC_PERCENT, - KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, KC_BACKSLASH, - KC_GRAVE, KC_TILDE, KC_TAB, KC_ESC, KC_PIPE, - KC_TRNS, KC_TRNS, - - KC_CIRC, KC_AMPERSAND, KC_ASTERISK, KC_LPRN, KC_RPRN, - KC_SLASH, KC_UNDERSCORE, KC_PLUS, KC_LCBR, KC_RCBR, - KC_QUESTION, KC_MINUS, KC_EQUAL, KC_LBRC, KC_RBRC, - KC_TRNS, KC_TRNS - ), - - [RAISE] = LAYOUT_LR( - KC_1, KC_2, KC_3, KC_4, KC_5, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, - - KC_6, KC_7, KC_8, KC_9, KC_0, - KC_BSPC, KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, - KC_DEL, KC_ENTER, KC_COMMA, KC_SEMICOLON, KC_COLON, - KC_TRNS, KC_TRNS - ), - - [FN] = LAYOUT_LR( - KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, - KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, - - KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, - KC_TRNS, TO(GR), TO(DV), TO(QW), TO(GAMING), - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, QK_BOOT, - KC_TRNS, KC_TRNS - ), - - [NAV] = LAYOUT_LR( - KC_BTN4, KC_BTN3, KC_UP, KC_BTN1, KC_BTN2, - KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT, KC_PGUP, - KC_HOME, KC_WH_D, KC_WH_U, KC_END, KC_PGDN, - KC_TRNS, KC_TRNS, - - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS - ), - - [GAMELOW] = LAYOUT_LR( - KC_ESC, KC_7, KC_8, KC_9, KC_TRNS, - KC_TRNS, KC_4, KC_5, KC_6, KC_TRNS, - KC_TRNS, KC_1, KC_2, KC_3, KC_0, - KC_TRNS, KC_TRNS, - - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS - ), - -}; - -const custom_shift_key_t custom_shift_keys[] = { - {KC_DOT , KC_GT}, - {KC_SLASH, KC_LT}, - {KC_MINS, KC_DOUBLE_QUOTE}, - {KC_QUOTE, KC_UNDERSCORE}, - {KC_COMMA, KC_QUESTION}, -}; -uint8_t NUM_CUSTOM_SHIFT_KEYS = - sizeof(custom_shift_keys) / sizeof(custom_shift_key_t); - -bool process_record_user(uint16_t keycode, keyrecord_t* record) { - if (!process_achordion(keycode, record)) { return false; } - - const bool use_custom_shift = !IS_LAYER_ON(DV) && - !IS_LAYER_ON(QW) && !IS_LAYER_ON(GAMING); - if (use_custom_shift && - !process_custom_shift_keys(keycode, record)) { - return false; - } - - return true; -} - -void matrix_scan_user(void) { - achordion_task(); -} - -bool achordion_chord(uint16_t tap_hold_keycode, - keyrecord_t* tap_hold_record, - uint16_t other_keycode, - keyrecord_t* other_record) { - // Also allow same-hand holds when the other key is in the rows below the - // alphas. I need the `% (MATRIX_ROWS / 2)` because my keyboard is split. - if (other_record->event.key.row % (MATRIX_ROWS / 2) >= 2) { return true; } - if (tap_hold_record->event.key.row % (MATRIX_ROWS / 2) >= 2) { return true; } - - // Otherwise, follow the opposite hands rule. - return achordion_opposite_hands(tap_hold_record, other_record); -} - -bool achordion_eager_mod(uint8_t mod) { - switch (mod) { - case MOD_LSFT: - case MOD_RSFT: - case MOD_LCTL: - case MOD_RCTL: - case MOD_LALT: - case MOD_RALT: - case MOD_LGUI: - case MOD_RGUI: - return true; // Eagerly apply mods. - - default: - return false; - } -} diff --git a/keyboards/planck/keymaps/orbekk/layout.h b/keyboards/planck/keymaps/orbekk/layout.h deleted file mode 100644 index b835e4570c..0000000000 --- a/keyboards/planck/keymaps/orbekk/layout.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include QMK_KEYBOARD_H - -#define LAYOUT_ortho_4x12(k0A, k0B, k0C, k0D, k0E, k0F, k4A, k4B, k4C, k4D, k4E, k4F, k1A, k1B, k1C, k1D, k1E, k1F, k5A, k5B, k5C, k5D, k5E, k5F, k2A, k2B, k2C, k2D, k2E, k2F, k6A, k6B, k6C, k6D, k6E, k6F, k3A, k3B, k3C, k7D, k7E, k7F, k7A, k7B, k7C, k3D, k3E, k3F) { \ - {k0A, k0B, k0C, k0D, k0E, k0F}, \ - {k1A, k1B, k1C, k1D, k1E, k1F}, \ - {k2A, k2B, k2C, k2D, k2E, k2F}, \ - {k3A, k3B, k3C, k3D, k3E, k3F}, \ - {k4A, k4B, k4C, k4D, k4E, k4F}, \ - {k5A, k5B, k5C, k5D, k5E, k5F}, \ - {k6A, k6B, k6C, k6D, k6E, k6F}, \ - {k7A, k7B, k7C, k7D, k7E, k7F} \ -} - - -#define LAYOUT_LR( \ -LA0, LA1, LA2, LA3, LA4, \ -LB0, LB1, LB2, LB3, LB4, \ -LC0, LC1, LC2, LC3, LC4, \ -LT0, LT1, \ -RA0, RA1, RA2, RA3, RA4, \ -RB0, RB1, RB2, RB3, RB4, \ -RC0, RC1, RC2, RC3, RC4, \ -RT0, RT1 \ -) LAYOUT_planck_grid( \ -LA0, LA1, LA2, LA3, LA4, KC_NO, KC_NO, RA0, RA1, RA2, RA3, RA4, \ -LB0, LB1, LB2, LB3, LB4, KC_NO, KC_NO, RB0, RB1, RB2, RB3, RB4, \ -LC0, LC1, LC2, LC3, LC4, KC_NO, KC_NO, RC0, RC1, RC2, RC3, RC4, \ -KC_NO, KC_NO, KC_NO, LT0, LT1, KC_NO, KC_NO, RT0, RT1, KC_NO, KC_NO, KC_NO \ -) diff --git a/keyboards/planck/keymaps/orbekk/rules.mk b/keyboards/planck/keymaps/orbekk/rules.mk deleted file mode 100644 index 85e3e779db..0000000000 --- a/keyboards/planck/keymaps/orbekk/rules.mk +++ /dev/null @@ -1,4 +0,0 @@ -TRI_LAYER_ENABLE = yes -COMBO_ENABLE = yes -SRC += features/custom_shift_keys.c -SRC += features/achordion.c diff --git a/keyboards/planck/keymaps/orbekk/features/achordion.c b/users/orbekk/achordion.c index 97bc9beacb..97bc9beacb 100644 --- a/keyboards/planck/keymaps/orbekk/features/achordion.c +++ b/users/orbekk/achordion.c diff --git a/keyboards/planck/keymaps/orbekk/features/achordion.h b/users/orbekk/achordion.h index dfa8dc232c..dfa8dc232c 100644 --- a/keyboards/planck/keymaps/orbekk/features/achordion.h +++ b/users/orbekk/achordion.h diff --git a/keyboards/planck/keymaps/orbekk/features/custom_shift_keys.c b/users/orbekk/custom_shift_keys.c index cb371ae339..cb371ae339 100644 --- a/keyboards/planck/keymaps/orbekk/features/custom_shift_keys.c +++ b/users/orbekk/custom_shift_keys.c diff --git a/keyboards/planck/keymaps/orbekk/features/custom_shift_keys.h b/users/orbekk/custom_shift_keys.h index d6cb7a9fdd..d6cb7a9fdd 100644 --- a/keyboards/planck/keymaps/orbekk/features/custom_shift_keys.h +++ b/users/orbekk/custom_shift_keys.h diff --git a/users/orbekk/orbekk.c b/users/orbekk/orbekk.c new file mode 100644 index 0000000000..4cbeb92347 --- /dev/null +++ b/users/orbekk/orbekk.c @@ -0,0 +1,200 @@ +#include QMK_KEYBOARD_H +#include "custom_shift_keys.h" +#include "achordion.h" + +// Based on: +// https://github.com/getreuer/qmk-keymap/blob/main/keymap.c + +enum layers { + GR, // Graphite + DV, // Dvorak + QW, // Qwerty (intended for typing in dvorak mode) + GAMING, + LOW, + RAISE, + NAV, + FN, + GAMELOW, +}; + +#define HL_1(kc) LGUI_T(kc) +#define HL_2(kc) LALT_T(kc) +#define HL_3(kc) LCTL_T(kc) +#define HL_4(kc) LSFT_T(kc) +#define HR_1(kc) LGUI_T(kc) +#define HR_2(kc) LALT_T(kc) +#define HR_3(kc) LCTL_T(kc) +#define HR_4(kc) LSFT_T(kc) + +const uint16_t PROGMEM combo_z[] = {KC_X, KC_M, COMBO_END}; +combo_t key_combos[] = { + COMBO(combo_z, KC_Z), +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [GR] = LAYOUT_LR( + KC_B, KC_L, KC_D, KC_W, KC_COMMA, + HL_1(KC_N), HL_2(KC_R), HL_3(KC_T), HL_4(KC_S), KC_G, + KC_Q, KC_X, KC_M, KC_C, KC_V, + TL_LOWR, LT(NAV, KC_SPC), + + KC_QUOT, KC_F, KC_O, KC_U, KC_J, + KC_Y, HR_4(KC_H), HR_3(KC_A), HR_2(KC_E), HR_1(KC_I), + KC_K, KC_P, KC_DOT, KC_MINUS, KC_SLASH, + KC_LSFT, TL_UPPR + ), + + [DV] = LAYOUT_LR( + KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, + HL_1(KC_A), HL_2(KC_O), HL_3(KC_E), HL_4(KC_U), KC_I, + KC_SCLN, KC_Q, KC_J, KC_K, KC_X, + KC_TRNS, KC_TRNS, + + KC_F, KC_G, KC_C, KC_R, KC_L, + KC_D, HR_4(KC_H), HR_3(KC_T), HR_2(KC_N), HR_1(KC_S), + KC_B, KC_M, KC_W, KC_V, KC_Z, + KC_TRNS, KC_TRNS + ), + + [QW] = LAYOUT_LR( + KC_Q, KC_W, KC_E, KC_R, KC_T, + HL_1(KC_A), HL_2(KC_S), HL_3(KC_D), HL_4(KC_F), KC_G, + KC_Z, KC_X, KC_C, KC_V, KC_B, + KC_TRNS, KC_TRNS, + + KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_H, HR_4(KC_J), HR_3(KC_K), HR_2(KC_L), HR_1(KC_SCLN), + KC_N, KC_M, KC_COMMA, KC_DOT, KC_SLASH, + KC_TRNS, KC_TRNS + ), + + [GAMING] = LAYOUT_LR( + KC_TAB, KC_Q, KC_W, KC_E, KC_R, + KC_LCTL, KC_A, KC_S, KC_D, KC_F, + KC_LSFT, KC_LALT, KC_X, KC_C, KC_V, + MO(GAMELOW), KC_SPC, + + KC_Y, KC_U, KC_I, KC_O, KC_P, + KC_H, KC_J, KC_K, KC_L, KC_SCLN, + KC_N, KC_M, KC_COMMA, KC_DOT, KC_SLASH, + KC_TRNS, TO(GR) + ), + + [LOW] = LAYOUT_LR( + KC_EXLM, KC_AT, KC_HASH, KC_DOLLAR, KC_PERCENT, + KC_LGUI, KC_LALT, KC_LCTL, KC_LSFT, KC_BACKSLASH, + KC_GRAVE, KC_TILDE, KC_TAB, KC_ESC, KC_PIPE, + KC_TRNS, KC_TRNS, + + KC_CIRC, KC_AMPERSAND, KC_ASTERISK, KC_LPRN, KC_RPRN, + KC_SLASH, KC_UNDERSCORE, KC_PLUS, KC_LCBR, KC_RCBR, + KC_QUESTION, KC_MINUS, KC_EQUAL, KC_LBRC, KC_RBRC, + KC_TRNS, KC_TRNS + ), + + [RAISE] = LAYOUT_LR( + KC_1, KC_2, KC_3, KC_4, KC_5, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + + KC_6, KC_7, KC_8, KC_9, KC_0, + KC_BSPC, KC_LSFT, KC_LCTL, KC_LALT, KC_LGUI, + KC_DEL, KC_ENTER, KC_COMMA, KC_SEMICOLON, KC_COLON, + KC_TRNS, KC_TRNS + ), + + [FN] = LAYOUT_LR( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, + KC_TRNS, TO(GR), TO(DV), TO(QW), TO(GAMING), + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, QK_BOOT, + KC_TRNS, KC_TRNS + ), + + [NAV] = LAYOUT_LR( + KC_BTN4, KC_BTN3, KC_UP, KC_BTN1, KC_BTN2, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT, KC_PGUP, + KC_HOME, KC_WH_D, KC_WH_U, KC_END, KC_PGDN, + KC_TRNS, KC_TRNS, + + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS + ), + + [GAMELOW] = LAYOUT_LR( + KC_ESC, KC_7, KC_8, KC_9, KC_TRNS, + KC_TRNS, KC_4, KC_5, KC_6, KC_TRNS, + KC_TRNS, KC_1, KC_2, KC_3, KC_0, + KC_TRNS, KC_TRNS, + + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS + ), + +}; + +const custom_shift_key_t custom_shift_keys[] = { + {KC_DOT , KC_GT}, + {KC_SLASH, KC_LT}, + {KC_MINS, KC_DOUBLE_QUOTE}, + {KC_QUOTE, KC_UNDERSCORE}, + {KC_COMMA, KC_QUESTION}, +}; +uint8_t NUM_CUSTOM_SHIFT_KEYS = + sizeof(custom_shift_keys) / sizeof(custom_shift_key_t); + +bool process_record_user(uint16_t keycode, keyrecord_t* record) { + if (!process_achordion(keycode, record)) { return false; } + + const bool use_custom_shift = !IS_LAYER_ON(DV) && + !IS_LAYER_ON(QW) && !IS_LAYER_ON(GAMING); + if (use_custom_shift && + !process_custom_shift_keys(keycode, record)) { + return false; + } + + return true; +} + +void matrix_scan_user(void) { + achordion_task(); +} + +bool achordion_chord(uint16_t tap_hold_keycode, + keyrecord_t* tap_hold_record, + uint16_t other_keycode, + keyrecord_t* other_record) { + // Also allow same-hand holds when the other key is in the rows below the + // alphas. I need the `% (MATRIX_ROWS / 2)` because my keyboard is split. + if (other_record->event.key.row % (MATRIX_ROWS / 2) >= 2) { return true; } + if (tap_hold_record->event.key.row % (MATRIX_ROWS / 2) >= 2) { return true; } + + // Otherwise, follow the opposite hands rule. + return achordion_opposite_hands(tap_hold_record, other_record); +} + +bool achordion_eager_mod(uint8_t mod) { + switch (mod) { + case MOD_LSFT: + case MOD_RSFT: + case MOD_LCTL: + case MOD_RCTL: + case MOD_LALT: + case MOD_RALT: + case MOD_LGUI: + case MOD_RGUI: + return true; // Eagerly apply mods. + + default: + return false; + } +} diff --git a/users/orbekk/rules.mk b/users/orbekk/rules.mk new file mode 100644 index 0000000000..d1591ebfb7 --- /dev/null +++ b/users/orbekk/rules.mk @@ -0,0 +1,6 @@ +TRI_LAYER_ENABLE = yes +COMBO_ENABLE = yes +MOUSEKEY_ENABLE = yes +INTROSPECTION_KEYMAP_C = orbekk.c +SRC += custom_shift_keys.c +SRC += achordion.c |