template.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. __attribute__ ((weak))
  22. void led_set_keymap(uint8_t usb_led) {}
  23. // Call user matrix init, then call the keymap's init function
  24. void matrix_init_user(void) {
  25. matrix_init_keymap();
  26. }
  27. // No global matrix scan code, so just run keymap's matix
  28. // scan function
  29. void matrix_scan_user(void) {
  30. matrix_scan_keymap();
  31. }
  32. // Defines actions tor my global custom keycodes. Defined in drashna.h file
  33. // Then runs the _keymap's recod handier if not processed here,
  34. // And use "NEWPLACEHOLDER" for new safe range
  35. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  36. switch (keycode) {
  37. case KC_MAKE:
  38. if (!record->event.pressed) {
  39. SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
  40. #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
  41. ":dfu"
  42. #elif defined(BOOTLOADER_HALFKAY)
  43. ":teensy"
  44. #elif defined(BOOTLOADER_CATERINA)
  45. ":avrdude"
  46. #endif
  47. SS_TAP(X_ENTER));
  48. }
  49. return false;
  50. break;
  51. case KC_RESET:
  52. if (!record->event.pressed) {
  53. reset_keyboard();
  54. }
  55. return false;
  56. break;
  57. case EPRM:
  58. if (record->event.pressed) {
  59. eeconfig_init();
  60. }
  61. return false;
  62. break;
  63. case VRSN:
  64. if (record->event.pressed) {
  65. SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  66. }
  67. return false;
  68. break;
  69. }
  70. return process_record_keymap(keycode, record);
  71. }
  72. // Runs state check and changes underglow color and animation
  73. // on layer change, no matter where the change was initiated
  74. // Then runs keymap's layer change check
  75. uint32_t layer_state_set_user (uint32_t state) {
  76. return layer_state_set_keymap (state);
  77. }
  78. void led_set_user(uint8_t usb_led) {
  79. led_set_keymap(usb_led);
  80. }