logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

nz64.c (3965B)


  1. /* Copyright 2021 JasonRen(biu)
  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 "nz64.h"
  17. #ifdef RGB_MATRIX_ENABLE
  18. typedef union {
  19. uint32_t raw;
  20. uint8_t underground_rgb_sw :8;
  21. } kb_cums_t;
  22. kb_cums_t kb_cums;
  23. led_config_t g_led_config = {
  24. {
  25. { 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52 },
  26. { 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38 },
  27. { 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, NO_LED, 25 },
  28. { 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11 },
  29. { 10, 9, 8, NO_LED, NO_LED, 6, NO_LED, NO_LED, NO_LED, 4, 3, 2, 1, 0 }
  30. },
  31. {
  32. /* LED Index to Physical Position */
  33. {224,64},{207,64},{190,64},{172,64},{155,64}, {121,64}, {86,64}, {52,64}, {34,64},{17,64},{0,64},
  34. {224,48},{207,48},{190,48},{172,48},{155,48},{138,48},{121,48},{103,48},{86,48},{69,48},{52,48},{34,48},{17,48},{0,48},
  35. {224,32},{190,32},{172,32},{155,32},{138,32},{121,32},{103,32},{86,32},{69,32},{52,32},{34,32},{17,32},{0,32},
  36. {224,16},{207,16},{190,16},{172,16},{155,16},{138,16},{121,16},{103,16},{86,16},{69,16},{52,16},{34,16},{17,16},{0,16},
  37. {224,0},{207,0},{190,0},{172,0},{155,0},{138,0},{121,0},{103,0},{86,0},{69,0},{52,0},{34,0},{17,0},{0,0},
  38. {0,0},{37,0},{75,0},{112,0},{149,0},{187,0},{224,0},
  39. {0,32},
  40. {224,64},{187,64},{149,64},{112,64},{75,64},{37,64},{0,64},
  41. {224,32}
  42. },
  43. {
  44. /* LED Index to Flag */
  45. 4,4,4,4,4, 4,4,4,4,4,
  46. 4,4,4,4,4, 4,4,4,4,4,
  47. 4,4,4,4,4, 4,4,4,4,4,
  48. 4,4,4,4,4, 4,4,4,4,4,
  49. 4,4,4,4,4, 4,4,4,4,4,
  50. 4,4,4,4,4, 4,4,4,4,4,
  51. 4,4,4,4,4, 4,
  52. 2,2,2,2,2, 2,2,2,2,2,
  53. 2,2,2,2,2, 2
  54. }
  55. };
  56. bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
  57. if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
  58. return false;
  59. }
  60. if (rgb_matrix_is_enabled()) {
  61. if (kb_cums.underground_rgb_sw == 1) {
  62. for (uint8_t i = led_min; i < led_max; ++i) {
  63. if ((g_led_config.flags[i] == 4)) {
  64. rgb_matrix_set_color(i, 0, 0, 0);
  65. }
  66. }
  67. } else if (kb_cums.underground_rgb_sw == 2) {
  68. for (uint8_t i = led_min; i < led_max; ++i) {
  69. if ((g_led_config.flags[i] == 2)) {
  70. rgb_matrix_set_color(i, 0, 0, 0);
  71. }
  72. }
  73. }
  74. } else {
  75. rgb_matrix_set_color_all(0,0,0);
  76. }
  77. return true;
  78. }
  79. void eeconfig_init_kb(void) {
  80. kb_cums.raw = 0;
  81. eeconfig_update_kb(kb_cums.raw);
  82. eeconfig_init_user();
  83. }
  84. void keyboard_post_init_kb(void) {
  85. kb_cums.underground_rgb_sw = eeconfig_read_kb();
  86. keyboard_post_init_user();
  87. }
  88. #endif
  89. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  90. if (!process_record_user(keycode, record)) {
  91. return false;
  92. }
  93. switch(keycode) {
  94. #ifdef RGB_MATRIX_ENABLE
  95. case URGB_K:
  96. if (rgb_matrix_config.enable && record->event.pressed) {
  97. kb_cums.underground_rgb_sw += 1;
  98. kb_cums.underground_rgb_sw %= 3;
  99. }
  100. eeconfig_update_kb(kb_cums.raw);
  101. return false;
  102. #endif
  103. default:
  104. return true;
  105. }
  106. return true;
  107. }