diff options
Diffstat (limited to 'users/ericgebhart/process_records.c')
-rwxr-xr-x | users/ericgebhart/process_records.c | 255 |
1 files changed, 255 insertions, 0 deletions
diff --git a/users/ericgebhart/process_records.c b/users/ericgebhart/process_records.c new file mode 100755 index 000000000..c1036c7f0 --- /dev/null +++ b/users/ericgebhart/process_records.c | |||
@@ -0,0 +1,255 @@ | |||
1 | /* | ||
2 | Copyright 2018 Eric Gebhart <e.a.gebhart@gmail.com> | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | #include "ericgebhart.h" | ||
18 | #include "caps_word.h" | ||
19 | #include "g/keymap_combo.h" | ||
20 | |||
21 | __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } | ||
22 | |||
23 | __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; } | ||
24 | |||
25 | |||
26 | uint16_t tap_taplong_timer; | ||
27 | |||
28 | inline void tap_taplong(uint16_t kc1, uint16_t kc2, keyrecord_t *record) { | ||
29 | if (record->event.pressed) { | ||
30 | tap_taplong_timer = timer_read(); | ||
31 | } else { | ||
32 | if (timer_elapsed(tap_taplong_timer) > TAPPING_TERM) { | ||
33 | tap_code16(kc2); | ||
34 | } else { | ||
35 | tap_code16(kc1); | ||
36 | } | ||
37 | } | ||
38 | } | ||
39 | |||
40 | /* for (){}[]""''<>``. tap for open. Hold for open and close, ending inbetween. */ | ||
41 | /* Assumes a one character length. */ | ||
42 | inline void open_openclose(uint16_t kc1, uint16_t kc2, keyrecord_t *record) { | ||
43 | if (record->event.pressed) { | ||
44 | tap_taplong_timer = timer_read(); | ||
45 | }else{ | ||
46 | if (timer_elapsed(tap_taplong_timer) > TAPPING_TERM) { | ||
47 | tap_code16(kc1); | ||
48 | tap_code16(kc2); | ||
49 | tap_code16(KC_LEFT); | ||
50 | } else { | ||
51 | tap_code16(kc1); | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | // Defines actions for my global custom keycodes. Defined in ericgebhart.h file | ||
57 | // Then runs the _keymap's record handier if not processed here | ||
58 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
59 | // If console is enabled, it will print the matrix position and status of each key pressed | ||
60 | |||
61 | #ifdef OLED_ENABLE | ||
62 | process_record_user_oled(keycode, record); | ||
63 | #endif // OLED | ||
64 | |||
65 | if (!process_caps_word(keycode, record)) { return false; } | ||
66 | |||
67 | if (process_record_keymap(keycode, record) && process_record_secrets(keycode, record)) { | ||
68 | switch (keycode) { | ||
69 | |||
70 | // Handle the key translations for Dvorak on bepo. It's best if these are the first | ||
71 | // enums after SAFE_RANGE. | ||
72 | case DB_1 ... BB_QUOT: | ||
73 | if(record->event.pressed) | ||
74 | send_keycode(keycode); | ||
75 | unregister_code(keycode); | ||
76 | break; | ||
77 | |||
78 | // Set the default layer. eeprom if shifted. | ||
79 | case KC_DVORAK ... KC_BEPO: | ||
80 | if (record->event.pressed) { | ||
81 | uint8_t mods = mod_config(get_mods() | get_oneshot_mods()); | ||
82 | if (!mods) { | ||
83 | default_layer_set(1UL << (keycode - KC_DVORAK)); | ||
84 | } else if (mods & MOD_MASK_SHIFT) { | ||
85 | set_single_persistent_default_layer(1UL << (keycode - KC_DVORAK)); | ||
86 | } | ||
87 | } | ||
88 | break; | ||
89 | |||
90 | |||
91 | case KC_RESET: // Custom RESET code | ||
92 | if (!record->event.pressed) { | ||
93 | reset_keyboard(); | ||
94 | } | ||
95 | return false; | ||
96 | break; | ||
97 | |||
98 | case KC_SPACETEST: // test something. | ||
99 | // default_layer_set(1UL << _BEAKL); | ||
100 | // tap_code16(LSFT(KC_SPACE)); | ||
101 | break; | ||
102 | |||
103 | |||
104 | // tap or long tap for different key. | ||
105 | case KC_CCCV: // One key copy/paste | ||
106 | tap_taplong(LCTL(KC_C), LCTL(KC_V), record); | ||
107 | break; | ||
108 | |||
109 | case BP_CCCV: // One key copy/paste | ||
110 | tap_taplong(LCTL(BP_C), LCTL(BP_V), record); | ||
111 | break; | ||
112 | |||
113 | case KC_CTCN: // New TaB/Window | ||
114 | tap_taplong(LCTL(KC_T), LCTL(KC_N), record); | ||
115 | break; | ||
116 | |||
117 | case BP_CTCN: // New TaB/Window | ||
118 | tap_taplong(LCTL(BP_T), LCTL(BP_N), record); | ||
119 | break; | ||
120 | |||
121 | case KC_CWCQ: // Close Tab-window/Quit | ||
122 | tap_taplong(LCTL(KC_W), LCTL(KC_Q), record); | ||
123 | break; | ||
124 | |||
125 | case BP_CWCQ: // Close Tab-window/Quit | ||
126 | tap_taplong(LCTL(BP_W), LCTL(BP_Q), record); | ||
127 | break; | ||
128 | |||
129 | case KC_XM_PORD: // Xmonad scratch pads or desktop | ||
130 | tap_taplong(LGUI(KC_E), LGUI(KC_T), record); | ||
131 | break; | ||
132 | |||
133 | case BP_XM_PORD: // Xmonad scratch pads or desktop | ||
134 | tap_taplong(LGUI(BP_E), LGUI(BP_T), record); | ||
135 | break; | ||
136 | |||
137 | |||
138 | // Open on tap and Open with close and back arrow on hold. | ||
139 | case KC_OCPRN: | ||
140 | open_openclose(KC_LPRN, KC_RPRN, record); | ||
141 | break; | ||
142 | |||
143 | case BP_OCPRN: | ||
144 | open_openclose(DB_LPRN, DB_RPRN, record); | ||
145 | break; | ||
146 | |||
147 | case KC_OCBRC: | ||
148 | open_openclose(KC_LBRC, KC_RBRC, record); | ||
149 | break; | ||
150 | |||
151 | case BP_OCBRC: | ||
152 | open_openclose(KC_RBRC, KC_LBRC, record); | ||
153 | break; | ||
154 | |||
155 | case KC_OCCBR: | ||
156 | open_openclose(KC_LCBR, KC_RCBR, record); | ||
157 | break; | ||
158 | |||
159 | case BP_OCCBR: | ||
160 | open_openclose(BP_LCBR, BP_RCBR, record); | ||
161 | break; | ||
162 | |||
163 | case KC_OCDQUO: | ||
164 | open_openclose(KC_DQUO, KC_DQUO, record); | ||
165 | break; | ||
166 | |||
167 | case BP_OCDQUO: | ||
168 | open_openclose(BP_DQUO, BP_DQUO, record); | ||
169 | break; | ||
170 | |||
171 | case KC_OCQUOT: | ||
172 | open_openclose(KC_QUOT, KC_QUOT, record); | ||
173 | break; | ||
174 | |||
175 | case BP_OCQUOT: | ||
176 | open_openclose(BP_QUOT, BP_QUOT, record); | ||
177 | break; | ||
178 | |||
179 | case KC_OCGRV: | ||
180 | open_openclose(KC_GRAVE, KC_GRAVE, record); | ||
181 | break; | ||
182 | |||
183 | case BP_OCGRV: | ||
184 | open_openclose(BP_GRV, BP_GRV, record); | ||
185 | break; | ||
186 | |||
187 | case KC_OCLTGT: | ||
188 | open_openclose(KC_LT, KC_GT, record); | ||
189 | break; | ||
190 | |||
191 | case BP_OCLTGT: | ||
192 | open_openclose(BP_LDAQ, BP_RDAQ, record); | ||
193 | break; | ||
194 | |||
195 | |||
196 | //Turn shift backspace into delete. | ||
197 | /* case KC_BSPC: */ | ||
198 | /* { */ | ||
199 | /* // Initialize a boolean variable that keeps track */ | ||
200 | /* // of the delete key status: registered or not? */ | ||
201 | /* static bool delkey_registered; */ | ||
202 | /* if (record->event.pressed) { */ | ||
203 | /* uint8_t mod_state = get_mods(); */ | ||
204 | /* // Detect the activation of either shift keys */ | ||
205 | /* if (mod_state & MOD_MASK_SHIFT) { */ | ||
206 | /* // First temporarily canceling both shifts so that */ | ||
207 | /* // shift isn't applied to the KC_DEL keycode */ | ||
208 | /* del_mods(MOD_MASK_SHIFT); */ | ||
209 | /* register_code(KC_DEL); */ | ||
210 | /* // Update the boolean variable to reflect the status of KC_DEL */ | ||
211 | /* delkey_registered = true; */ | ||
212 | /* // Reapplying modifier state so that the held shift key(s) */ | ||
213 | /* // still work even after having tapped the Backspace/Delete key. */ | ||
214 | /* set_mods(mod_state); */ | ||
215 | /* return false; */ | ||
216 | /* } */ | ||
217 | /* } else { // on release of KC_BSPC */ | ||
218 | /* // In case KC_DEL is still being sent even after the release of KC_BSPC */ | ||
219 | /* if (delkey_registered) { */ | ||
220 | /* unregister_code(KC_DEL); */ | ||
221 | /* delkey_registered = false; */ | ||
222 | /* return false; */ | ||
223 | /* } */ | ||
224 | /* } */ | ||
225 | /* // Let QMK process the KC_BSPC keycode as usual outside of shift */ | ||
226 | /* return true; */ | ||
227 | /* } */ | ||
228 | |||
229 | |||
230 | #ifdef UNICODE_ENABLE | ||
231 | case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ | ||
232 | if (record->event.pressed) { | ||
233 | send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); | ||
234 | } | ||
235 | break; | ||
236 | case UC_TABL: // ┬─┬ノ( º _ ºノ) | ||
237 | if (record->event.pressed) { | ||
238 | send_unicode_string("┬─┬ノ( º _ ºノ)"); | ||
239 | } | ||
240 | break; | ||
241 | case UC_SHRG: // ¯\_(ツ)_/¯ | ||
242 | if (record->event.pressed) { | ||
243 | send_unicode_string("¯\\_(ツ)_/¯"); | ||
244 | } | ||
245 | break; | ||
246 | case UC_DISA: // ಠ_ಠ | ||
247 | if (record->event.pressed) { | ||
248 | send_unicode_string("ಠ_ಠ"); | ||
249 | } | ||
250 | break; | ||
251 | #endif | ||
252 | } | ||
253 | } | ||
254 | return true; | ||
255 | } | ||