You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7 KiB

  1. /* Copyright 2022 W. Alex Ronke, a.k.a. NoPunIn10Did (w.alex.ronke@gmail.com)
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "kastenwagen1840.h"
  17. #ifndef LAYER_LED_DISABLE
  18. void keyboard_pre_init_kb(void) {
  19. setPinOutput(LED_INDICATOR_TOP);
  20. setPinOutput(LED_INDICATOR_MID);
  21. setPinOutput(LED_INDICATOR_BOT);
  22. keyboard_pre_init_user();
  23. }
  24. __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
  25. writePinHigh(LED_INDICATOR_TOP);
  26. writePinHigh(LED_INDICATOR_MID);
  27. writePinHigh(LED_INDICATOR_BOT);
  28. switch(get_highest_layer(state) % 4) {
  29. case 1:
  30. writePinLow(LED_INDICATOR_TOP);
  31. writePinLow(LED_INDICATOR_MID);
  32. break;
  33. case 2:
  34. writePinLow(LED_INDICATOR_TOP);
  35. writePinLow(LED_INDICATOR_BOT);
  36. break;
  37. case 3:
  38. writePinLow(LED_INDICATOR_MID);
  39. writePinLow(LED_INDICATOR_BOT);
  40. break;
  41. }
  42. return state;
  43. }
  44. #endif
  45. bool encoder_update_kb(uint8_t index, bool clockwise) {
  46. if (!encoder_update_user(index, clockwise)) { return false; }
  47. if (clockwise) {
  48. tap_code(KC_PGUP);
  49. } else {
  50. tap_code(KC_PGUP);
  51. }
  52. return true;
  53. };