aboutsummaryrefslogtreecommitdiff
path: root/users/noroadsleft/noroadsleft.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/noroadsleft/noroadsleft.c')
-rw-r--r--users/noroadsleft/noroadsleft.c153
1 files changed, 153 insertions, 0 deletions
diff --git a/users/noroadsleft/noroadsleft.c b/users/noroadsleft/noroadsleft.c
new file mode 100644
index 000000000..6fb223f9e
--- /dev/null
+++ b/users/noroadsleft/noroadsleft.c
@@ -0,0 +1,153 @@
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
17#include "noroadsleft.h"
18#include "version.h"
19
20/*******************
21** MODIFIER MASKS **
22*******************/
23bool macroMode = 0;
24
25__attribute__((weak))
26bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; };
27
28bool process_record_user(uint16_t keycode, keyrecord_t *record) {
29 if (!process_record_keymap(keycode, record)) {
30 return false;
31 }
32 switch (keycode) {
33 case VRSN:
34 if (record->event.pressed) {
35 SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
36 }
37 return false;
38 case G_PUSH:
39 if (record->event.pressed) {
40 SEND_STRING("git push origin ");
41 };
42 return false;
43 case G_FTCH:
44 if (record->event.pressed) {
45 if ( get_mods() & MOD_MASK_SHIFT ) {
46 clear_mods();
47 SEND_STRING("git pull upstream ");
48 } else {
49 SEND_STRING("git fetch upstream ");
50 }
51 };
52 return false;
53 case G_BRCH:
54 if (record->event.pressed) {
55 if ( get_mods() & MOD_MASK_SHIFT ) {
56 clear_mods();
57 SEND_STRING("master");
58 } else {
59 SEND_STRING("$(git branch-name)");
60 }
61 };
62 return false;
63 case M_SALL:
64 if (record->event.pressed) {
65 if ( macroMode == 1 ) {
66 SEND_STRING(SS_LGUI("a"));
67 } else {
68 SEND_STRING(SS_LCTL("a"));
69 }
70 }
71 return false;
72 case M_UNDO:
73 if (record->event.pressed) {
74 if ( macroMode == 1 ) {
75 if ( get_mods() & MOD_MASK_SHIFT ) {
76 SEND_STRING(SS_LSFT(SS_LGUI("z")));
77 } else {
78 SEND_STRING(SS_LGUI("z"));
79 }
80 } else {
81 SEND_STRING(SS_LCTL("z"));
82 }
83 }
84 return false;
85 case M_CUT:
86 if (record->event.pressed) {
87 if ( macroMode == 1 ) {
88 SEND_STRING(SS_LGUI("x"));
89 } else {
90 SEND_STRING(SS_LCTL("x"));
91 }
92 }
93 return false;
94 case M_COPY:
95 if (record->event.pressed) {
96 if ( macroMode == 1 ) {
97 SEND_STRING(SS_LGUI("c"));
98 } else {
99 SEND_STRING(SS_LCTL("c"));
100 }
101 }
102 return false;
103 case M_PASTE:
104 if (record->event.pressed) {
105 if ( macroMode == 1 ) {
106 if ( get_mods() & MOD_MASK_SHIFT ) {
107 SEND_STRING(SS_LSFT(SS_LALT(SS_LGUI("v"))));
108 } else {
109 SEND_STRING(SS_LGUI("v"));
110 }
111 } else {
112 SEND_STRING(SS_LCTL("v"));
113 }
114 }
115 return false;
116 case M_MDSWP:
117 if (record->event.pressed) {
118 macroMode ^= 1;
119 }
120 return false;
121 case KC_1 ... KC_0:
122 if (record->event.pressed) {
123 if (get_mods() & MOD_MASK_RALT) {
124 register_code(keycode + 0x3B);
125 } else {
126 register_code(keycode);
127 }
128 } else {
129 if (get_mods() & MOD_MASK_RALT) {
130 unregister_code(keycode + 0x3B);
131 } else {
132 unregister_code(keycode);
133 }
134 }
135 return false;
136 case KC_F1 ... KC_F12:
137 if (record->event.pressed) {
138 if (get_mods() & MOD_MASK_RALT) {
139 register_code(keycode + 0x2E);
140 } else {
141 register_code(keycode);
142 }
143 } else {
144 if (get_mods() & MOD_MASK_RALT) {
145 unregister_code(keycode + 0x2E);
146 } else {
147 unregister_code(keycode);
148 }
149 }
150 return false;
151 } // switch()
152 return true;
153};