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.

134 lines
4.4 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. __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 M_SALL:
  67. if (record->event.pressed) {
  68. tap_code16(C(KC_A));
  69. }
  70. return false;
  71. case M_UNDO:
  72. if (record->event.pressed) {
  73. register_code(KC_LCTL);
  74. register_code(KC_Z);
  75. } else {
  76. unregister_code(KC_Z);
  77. unregister_code(KC_LCTL);
  78. }
  79. return false;
  80. case M_CUT:
  81. if (record->event.pressed) {
  82. tap_code16(C(KC_X));
  83. }
  84. return false;
  85. case M_COPY:
  86. if (record->event.pressed) {
  87. tap_code16(C(KC_C));
  88. }
  89. return false;
  90. case M_PASTE:
  91. if (record->event.pressed) {
  92. register_code(KC_LCTL);
  93. register_code(KC_V);
  94. } else {
  95. unregister_code(KC_V);
  96. unregister_code(KC_LCTL);
  97. }
  98. return false;
  99. case KC_1 ... KC_0:
  100. if (record->event.pressed) {
  101. if (get_mods() & MOD_MASK_RALT) {
  102. register_code(keycode + 0x3B);
  103. } else {
  104. register_code(keycode);
  105. }
  106. } else {
  107. if (get_mods() & MOD_MASK_RALT) {
  108. unregister_code(keycode + 0x3B);
  109. } else {
  110. unregister_code(keycode);
  111. }
  112. }
  113. return false;
  114. case KC_F1 ... KC_F12:
  115. if (record->event.pressed) {
  116. if (get_mods() & MOD_MASK_RALT) {
  117. register_code(keycode + 0x2E);
  118. } else {
  119. register_code(keycode);
  120. }
  121. } else {
  122. if (get_mods() & MOD_MASK_RALT) {
  123. unregister_code(keycode + 0x2E);
  124. } else {
  125. unregister_code(keycode);
  126. }
  127. }
  128. return false;
  129. } // switch()
  130. return true;
  131. };