rgb_functions.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright 2021 Drashna Jael're
  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 "rgb_functions.h"
  18. #ifdef RGBLIGHT_ENABLE
  19. #undef RGB_DI_PIN
  20. #define RGB_DI_PIN RGBLIGHT_DI_PIN
  21. #define ws2812_setleds ws2812_rgb_setleds
  22. #include "ws2812.c"
  23. void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
  24. ws2812_setleds(start_led, num_leds);
  25. }
  26. #endif
  27. #ifdef RGB_MATRIX_ENABLE
  28. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  29. if (!process_record_user(keycode, record)) { return false; }
  30. if (record->event.pressed) {
  31. switch(keycode) {
  32. case RGB_MATRIX_TOGGLE: // toggle rgb matrix
  33. rgb_matrix_toggle();
  34. return false;
  35. case RGB_MATRIX_MODE_INC:
  36. rgb_matrix_step();
  37. return false;
  38. case RGB_MATRIX_MODE_DEC:
  39. rgb_matrix_step_reverse();
  40. return false;
  41. case RGB_MATRIX_HUE_INC:
  42. rgb_matrix_increase_hue();
  43. return false;
  44. case RGB_MATRIX_HUE_DEC:
  45. rgb_matrix_decrease_hue();
  46. return false;
  47. case RGB_MATRIX_SAT_INC:
  48. rgb_matrix_increase_sat();
  49. return false;
  50. case RGB_MATRIX_SAT_DEC:
  51. rgb_matrix_decrease_sat();
  52. return false;
  53. case RGB_MATRIX_VAL_INC:
  54. rgb_matrix_increase_val();
  55. return false;
  56. case RGB_MATRIX_VAL_DEC:
  57. rgb_matrix_decrease_val();
  58. return false;
  59. default:
  60. break;
  61. }
  62. }
  63. return true;
  64. }
  65. #endif