bocaj.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #include "bocaj.h"
  2. #include "eeprom.h"
  3. #include "version.h"
  4. #include "tap_dances.h"
  5. static uint16_t copy_paste_timer;
  6. userspace_config_t userspace_config;
  7. /* *** *** *** *** *
  8. * Helper Functions *
  9. * *** *** *** *** */
  10. void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); };
  11. // Add reconfigurable functions here, for keymap customization
  12. // This allows for a global, userspace functions, and continued
  13. // customization of the keymap. Use _keymap instead of _user
  14. // functions in the keymaps
  15. __attribute__ ((weak))
  16. void matrix_init_keymap(void) {}
  17. __attribute__ ((weak))
  18. void startup_keymap(void) {}
  19. __attribute__ ((weak))
  20. void suspend_power_down_keymap(void) {}
  21. __attribute__ ((weak))
  22. void suspend_wakeup_init_keymap(void) {}
  23. __attribute__ ((weak))
  24. void matrix_scan_keymap(void) {}
  25. __attribute__ ((weak))
  26. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  27. return true;
  28. }
  29. __attribute__ ((weak))
  30. bool process_record_secrets(uint16_t keycode, keyrecord_t *record) {
  31. return true;
  32. }
  33. __attribute__ ((weak))
  34. uint32_t layer_state_set_keymap (uint32_t state) {
  35. return state;
  36. }
  37. __attribute__ ((weak))
  38. uint32_t default_layer_state_set_keymap (uint32_t state) {
  39. return state;
  40. }
  41. __attribute__ ((weak))
  42. void led_set_keymap(uint8_t usb_led) {}
  43. // Call user matrix init, set default RGB colors and then
  44. // call the keymap's init function
  45. void matrix_init_user(void) {
  46. userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE);
  47. matrix_init_keymap();
  48. }
  49. void startup_user (void) {
  50. startup_keymap();
  51. }
  52. void suspend_power_down_user(void)
  53. {
  54. suspend_power_down_keymap();
  55. }
  56. void suspend_wakeup_init_user(void)
  57. {
  58. suspend_wakeup_init_keymap();
  59. #ifdef KEYBOARD_ergodox_ez
  60. wait_ms(10);
  61. #endif
  62. }
  63. // No global matrix scan code, so just run keymap's matrix
  64. // scan function
  65. void matrix_scan_user(void) {
  66. static bool has_ran_yet;
  67. if (!has_ran_yet) {
  68. has_ran_yet = true;
  69. startup_user();
  70. }
  71. #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
  72. run_diablo_macro_check();
  73. #endif // TAP_DANCE_ENABLE
  74. matrix_scan_keymap();
  75. }
  76. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  77. /* uint8_t default_layer = 0;
  78. default_layer = eeconfig_read_default_layer(); */
  79. switch (keycode) {
  80. case JJ_COPY:
  81. if (!record->event.pressed) {
  82. SEND_STRING(SS_LGUI("c"));
  83. }
  84. return false;
  85. break;
  86. case JJ_PSTE:
  87. if (!record->event.pressed) {
  88. SEND_STRING(SS_LGUI("v"));
  89. }
  90. return false;
  91. break;
  92. case JJ_ARRW:
  93. if (!record->event.pressed) {
  94. SEND_STRING("->");
  95. }
  96. return false;
  97. break; /*
  98. case KC_SWRK:
  99. if (!record->event.pressed) {
  100. set_single_persistent_default_layer(_SWRKMN);
  101. layer_move(default_layer);
  102. //ergodox_blink_all_leds();
  103. //ergodox_blink_all_leds();
  104. }
  105. return false;
  106. break;
  107. case KC_HWRK:
  108. if (!record->event.pressed) {
  109. set_single_persistent_default_layer(_HWRKMN);
  110. layer_move(default_layer);
  111. //ergodox_blink_all_leds();
  112. //ergodox_blink_all_leds();
  113. }
  114. return false;
  115. break;
  116. case KC_EPRM:
  117. if (!record->event.pressed) {
  118. //ergodox_blink_all_leds();
  119. eeconfig_init();
  120. }
  121. return false;
  122. break;
  123. case MC_LOCK:
  124. if (!record->event.pressed) {
  125. layer_move(default_layer);
  126. SEND_STRING(SS_LCTRL(SS_LGUI("q")));
  127. }
  128. return false;
  129. break; */
  130. case KC_DCLR:
  131. #ifdef TAP_DANCE_ENABLE
  132. if (record->event.pressed) {
  133. uint8_t dtime;
  134. for (dtime = 0; dtime < 4; dtime++) {
  135. diablo_key_time[dtime] = diablo_times[0];
  136. }
  137. }
  138. #endif // !TAP_DANCE_ENABLE
  139. return false;
  140. break;
  141. case KC_CCCV:
  142. if (record->event.pressed) {
  143. copy_paste_timer = timer_read();
  144. } else {
  145. if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
  146. SEND_STRING(SS_LGUI("c"));
  147. } else {
  148. SEND_STRING(SS_LGUI("v"));
  149. }
  150. }
  151. return false;
  152. break;
  153. }
  154. return process_record_keymap(keycode, record);
  155. }