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.

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