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.

42 lines
1.0 KiB

  1. #include "rainbowUnicorn.h"
  2. #include "pcoves.h"
  3. static struct {
  4. bool enabled;
  5. uint8_t color;
  6. char string[2];
  7. uint8_t mods;
  8. } state = {false, 0};
  9. bool process_record_rainbowUnicorn(uint16_t keycode, keyrecord_t* record) {
  10. if (keycode == RAINBOW_UNICORN_TOGGLE) {
  11. state.enabled ^= true;
  12. return false;
  13. }
  14. if (!state.enabled) return true;
  15. switch (keycode) {
  16. case KC_A ... KC_Z:
  17. case KC_1 ... KC_0:
  18. case ALT_T(KC_A)... ALT_T(KC_Z):
  19. case CTL_T(KC_A)... CTL_T(KC_Z):
  20. case GUI_T(KC_A)... GUI_T(KC_Z):
  21. case SFT_T(KC_A)... SFT_T(KC_Z):
  22. if (record->event.pressed) {
  23. state.mods = get_mods();
  24. clear_mods();
  25. tap_code16(C(KC_C));
  26. itoa(state.color + 3, state.string, 10);
  27. send_string(state.string);
  28. set_mods(state.mods);
  29. } else {
  30. state.color = (state.color + 1) % 11;
  31. }
  32. }
  33. return true;
  34. }