bumblebee.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2021 Swiftrax <swiftrax@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 "bumblebee.h"
  15. // Encoder
  16. bool encoder_update_kb(uint8_t index, bool clockwise) {
  17. if (!encoder_update_user(index, clockwise))
  18. return false;
  19. if (clockwise)
  20. tap_code(KC_VOLU);
  21. else
  22. tap_code(KC_VOLD);
  23. return true;
  24. }
  25. // Initialize all RGB indicators to 'off'
  26. void keyboard_post_init_kb(void) {
  27. rgblight_setrgb_at(0, 0, 0, 0); // [..., 0] = top LED
  28. rgblight_setrgb_at(0, 0, 0, 1); // [..., 1] = middle LED
  29. rgblight_setrgb_at(0, 0, 0, 2); // [..., 2] = bottom LED
  30. keyboard_post_init_user();
  31. }
  32. // RGB Layer Indicators
  33. layer_state_t layer_state_set_kb(layer_state_t state) {
  34. if (get_highest_layer(state) == 0) {
  35. rgblight_setrgb_at(255, 0, 0, 0); //red
  36. } else {
  37. rgblight_setrgb_at(0, 0, 0, 0);
  38. }
  39. if (get_highest_layer(state) == 1){
  40. rgblight_setrgb_at(0, 0, 255, 1); //green
  41. } else{
  42. rgblight_setrgb_at(0, 0, 0, 1);
  43. }
  44. if (get_highest_layer(state) == 2){
  45. rgblight_setrgb_at(0, 255, 0, 2); //blue
  46. } else{
  47. rgblight_setrgb_at(0, 0, 0, 2);
  48. }
  49. return layer_state_set_user(state);
  50. }