You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.9 KiB

  1. /* Copyright 2019 Thomas Baart <thomas@splitkb.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include QMK_KEYBOARD_H
  17. #include "keycodes.h"
  18. #ifdef ENCODER_ENABLE
  19. # include "encoder_utils.h"
  20. #endif
  21. #ifdef OLED_ENABLE
  22. # include "oled_utils.h"
  23. #endif
  24. #ifdef THUMBSTICK_ENABLE
  25. # include "thumbstick.h"
  26. #endif
  27. // clang-format off
  28. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  29. /*
  30. * Base Layer: QWERTY
  31. */
  32. [_QWERTY] = LAYOUT(
  33. ESC_RAISE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, BSLS_RAISE,
  34. KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, SFT_QUOT,
  35. KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LGUI, KC_NO, TMB_MODE, KC_NO, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, CTL_MINS,
  36. ENC_MODE_L, KC_LALT, LT(_LOWER, KC_SPC), LT(_RAISE, KC_TAB), KC_LSFT, KC_EQL, LT(_RAISE, KC_ENT), LT(_LOWER, KC_BSPC), KC_DEL, ENC_MODE_R
  37. ),
  38. /*
  39. * Lower Layer: Symbols, Navigation
  40. */
  41. [_LOWER] = LAYOUT(
  42. _______, KC_HASH, KC_DLR, KC_LCBR, KC_RCBR, KC_PIPE, _______, _______, _______, _______, _______, KC_PIPE,
  43. _______, KC_EXLM, KC_AT, KC_LPRN, KC_RPRN, KC_GRV, KC_PGUP, KC_LEFT, KC_UP, KC_RGHT, _______, KC_QUOT,
  44. _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, _______, _______, _______, _______, KC_PGDN, KC_HOME, KC_DOWN, KC_END, _______, KC_MINS,
  45. _______, _______, _______, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, _______, _______, _______
  46. ),
  47. /*
  48. * Raise Layer: Number keys, media, more symbols
  49. */
  50. [_RAISE] = LAYOUT(
  51. _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
  52. _______, _______, KC_MPRV, KC_MPLY, KC_MNXT, KC_VOLU, KC_MINS, KC_PLUS, KC_ASTR, KC_SLSH, KC_PERC, _______,
  53. _______, _______, _______, _______, KC_MUTE, KC_VOLD, _______, _______, _______, _______, KC_AMPR, KC_PIPE, KC_COMM, KC_DOT, KC_SLSH, _______,
  54. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  55. ),
  56. /*
  57. * Adjust Layer: Function keys, RGB
  58. */
  59. [_ADJUST] = LAYOUT(
  60. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______,
  61. _______, RGB_TOG, RGB_SAI, RGB_HUI, RGB_VAI, RGB_MOD, _______, _______, _______, KC_F11, KC_F12, _______,
  62. _______, _______, RGB_SAD, RGB_HUD, RGB_VAD, RGB_RMOD,_______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  63. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  64. ),
  65. };
  66. // clang-format on
  67. void matrix_init_user(void) {
  68. #ifdef ENCODER_ENABLE
  69. encoder_utils_init();
  70. #endif
  71. }
  72. layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); }
  73. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  74. switch (keycode) {
  75. #ifdef ENCODER_ENABLE
  76. case ENC_MODE_L:
  77. if (record->event.pressed) {
  78. cycle_encoder_mode(true, false);
  79. }
  80. break;
  81. case ENC_MODE_R:
  82. if (record->event.pressed) {
  83. cycle_encoder_mode(false, false);
  84. }
  85. break;
  86. #endif
  87. #ifdef THUMBSTICK_ENABLE
  88. case TMB_MODE:
  89. if (record->event.pressed) {
  90. thumbstick_mode_cycle(false);
  91. }
  92. #endif
  93. }
  94. return true;
  95. }
  96. #ifdef OLED_ENABLE
  97. oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_180; }
  98. void oled_task_user(void) { render_status(); }
  99. #endif
  100. #ifdef ENCODER_ENABLE
  101. bool encoder_update_user(uint8_t index, bool clockwise) {
  102. if (index == 0) {
  103. encoder_action(get_encoder_mode(true), clockwise);
  104. # ifdef OLED_ENABLE
  105. oled_on();
  106. # endif
  107. } else if (index == 1) {
  108. encoder_action(get_encoder_mode(false), clockwise);
  109. # ifdef OLED_ENABLE
  110. oled_on();
  111. # endif
  112. }
  113. return true;
  114. }
  115. #endif