stick.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright 2021 Danny Nguyen <danny@keeb.io>
  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 "stick.h"
  15. #ifdef RGB_MATRIX_ENABLE
  16. led_config_t g_led_config = { {
  17. // Key Matrix to LED Index
  18. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }
  19. }, {
  20. // LED Index to Physical Position
  21. { 0, 0 }, { 20, 0 }, { 40, 0 }, { 60, 0 },
  22. { 80, 0 }, { 100, 0 }, { 120, 0 }, { 140, 0 },
  23. { 160, 0 }, { 180, 0 }, { 200, 0 }, { 220, 0 },
  24. }, {
  25. // LED Index to Flag
  26. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
  27. } };
  28. #endif
  29. void eeconfig_init_kb(void) {
  30. #ifdef RGBLIGHT_ENABLE
  31. rgblight_enable(); // Enable RGB by default
  32. rgblight_sethsv(0, 255, 255); // Set default HSV - red hue, full saturation, full brightness
  33. # ifdef RGBLIGHT_EFFECT_RAINDOWN_SWIRL
  34. rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL + 2); // set to RGB_RAINBOW_SWIRL by default
  35. # endif
  36. #endif
  37. #ifdef RGB_MATRIX_ENABLE
  38. rgb_matrix_enable(); // Enable RGB by default
  39. #endif
  40. eeconfig_update_kb(0);
  41. eeconfig_init_user();
  42. }
  43. bool encoder_update_kb(uint8_t index, bool clockwise) {
  44. if (!encoder_update_user(index, clockwise)) { return false; }
  45. if (index == 0) {
  46. if (clockwise) {
  47. tap_code(KC_VOLU);
  48. } else {
  49. tap_code(KC_VOLD);
  50. }
  51. } else if (index == 1) {
  52. if (clockwise) {
  53. tap_code(KC_DOWN);
  54. } else {
  55. tap_code(KC_UP);
  56. }
  57. }
  58. return false;
  59. }