template.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "drashna.h"
  2. #include "quantum.h"
  3. #include "action.h"
  4. #include "version.h"
  5. // Add reconfigurable functions here, for keymap customization
  6. // This allows for a global, userspace functions, and continued
  7. // customization of the keymap. Use _keymap instead of _user
  8. // functions in the keymaps
  9. __attribute__ ((weak))
  10. void matrix_init_keymap(void) {}
  11. __attribute__ ((weak))
  12. void matrix_scan_keymap(void) {}
  13. __attribute__ ((weak))
  14. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  15. return true;
  16. }
  17. __attribute__ ((weak))
  18. uint32_t layer_state_set_keymap (uint32_t state) {
  19. return state;
  20. }
  21. // Call user matrix init, then call the keymap's init function
  22. void matrix_init_user(void) {
  23. matrix_init_keymap();
  24. }
  25. // No global matrix scan code, so just run keymap's matix
  26. // scan function
  27. void matrix_scan_user(void) {
  28. matrix_scan_keymap();
  29. }
  30. // Defines actions tor my global custom keycodes. Defined in drashna.h file
  31. // Then runs the _keymap's recod handier if not processed here,
  32. // And use "NEWPLACEHOLDER" for new safe range
  33. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  34. switch (keycode) {
  35. case KC_MAKE:
  36. if (!record->event.pressed) {
  37. SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
  38. #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
  39. ":dfu"
  40. #elif defined(BOOTLOADER_HALFKAY)
  41. ":teensy"
  42. #elif defined(BOOTLOADER_CATERINA)
  43. ":avrdude"
  44. #endif
  45. SS_TAP(X_ENTER));
  46. }
  47. return false;
  48. break;
  49. case KC_RESET:
  50. if (!record->event.pressed) {
  51. reset_keyboard();
  52. }
  53. return false;
  54. break;
  55. case EPRM:
  56. if (record->event.pressed) {
  57. eeconfig_init();
  58. }
  59. return false;
  60. break;
  61. case VRSN:
  62. if (record->event.pressed) {
  63. SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  64. }
  65. return false;
  66. break;
  67. }
  68. return process_record_keymap(keycode, record);
  69. }
  70. // Runs state check and changes underglow color and animation
  71. // on layer change, no matter where the change was initiated
  72. // Then runs keymap's layer change check
  73. uint32_t layer_state_set_user (uint32_t state) {
  74. return layer_state_set_keymap (state);
  75. }