keymap.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /** @file keymap.c
  2. * @brief keymao.c that includes key layout and keylogs functions
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * @author Mario Corona (mariocc@comunidad.unam.mx) 2021
  18. *
  19. */
  20. #include "mcrown.h"
  21. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  22. [_QWERTY] = LAYOUT_wrapper(
  23. /*,-------------------------------------------------|-----|--------------------------------------------------------|.*/
  24. _____________________QWERTY_L1______________________, _____________________QWERTY_R1______________________,
  25. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  26. _____________________QWERTY_L2______________________, _____________________QWERTY_R2______________________,
  27. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  28. _____________________QWERTY_L3______________________, _____________________QWERTY_R3______________________,
  29. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  30. _____________MOD_LEFT_____________, _____________MOD_RIGHT____________
  31. /*|-----------------------------------| |----------------------------------|*/
  32. ),
  33. [_LOWER] = LAYOUT_wrapper(
  34. /*,-------------------------------------------------|-----|--------------------------------------------------------|.*/
  35. _____________________LOWER_L1_______________________, _____________________LOWER_R1_______________________,
  36. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  37. _____________________LOWER_L2_______________________, _____________________LOWER_R2_______________________,
  38. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  39. _____________________LOWER_L3_______________________, _____________________LOWER_R3_______________________,
  40. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  41. _____________MOD_LEFT_____________, _____________MOD_RIGHT____________
  42. /*|-----------------------------------| |----------------------------------|*/
  43. ),
  44. [_RAISE] = LAYOUT_wrapper(
  45. /*,-------------------------------------------------|-----|--------------------------------------------------------|.*/
  46. _____________________RAISE_L1_______________________, _____________________RAISE_R1_______________________,
  47. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  48. _____________________RAISE_L2_______________________, _____________________RAISE_R2_______________________,
  49. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  50. _____________________RAISE_L3_______________________, _____________________RAISE_R3_______________________,
  51. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  52. _____________MOD_LEFT_____________, _____________MOD_RIGHT____________
  53. /*|-----------------------------------| |----------------------------------|*/
  54. ),
  55. [_ADJUST] = LAYOUT_wrapper(
  56. /*,-------------------------------------------------|-----|--------------------------------------------------------|.*/
  57. _____________________ADJUST_L1______________________, _____________________ADJUST_R1______________________,
  58. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  59. _____________________ADJUST_L2______________________, _____________________ADJUST_R2______________________,
  60. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  61. _____________________ADJUST_L3______________________, _____________________ADJUST_R3______________________,
  62. /*|--------+--------+--------+--------+--------+----| |--------+--------+--------+--------+--------+-----------|*/
  63. _____________MOD_LEFT_____________, _____________MOD_RIGHT____________
  64. /*|-----------------------------------| |----------------------------------|*/
  65. ),
  66. };
  67. bool process_record_user(uint16_t keycode, keyrecord_t *record){
  68. bool user_records_press=true;
  69. if (record->event.pressed){
  70. add_keylog(keycode);
  71. }
  72. switch (keycode){
  73. case QWERTY:
  74. if (record->event.pressed){
  75. set_single_persistent_default_layer(_QWERTY);
  76. }
  77. break;
  78. case LOWER:
  79. if(record->event.pressed){
  80. layer_on(_LOWER);
  81. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  82. }else{
  83. layer_off(_LOWER);
  84. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  85. }
  86. break;
  87. case RAISE:
  88. if (record->event.pressed){
  89. layer_on(_RAISE);
  90. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  91. }else{
  92. layer_off(_RAISE);
  93. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  94. }
  95. break;
  96. case ADJUST:
  97. if (record->event.pressed){
  98. layer_on(_ADJUST);
  99. }else{
  100. layer_off(_ADJUST);
  101. }
  102. break;
  103. case RGB_MOD:
  104. #ifdef RGBLIGHT_ENABLE
  105. if(record->event.pressed){
  106. rgblight_mode(RGB_current_mode);
  107. rgblight_step();
  108. RGB_current_mode = rgblight_get_mode();
  109. }
  110. #endif
  111. break;
  112. case RGBRST:
  113. #ifdef RGBLIGHT_ENABLE
  114. if(record->event.pressed){
  115. eeconfig_update_rgblight_default();
  116. rgblight_enable();
  117. RGB_current_mode = rgblight_get_mode();
  118. }
  119. #endif
  120. break;
  121. default:
  122. user_records_press=false;
  123. break;
  124. }
  125. return false==user_records_press;
  126. }