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.

191 lines
6.2 KiB

  1. /* Copyright 2020-2021 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. /*******************
  19. ** MODIFIER MASKS **
  20. *******************/
  21. bool macroMode = 0;
  22. __attribute__((weak))
  23. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; };
  24. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  25. if (!process_record_keymap(keycode, record)) {
  26. return false;
  27. }
  28. #if defined(ANSI_NUBS_ROW) && defined(ANSI_NUBS_COL)
  29. // if ANSI_NUBS_ROW and ANSI_NUBS_COL are both defined, and Right Alt mod is active
  30. if ( record->event.key.row == ANSI_NUBS_ROW && record->event.key.col == ANSI_NUBS_COL && get_mods() & MOD_MASK_RALT ) {
  31. if (record->event.pressed) {
  32. register_code(KC_NUBS);
  33. } else {
  34. unregister_code(KC_NUBS);
  35. }
  36. return false;
  37. }
  38. #endif
  39. switch (keycode) {
  40. case VRSN:
  41. if (record->event.pressed) {
  42. SEND_STRING(QMK_KEYBOARD ":" QMK_KEYMAP " # @ " QMK_VERSION);
  43. }
  44. return false;
  45. case G_PUSH:
  46. if (record->event.pressed) {
  47. SEND_STRING("git push origin ");
  48. };
  49. return false;
  50. case G_FTCH:
  51. if (record->event.pressed) {
  52. if ( get_mods() & MOD_MASK_SHIFT ) {
  53. clear_mods();
  54. SEND_STRING("git pull upstream ");
  55. } else {
  56. SEND_STRING("git fetch upstream ");
  57. }
  58. };
  59. return false;
  60. case G_BRCH:
  61. if (record->event.pressed) {
  62. if ( get_mods() & MOD_MASK_SHIFT ) {
  63. clear_mods();
  64. SEND_STRING("master");
  65. } else {
  66. SEND_STRING("$(git branch-name)");
  67. }
  68. };
  69. return false;
  70. case M_SALL:
  71. if (record->event.pressed) {
  72. if ( macroMode == 1 ) {
  73. SEND_STRING(SS_LGUI("a"));
  74. } else {
  75. SEND_STRING(SS_LCTL("a"));
  76. }
  77. }
  78. return false;
  79. case M_UNDO:
  80. if (record->event.pressed) {
  81. if ( macroMode == 1 ) {
  82. if ( get_mods() & MOD_MASK_SHIFT ) {
  83. SEND_STRING(SS_LSFT(SS_LGUI("z")));
  84. } else {
  85. SEND_STRING(SS_LGUI("z"));
  86. }
  87. } else {
  88. SEND_STRING(SS_LCTL("z"));
  89. }
  90. }
  91. return false;
  92. case M_CUT:
  93. if (record->event.pressed) {
  94. if ( macroMode == 1 ) {
  95. SEND_STRING(SS_LGUI("x"));
  96. } else {
  97. SEND_STRING(SS_LCTL("x"));
  98. }
  99. }
  100. return false;
  101. case M_COPY:
  102. if (record->event.pressed) {
  103. if ( macroMode == 1 ) {
  104. SEND_STRING(SS_LGUI("c"));
  105. } else {
  106. SEND_STRING(SS_LCTL("c"));
  107. }
  108. }
  109. return false;
  110. case M_PASTE:
  111. if (record->event.pressed) {
  112. if ( macroMode == 1 ) {
  113. if ( get_mods() & MOD_MASK_SHIFT ) {
  114. SEND_STRING(SS_LSFT(SS_LALT(SS_LGUI("v"))));
  115. } else {
  116. SEND_STRING(SS_LGUI("v"));
  117. }
  118. } else {
  119. SEND_STRING(SS_LCTL("v"));
  120. }
  121. }
  122. return false;
  123. case M_MDSWP:
  124. if (record->event.pressed) {
  125. macroMode ^= 1;
  126. }
  127. return false;
  128. case KC_1 ... KC_0:
  129. if (record->event.pressed) {
  130. if (get_mods() & MOD_MASK_RALT) {
  131. register_code(keycode + 0x3B);
  132. } else {
  133. register_code(keycode);
  134. }
  135. } else {
  136. if (get_mods() & MOD_MASK_RALT) {
  137. unregister_code(keycode + 0x3B);
  138. } else {
  139. unregister_code(keycode);
  140. }
  141. }
  142. return false;
  143. case KC_F1 ... KC_F12:
  144. if (record->event.pressed) {
  145. if (get_mods() & MOD_MASK_RALT) {
  146. register_code(keycode + 0x2E);
  147. } else {
  148. register_code(keycode);
  149. }
  150. } else {
  151. if (get_mods() & MOD_MASK_RALT) {
  152. unregister_code(keycode + 0x2E);
  153. } else {
  154. unregister_code(keycode);
  155. }
  156. }
  157. return false;
  158. case KC_PSCR:
  159. if (record->event.pressed) {
  160. if ( macroMode == 1 ) {
  161. tap_code16(G(S(KC_3)));
  162. } else {
  163. tap_code(KC_PSCR);
  164. }
  165. }
  166. return false;
  167. case KC_HOME:
  168. if (record->event.pressed) {
  169. if ( macroMode == 1 ) {
  170. tap_code16(G(KC_LEFT));
  171. } else {
  172. tap_code(KC_HOME);
  173. }
  174. }
  175. return false;
  176. case KC_END:
  177. if (record->event.pressed) {
  178. if ( macroMode == 1 ) {
  179. tap_code16(G(KC_RGHT));
  180. } else {
  181. tap_code(KC_END);
  182. }
  183. }
  184. return false;
  185. } // switch()
  186. return true;
  187. };