logo

qmk_firmware

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

rev1.c (3014B)


  1. /* Copyright 2023 HorrorTroll <https://github.com/HorrorTroll>
  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 "quantum.h"
  17. #ifdef RGB_MATRIX_ENABLE
  18. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  19. switch (keycode) {
  20. case QK_RGB_MATRIX_TOGGLE:
  21. if (record->event.pressed) {
  22. switch (rgb_matrix_get_flags()) {
  23. case LED_FLAG_ALL: {
  24. rgb_matrix_set_flags(LED_FLAG_NONE);
  25. rgb_matrix_set_color_all(0, 0, 0);
  26. }
  27. break;
  28. default: {
  29. rgb_matrix_set_flags(LED_FLAG_ALL);
  30. rgb_matrix_enable_noeeprom();
  31. }
  32. break;
  33. }
  34. }
  35. return false;
  36. case QK_RGB_MATRIX_MODE_NEXT:
  37. if (record->event.pressed) {
  38. switch (rgb_matrix_get_mode()) {
  39. case RGB_MATRIX_SOLID_MULTISPLASH:
  40. rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR);
  41. return false;
  42. default:
  43. rgb_matrix_step();
  44. return false;
  45. }
  46. }
  47. return false;
  48. case QK_RGB_MATRIX_MODE_PREVIOUS:
  49. if (record->event.pressed) {
  50. switch (rgb_matrix_get_mode()) {
  51. case RGB_MATRIX_SOLID_COLOR:
  52. rgb_matrix_mode(RGB_MATRIX_SOLID_MULTISPLASH);
  53. return false;
  54. default:
  55. rgb_matrix_step_reverse();
  56. return false;
  57. }
  58. }
  59. return false;
  60. }
  61. return process_record_user(keycode, record);
  62. }
  63. bool rgb_matrix_indicators_kb(void) {
  64. if (!rgb_matrix_indicators_user()) {
  65. return false;
  66. }
  67. if (host_keyboard_led_state().caps_lock) {
  68. rgb_matrix_set_color(30, 0, 75, 75);
  69. } else if (!(rgb_matrix_get_flags() & LED_FLAG_INDICATOR)) {
  70. rgb_matrix_set_color(30, RGB_OFF);
  71. }
  72. return true;
  73. }
  74. void keyboard_post_init_kb(void) {
  75. if (!(rgb_matrix_get_flags() & LED_FLAG_ALL)) {
  76. rgb_matrix_set_color_all(0, 0, 0);
  77. } else {
  78. rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_STARTUP_SWIRL_ANIM);
  79. }
  80. keyboard_post_init_user();
  81. }
  82. #endif