2
0

pulse4k.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright (C) 2019 Maxr1998 <max.rumpf1998@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "pulse4k.h"
  15. #include "rgblight.h"
  16. enum combo_events {
  17. LED_ADJUST
  18. };
  19. const uint16_t PROGMEM led_adjust_combo[] = {KC_LEFT, KC_RGHT, COMBO_END};
  20. combo_t key_combos[COMBO_COUNT] = {
  21. [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
  22. };
  23. bool led_adjust_active = false;
  24. void matrix_init_kb(void) {
  25. matrix_init_user();
  26. }
  27. void process_combo_event(uint8_t combo_index, bool pressed) {
  28. if (combo_index == LED_ADJUST) {
  29. led_adjust_active = pressed;
  30. }
  31. }
  32. void encoder_update_kb(uint8_t index, bool clockwise) {
  33. if (index == 0) {
  34. if (led_adjust_active) {
  35. if (clockwise) {
  36. rgblight_increase_val();
  37. } else {
  38. rgblight_decrease_val();
  39. }
  40. } else encoder_one_update(clockwise);
  41. } else if (index == 1) {
  42. if (led_adjust_active) {
  43. if (clockwise) {
  44. rgblight_increase_hue();
  45. } else {
  46. rgblight_decrease_hue();
  47. }
  48. } else encoder_two_update(clockwise);
  49. }
  50. }