process_records.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "process_records.h"
  2. #include "custom_keycodes.h"
  3. #include "timer_utils.h"
  4. #ifdef RGB_ENABLE
  5. #include "custom_rgb.h"
  6. #endif
  7. #ifdef TRILAYER_ENABLED
  8. uint32_t layer_state_set_user(uint32_t state)
  9. {
  10. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  11. }
  12. #endif
  13. bool process_record_user(uint16_t keycode, keyrecord_t *record)
  14. {
  15. static uint16_t reset_timer;
  16. #ifndef TAP_DANCE_ENABLE
  17. if (!process_custom_tap_dance(keycode, record))
  18. return false;
  19. #endif
  20. switch (keycode)
  21. {
  22. case RGBRST:
  23. #ifdef RGB_ENABLE
  24. if (record->event.pressed)
  25. rgb_reset();
  26. #endif
  27. return false;
  28. case RESET:
  29. {
  30. if (record->event.pressed)
  31. reset_timer = timer_read() + 500;
  32. else if (timer_expired(reset_timer))
  33. reset_keyboard();
  34. }
  35. return false;
  36. #ifdef RGB_MATRIX_TOG_LAYERS
  37. case RGB_TOG:
  38. if (record->event.pressed) {
  39. rgb_matrix_decrease_flags();
  40. }
  41. return false;
  42. #endif
  43. }
  44. return process_record_encoder(keycode, record) && process_record_keymap(keycode, record);
  45. }
  46. __attribute__ ((weak))
  47. bool process_record_keymap(uint16_t keycode, keyrecord_t *record)
  48. {
  49. return true;
  50. }
  51. __attribute__ ((weak))
  52. bool process_record_encoder(uint16_t keycode, keyrecord_t *record)
  53. {
  54. return true;
  55. }