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.

140 lines
4.6 KiB

  1. /* Copyright 2020-2022 James Young (@noroadsleft)
  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 "noroadsleft.h"
  17. #include "version.h"
  18. __attribute__((weak))
  19. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; };
  20. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  21. if (!process_record_keymap(keycode, record)) {
  22. return false;
  23. }
  24. #if defined(ANSI_NUBS_ROW) && defined(ANSI_NUBS_COL)
  25. // if ANSI_NUBS_ROW and ANSI_NUBS_COL are both defined, and Right Alt mod is active
  26. if ( record->event.key.row == ANSI_NUBS_ROW && record->event.key.col == ANSI_NUBS_COL && get_mods() & MOD_MASK_RALT ) {
  27. if (record->event.pressed) {
  28. register_code(KC_NUBS);
  29. } else {
  30. unregister_code(KC_NUBS);
  31. }
  32. return false;
  33. }
  34. #endif
  35. switch (keycode) {
  36. case VRSN:
  37. if (record->event.pressed) {
  38. SEND_STRING(QMK_KEYBOARD ":" QMK_KEYMAP " # @ " QMK_VERSION);
  39. }
  40. return false;
  41. case G_PUSH:
  42. if (record->event.pressed) {
  43. SEND_STRING("git push origin ");
  44. };
  45. return false;
  46. case G_FTCH:
  47. if (record->event.pressed) {
  48. if ( get_mods() & MOD_MASK_SHIFT ) {
  49. clear_mods();
  50. SEND_STRING("git pull upstream ");
  51. } else {
  52. SEND_STRING("git fetch upstream ");
  53. }
  54. };
  55. return false;
  56. case G_BRCH:
  57. if (record->event.pressed) {
  58. if ( get_mods() & MOD_MASK_SHIFT ) {
  59. clear_mods();
  60. SEND_STRING("master");
  61. } else {
  62. SEND_STRING("$(git branch-name)");
  63. }
  64. };
  65. return false;
  66. case G_PWD:
  67. if (record->event.pressed) {
  68. clear_mods();
  69. SEND_STRING("$( pwd | sed -e 's;^.*/keyboards/;;' -e 's;/;_;g')");
  70. };
  71. return false;
  72. case M_SALL:
  73. if (record->event.pressed) {
  74. tap_code16(C(KC_A));
  75. }
  76. return false;
  77. case M_UNDO:
  78. if (record->event.pressed) {
  79. register_code(KC_LCTL);
  80. register_code(KC_Z);
  81. } else {
  82. unregister_code(KC_Z);
  83. unregister_code(KC_LCTL);
  84. }
  85. return false;
  86. case M_CUT:
  87. if (record->event.pressed) {
  88. tap_code16(C(KC_X));
  89. }
  90. return false;
  91. case M_COPY:
  92. if (record->event.pressed) {
  93. tap_code16(C(KC_C));
  94. }
  95. return false;
  96. case M_PASTE:
  97. if (record->event.pressed) {
  98. register_code(KC_LCTL);
  99. register_code(KC_V);
  100. } else {
  101. unregister_code(KC_V);
  102. unregister_code(KC_LCTL);
  103. }
  104. return false;
  105. case KC_1 ... KC_0:
  106. if (record->event.pressed) {
  107. if (get_mods() & MOD_MASK_RALT) {
  108. register_code(keycode + 0x3B);
  109. } else {
  110. register_code(keycode);
  111. }
  112. } else {
  113. if (get_mods() & MOD_MASK_RALT) {
  114. unregister_code(keycode + 0x3B);
  115. } else {
  116. unregister_code(keycode);
  117. }
  118. }
  119. return false;
  120. case KC_F1 ... KC_F12:
  121. if (record->event.pressed) {
  122. if (get_mods() & MOD_MASK_RALT) {
  123. register_code(keycode + 0x2E);
  124. } else {
  125. register_code(keycode);
  126. }
  127. } else {
  128. if (get_mods() & MOD_MASK_RALT) {
  129. unregister_code(keycode + 0x2E);
  130. } else {
  131. unregister_code(keycode);
  132. }
  133. }
  134. return false;
  135. } // switch()
  136. return true;
  137. };