pulse4k.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. }
  51. __attribute__((weak)) void encoder_one_update(bool clockwise) {
  52. if (clockwise) {
  53. tap_code(KC_PGDN);
  54. } else {
  55. tap_code(KC_PGUP);
  56. }
  57. }
  58. __attribute__((weak)) void encoder_two_update(bool clockwise) {
  59. if (clockwise) {
  60. tap_code(KC_VOLU);
  61. } else {
  62. tap_code(KC_VOLD);
  63. }
  64. }