pulse4k.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2019-2020 Maxr1998 <max.rumpf1998@gmail.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "pulse4k.h"
  18. #include "rgblight.h"
  19. enum combo_events {
  20. LED_ADJUST
  21. };
  22. extern const uint16_t PROGMEM led_adjust_combo[3];
  23. combo_t key_combos[COMBO_COUNT] = {
  24. [LED_ADJUST] = COMBO_ACTION(led_adjust_combo)
  25. };
  26. bool led_adjust_active = false;
  27. void process_combo_event(uint16_t combo_index, bool pressed) {
  28. if (combo_index == LED_ADJUST) {
  29. led_adjust_active = pressed;
  30. }
  31. }
  32. bool encoder_update_kb(uint8_t index, bool clockwise) {
  33. if (!encoder_update_user(index, clockwise)) return false;
  34. if (index == 0) {
  35. if (led_adjust_active) {
  36. if (clockwise) {
  37. rgblight_increase_val();
  38. } else {
  39. rgblight_decrease_val();
  40. }
  41. } else encoder_one_update(clockwise);
  42. } else if (index == 1) {
  43. if (led_adjust_active) {
  44. if (clockwise) {
  45. rgblight_increase_hue();
  46. } else {
  47. rgblight_decrease_hue();
  48. }
  49. } else encoder_two_update(clockwise);
  50. }
  51. return true;
  52. }
  53. __attribute__((weak)) void encoder_one_update(bool clockwise) {
  54. tap_code(!clockwise ? KC_PGUP : KC_PGDN);
  55. }
  56. __attribute__((weak)) void encoder_two_update(bool clockwise) {
  57. tap_code(!clockwise ? KC_VOLD : KC_VOLU);
  58. }