replicaJunction.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #include "replicaJunction.h"
  2. #include "version.h"
  3. #ifdef TAP_DANCE_ENABLE
  4. void dance_layer(qk_tap_dance_state_t *state, void *user_data)
  5. {
  6. uint8_t layer = biton32(layer_state);
  7. if (state->count >= 5)
  8. {
  9. // 5 or more taps resets the keyboard
  10. reset_keyboard();
  11. }
  12. #ifdef L_QWERTY
  13. else if (state->count == 3)
  14. {
  15. // Triple tap changes to QWERTY layer
  16. if (layer == L_QWERTY)
  17. {
  18. layer_off(L_QWERTY);
  19. }
  20. else
  21. {
  22. layer_on(L_QWERTY);
  23. }
  24. }
  25. #endif
  26. #ifdef L_NUM
  27. else if (state->count == 2)
  28. {
  29. // Double tap toggles Number layer
  30. if (layer == L_NUM)
  31. {
  32. layer_off(L_NUM);
  33. }
  34. else
  35. {
  36. layer_on(L_NUM);
  37. }
  38. }
  39. #endif
  40. else
  41. {
  42. // Single tap sends Escape, and also turns off layers
  43. // That's mostly in case I get stuck and forget where I am
  44. #ifdef L_NUM
  45. layer_off(L_NUM);
  46. #endif
  47. #ifdef L_EXTEND
  48. layer_off(L_EXTEND);
  49. #endif
  50. #ifdef L_SYMBOL
  51. layer_off(L_SYMBOL);
  52. #endif
  53. #ifdef L_QWERTY
  54. layer_off(L_QWERTY);
  55. #endif
  56. register_code(KC_ESC);
  57. unregister_code(KC_ESC);
  58. }
  59. };
  60. // Tap Dance Definitions
  61. // Note - this needs to come AFTER the function is declared
  62. qk_tap_dance_action_t tap_dance_actions[] = {
  63. [TD_LAYER_TOGGLE] = ACTION_TAP_DANCE_FN(dance_layer)
  64. };
  65. #endif // TAP_DANCE_ENABLE
  66. // These functions can be overridden in individual keymap files.
  67. // This allows a user function to be shared for all my keyboards, while each
  68. // keyboard can also have a keyboard-specific section.
  69. // Note that keymaps don't need to override these if there's nothing to
  70. // override them with.
  71. __attribute__ ((weak))
  72. void matrix_init_keymap(void) {}
  73. __attribute__ ((weak))
  74. void matrix_scan_keymap(void) {}
  75. __attribute__ ((weak))
  76. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  77. return true;
  78. };
  79. // Runs just one time when the keyboard initializes.
  80. void matrix_init_user(void) {
  81. #ifdef UNICODEMAP_ENABLE
  82. // Set Unicode input to use WinCompose
  83. // https://github.com/samhocevar/wincompose
  84. set_unicode_input_mode(UC_WINC);
  85. #endif // UNICODEMAP_ENABLE
  86. matrix_init_keymap();
  87. };
  88. // Runs constantly in the background, in a loop.
  89. void matrix_scan_user(void) {
  90. matrix_scan_keymap();
  91. }
  92. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  93. if (record->event.pressed)
  94. return true;
  95. switch(keycode)
  96. {
  97. case RJ_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
  98. SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP
  99. #if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU))
  100. ":dfu"
  101. #elif defined(BOOTLOADER_HALFKAY)
  102. ":teensy"
  103. #elif defined(BOOTLOADER_CATERINA)
  104. ":avrdude"
  105. #endif // bootloader options
  106. //SS_TAP(X_ENTER)
  107. );
  108. return false;
  109. case RJ_QMKV:
  110. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  111. return false;
  112. case RJ_EQ:
  113. SEND_STRING("==");
  114. return false;
  115. case RJ_NEQ:
  116. SEND_STRING("!=");
  117. return false;
  118. case RJ_GEQ:
  119. SEND_STRING(">=");
  120. return false;
  121. case RJ_LEQ:
  122. SEND_STRING("<=");
  123. return false;
  124. case RJ_GEQR:
  125. SEND_STRING("=>");
  126. return false;
  127. case RJ_DUND:
  128. SEND_STRING("$_");
  129. return false;
  130. case RJ_SELS:
  131. SEND_STRING("select *");
  132. return false;
  133. }
  134. return process_record_keymap(keycode, record);
  135. };