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.

149 lines
4.4 KiB

  1. /* Copyright 2021 Joshua T.
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include QMK_KEYBOARD_H
  17. #include "process_records.h"
  18. uint8_t mod_state;
  19. __attribute__ ((weak))
  20. bool process_record_user_kb(uint16_t keycode, keyrecord_t *record) {
  21. return true;
  22. }
  23. // Runs for each key down or up event.
  24. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  25. // Returning true here will cause QMK to continue handling the key normally.
  26. // Returning false indicates that we've handled everything the keycode should do, and QMK
  27. // should not continue handling the keypress.
  28. //
  29. // NOTE: There is also a process_record_kb function that can be defined in the keyboard-
  30. // specific code. This allows the keyboard to have its own process_record function.
  31. // This is supposed to be "higher" than the user function, meaning the kb function
  32. // is shared for all keymaps for the keyboard.
  33. //
  34. // For this reason, I add my own function, called process_record_user_kb, and at the end
  35. // of this function, I defer to that one if it exists.
  36. // return process_record_user(keycode, record);
  37. // Custom keycode / function handling, based on the core function
  38. // process_record_quantum
  39. // https://github.com/qmk/qmk_firmware/blob/master/quantum/quantum.c
  40. if (!(
  41. #ifdef USER_CAPS_WORD_ENABLE
  42. process_record_caps_word(keycode, record) &&
  43. #endif
  44. #ifdef USER_MOUSE_JIGGLE_ENABLE
  45. process_record_mouse_jiggle(keycode, record) &&
  46. #endif
  47. #ifdef USER_NUM_WORD_ENABLE
  48. process_record_num_word(keycode, record) &&
  49. #endif
  50. #ifdef USER_SECRETS_ENABLE
  51. process_record_secrets(keycode, record) &&
  52. #endif
  53. #ifdef USER_SUPER_ALT_TAB_ENABLE
  54. process_record_super_alt_tab(keycode, record) &&
  55. #endif
  56. true)) {
  57. return false;
  58. }
  59. // Miscellaneous keycode handling
  60. mod_state = get_mods();
  61. switch(keycode)
  62. {
  63. case QK_MAKE: {
  64. if (record->event.pressed)
  65. SEND_STRING("qmk compile --keyboard " QMK_KEYBOARD " --keymap " QMK_KEYMAP);
  66. return false;
  67. }
  68. case QK_FLSH: {
  69. if (record->event.pressed) {
  70. SEND_STRING("qmk flash --keyboard " QMK_KEYBOARD " --keymap " QMK_KEYMAP);
  71. }
  72. return false;
  73. }
  74. case QK_VERS: {
  75. if (record->event.pressed) {
  76. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE);
  77. }
  78. return false;
  79. }
  80. case PRG_EQ: {
  81. if (record->event.pressed) {
  82. SEND_STRING("==");
  83. }
  84. return false;
  85. }
  86. case PRG_NE: {
  87. if (record->event.pressed) {
  88. SEND_STRING("!=");
  89. }
  90. return false;
  91. }
  92. case PRG_GEQ: {
  93. if (record->event.pressed) {
  94. SEND_STRING(">=");
  95. }
  96. return false;
  97. }
  98. case PRG_LEQ: {
  99. if (record->event.pressed) {
  100. SEND_STRING("<=");
  101. }
  102. return false;
  103. }
  104. case PRG_ARR: {
  105. if (record->event.pressed) {
  106. SEND_STRING("=>");
  107. }
  108. return false;
  109. }
  110. case PS_ITEM: {
  111. if (record->event.pressed) {
  112. SEND_STRING("$_");
  113. }
  114. return false;
  115. }
  116. case FS_PIPE: {
  117. if (record->event.pressed) {
  118. SEND_STRING("|>");
  119. }
  120. return false;
  121. }
  122. case FS_ARR: {
  123. if (record->event.pressed) {
  124. SEND_STRING("->");
  125. }
  126. return false;
  127. }
  128. case SHEBANG: {
  129. if (record->event.pressed) {
  130. SEND_STRING("#!");
  131. }
  132. return false;
  133. }
  134. }
  135. return process_record_user_kb(keycode, record);
  136. }