template.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. SEND_STRING(":dfu");
  40. #elseif defined(BOOTLOADER_HALFKEY)
  41. SEND_STRING(":teensy ");
  42. #elseif defined(BOOTLOADER_CATERINA)
  43. SEND_STRING(":avrdude ");
  44. #else
  45. SEND_STRING(" ");
  46. #endif
  47. SEND_STRING(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. }