keymap.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Copyright 2021 Danny Nguyen <danny@keeb.io>
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. #include QMK_KEYBOARD_H
  14. enum custom_layer {
  15. _QWERTY,
  16. _LOWER,
  17. _RAISE,
  18. _ADJUST,
  19. };
  20. enum custom_keycodes {
  21. LOWER = SAFE_RANGE,
  22. RAISE,
  23. ADJUST,
  24. };
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* Default Layer
  27. * ,-----------------------------------------------------------.
  28. * | Esc| Q | W | E | R | T | Y | U | I | O | P | BS |
  29. * |-----------------------------------------------------------|
  30. * | Tab | A | S | D | F | G | H | J | K | L | Ent |
  31. * |-----------------------------------------------------------|
  32. * | LSft | Z | X | C | V | B | N | M | , | . | /? |
  33. * |-----------------------------------------------------------|
  34. * | LCtl | LGui| LAlt| spc fn0 | spc fn1 |fn2|RAlt|RCtl |
  35. * `-----------------------------------------------------------'
  36. */
  37. [_QWERTY] = LAYOUT(
  38. KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  39. KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_ENT,
  40. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH,
  41. KC_LCTL, KC_LGUI, KC_LALT, LT(_LOWER, KC_SPC), LT(_RAISE, KC_SPC), LT(_ADJUST, KC_LGUI), KC_RALT, KC_RCTL
  42. ),
  43. [_LOWER] = LAYOUT(
  44. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
  45. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
  46. KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),BL_TOGG, BL_UP, BL_DOWN,
  47. _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
  48. ),
  49. [_RAISE] = LAYOUT(
  50. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
  51. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
  52. KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, KC_DEL,
  53. _______, KC_TRNS, _______, KC_TRNS, KC_TRNS, _______, _______, UG_TOGG
  54. ),
  55. [_ADJUST] = LAYOUT(
  56. _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL,
  57. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, _______, _______, _______, _______,
  58. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  59. _______, _______, _______, _______, _______, _______, _______, _______
  60. )
  61. };
  62. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  63. switch (keycode) {
  64. case LOWER:
  65. if (record->event.pressed) {
  66. layer_on(_LOWER);
  67. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  68. } else {
  69. layer_off(_LOWER);
  70. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  71. }
  72. return false;
  73. break;
  74. case RAISE:
  75. if (record->event.pressed) {
  76. layer_on(_RAISE);
  77. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  78. } else {
  79. layer_off(_RAISE);
  80. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  81. }
  82. return false;
  83. break;
  84. case ADJUST:
  85. if (record->event.pressed) {
  86. layer_on(_ADJUST);
  87. } else {
  88. layer_off(_ADJUST);
  89. }
  90. return false;
  91. break;
  92. }
  93. return true;
  94. }
  95. bool encoder_update_user(uint8_t index, bool clockwise) {
  96. if (index == 0) {
  97. if (clockwise) {
  98. tap_code(KC_VOLU);
  99. } else {
  100. tap_code(KC_VOLD);
  101. }
  102. }
  103. return false;
  104. }