You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

  1. // Copyright 2023 Colin Kinloch (@ColinKinloch)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "quantum.h"
  4. static uint8_t anim = 0;
  5. #ifdef ENCODER_ENABLE
  6. bool encoder_update_kb(uint8_t index, bool clockwise) {
  7. if (!encoder_update_user(index, clockwise)) {
  8. return false;
  9. }
  10. switch (index) {
  11. case 0: {
  12. if (clockwise) {
  13. tap_code_delay(KC_VOLU, 10);
  14. } else {
  15. tap_code_delay(KC_VOLD, 10);
  16. }
  17. }
  18. break;
  19. case 1: {
  20. if (clockwise) {
  21. rgblight_increase_hue();
  22. } else {
  23. rgblight_decrease_hue();
  24. }
  25. }
  26. break;
  27. case 2: {
  28. if (clockwise) {
  29. rgblight_increase_val();
  30. } else {
  31. rgblight_decrease_val();
  32. }
  33. }
  34. break;
  35. case 3: {
  36. if (clockwise) {
  37. anim++;
  38. } else {
  39. anim--;
  40. }
  41. if (anim >= RGB_MATRIX_EFFECT_MAX) {
  42. anim = 0;
  43. } else if (anim < 0) {
  44. anim = RGB_MATRIX_EFFECT_MAX - 1;
  45. }
  46. rgblight_mode(anim);
  47. }
  48. break;
  49. }
  50. return true;
  51. }
  52. #endif