noroadsleft.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* Copyright 2020 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_1 ... KC_0:
  118. if (record->event.pressed) {
  119. if (get_mods() & MOD_MASK_RALT) {
  120. register_code(keycode + 0x3B);
  121. } else {
  122. register_code(keycode);
  123. }
  124. } else {
  125. if (get_mods() & MOD_MASK_RALT) {
  126. unregister_code(keycode + 0x3B);
  127. } else {
  128. unregister_code(keycode);
  129. }
  130. }
  131. return false;
  132. case KC_F1 ... KC_F12:
  133. if (record->event.pressed) {
  134. if (get_mods() & MOD_MASK_RALT) {
  135. register_code(keycode + 0x2E);
  136. } else {
  137. register_code(keycode);
  138. }
  139. } else {
  140. if (get_mods() & MOD_MASK_RALT) {
  141. unregister_code(keycode + 0x2E);
  142. } else {
  143. unregister_code(keycode);
  144. }
  145. }
  146. return false;
  147. } // switch()
  148. return true;
  149. };