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.

101 lines
2.8 KiB

  1. #include "dhertz.h"
  2. // Add reconfigurable functions here, for keymap customization
  3. // This allows for a global, userspace functions, and continued
  4. // customization of the keymap. Use _keymap instead of _user
  5. // functions in the keymaps
  6. __attribute__ ((weak))
  7. void matrix_init_keymap(void) {}
  8. __attribute__ ((weak))
  9. void matrix_scan_keymap(void) {}
  10. __attribute__ ((weak))
  11. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  12. return true;
  13. }
  14. __attribute__ ((weak))
  15. uint32_t layer_state_set_keymap (uint32_t state) {
  16. return state;
  17. }
  18. __attribute__ ((weak))
  19. void led_set_keymap(uint8_t usb_led) {}
  20. __attribute__ ((weak))
  21. void action_function_keymap(keyrecord_t *record, uint8_t id, uint8_t opt) {}
  22. // Call user matrix init, then call the keymap's init function
  23. void matrix_init_user(void) {
  24. matrix_init_keymap();
  25. }
  26. // No global matrix scan code, so just run keymap's matix
  27. // scan function
  28. void matrix_scan_user(void) {
  29. matrix_scan_keymap();
  30. }
  31. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  32. switch(keycode) {
  33. case CMD_TAB_CMD:
  34. mod_or_mod_with_macro(record, KC_LGUI, SS_TAP(X_TAB));
  35. return false;
  36. case CMD_GRV_CMD:
  37. mod_or_mod_with_macro(record, KC_RGUI, SS_TAP(X_GRAVE));
  38. return false;
  39. }
  40. if (record->event.pressed) {
  41. switch(keycode) {
  42. case HSH_TLD:
  43. if (get_mods()&(MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT))) {
  44. SEND_STRING(SS_TAP(X_NONUS_BSLASH));
  45. } else {
  46. SEND_STRING(SS_LALT("3"));
  47. }
  48. break;
  49. case CTRL_A:
  50. SEND_STRING(SS_LCTRL("a"));
  51. break;
  52. case CMD_ALT_C:
  53. SEND_STRING(SS_LGUI(SS_LALT("c")));
  54. break;
  55. case CMD_SFT_L:
  56. SEND_STRING(SS_LGUI("L"));
  57. break;
  58. case ISO_COUNTRY_CODE:
  59. SEND_STRING("country_iso_alpha2_code");
  60. break;
  61. default:
  62. return process_record_keymap(keycode, record);
  63. }
  64. return false;
  65. }
  66. return process_record_keymap(keycode, record);
  67. }
  68. static uint16_t sunds_timer;
  69. void mod_or_mod_with_macro(keyrecord_t *record, uint16_t kc_mod, char* macro) {
  70. if (record->event.pressed) {
  71. sunds_timer = timer_read();
  72. register_code(kc_mod);
  73. } else {
  74. if (timer_elapsed(sunds_timer) < TAPPING_TERM) {
  75. send_string(macro);
  76. }
  77. unregister_code(kc_mod);
  78. }
  79. }
  80. // Runs state check and changes underglow color and animation
  81. // on layer change, no matter where the change was initiated
  82. // Then runs keymap's layer change check
  83. uint32_t layer_state_set_user (uint32_t state) {
  84. return layer_state_set_keymap (state);
  85. }
  86. void led_set_user(uint8_t usb_led) {
  87. led_set_keymap(usb_led);
  88. }