keymap.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include QMK_KEYBOARD_H
  15. // clang-format off
  16. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  17. [_QW] = LAYOUT_ortho_5x13(
  18. KC_ESC, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_BSPC ,
  19. 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 ,
  20. KC_NUHS, KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, KC_ENT ,
  21. SC_LSPO, KC_NUBS, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_UP , KC_SLSH ,
  22. KC_LCTL, KC_LGUI, TT(_LWR), KC_LALT, TT(_RSE), KC_SPC, KC_SPC, KC_SPC, KC_RALT, SC_RSPC, KC_LEFT, KC_DOWN, KC_RGHT),
  23. [_LWR] = LAYOUT_ortho_5x13(
  24. KC_GRV , KC_MUTE, KC_VOLU, KC_VOLD, KC_MPRV, KC_MPLY, KC_MNXT, G(KC_P), KC_SLEP, KC_WAKE, KC_PSCR, KC_DEL , KC_EQL ,
  25. KC_BTN3, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  26. KC_BTN2, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  27. _______, KC_BTN1, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_U, _______ ,
  28. _______, KC_BTN4, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R),
  29. [_RSE] = LAYOUT_ortho_5x13(
  30. KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 ,
  31. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  32. KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  33. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_WH_U, _______ ,
  34. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_R),
  35. [_ADJ] = LAYOUT_ortho_5x13(
  36. RGB_MOD, RGB_RMOD, A(KC_F2), _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_T , RGB_M_SW,
  37. RGB_HUI, RGB_HUD , RGB_M_P , _______, QK_BOOT , _______, _______, _______, _______, _______, _______, _______ , RGB_M_SN,
  38. RGB_SAI, RGB_SAD , RGB_M_B , _______, _______, _______, _______, _______, _______, _______, _______, _______ , RGB_M_K ,
  39. RGB_VAI, RGB_VAD , RGB_M_R , _______, _______, _______, _______, _______, _______, _______, _______, _______ , RGB_M_X ,
  40. RGB_TOG, _______ , _______ , _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_TW, RGB_M_G),
  41. };
  42. // clang-format on
  43. bool led_update_user(led_t led_state) {
  44. // Disable the default LED update code, so that lock LEDs could be reused to show layer status.
  45. return false;
  46. }
  47. void matrix_scan_user(void) {
  48. toggle_leds();
  49. }
  50. bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  51. switch (keycode) {
  52. case (TT(_LWR)):
  53. if (!record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
  54. // This runs before the TT() handler toggles the layer state, so the current layer state is the opposite of the final one after toggle.
  55. set_led_toggle(_LWR, !layer_state_is(_LWR));
  56. }
  57. return true;
  58. break;
  59. case (TT(_RSE)):
  60. if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
  61. set_led_toggle(_RSE, !layer_state_is(_RSE));
  62. }
  63. return true;
  64. break;
  65. default:
  66. return true;
  67. }
  68. }
  69. layer_state_t layer_state_set_user(layer_state_t state) {
  70. #ifdef RGBLIGHT_ENABLE
  71. set_rgb_layers(state);
  72. #endif
  73. return update_tri_layer_state(state, _LWR, _RSE, _ADJ);
  74. }
  75. #ifdef RGBLIGHT_ENABLE
  76. layer_state_t default_layer_state_set_user(layer_state_t state) {
  77. set_default_rgb_layers(state);
  78. return state;
  79. }
  80. #endif
  81. void keyboard_post_init_user(void) {
  82. #ifdef RGBLIGHT_ENABLE
  83. // Enable the LED layers
  84. rgblight_layers = my_rgb();
  85. #endif
  86. #ifdef OLED_ENABLE
  87. init_timer();
  88. #endif
  89. }