aboutsummaryrefslogtreecommitdiff
path: root/users/romus/romus.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/romus/romus.c')
-rw-r--r--users/romus/romus.c557
1 files changed, 557 insertions, 0 deletions
diff --git a/users/romus/romus.c b/users/romus/romus.c
new file mode 100644
index 000000000..35b524f94
--- /dev/null
+++ b/users/romus/romus.c
@@ -0,0 +1,557 @@
1#include "romus.h"
2
3/*---------------*\
4|*-----MOUSE-----*|
5\*---------------*/
6#ifdef MOUSEKEY_ENABLE
7#include "mousekey.h"
8#endif
9
10/*-------------*\
11|*-----RGB-----*|
12\*-------------*/
13#ifdef RGBLIGHT_ENABLE
14#include "rgblight.h"
15#endif
16
17/*-------------*\
18|*---UNICODE---*|
19\*-------------*/
20#ifdef UNICODE_ENABLE
21#endif
22
23/*-----------------*\
24|*-----SECRETS-----*|
25\*-----------------*/
26// Enabled by adding a non-tracked secrets.h to this dir.
27#if (__has_include("secrets.h"))
28#include "secrets.h"
29#endif
30
31/*---------------*\
32|*-----MUSIC-----*|
33\*---------------*/
34#ifdef AUDIO_ENABLE
35float tone_game[][2] = SONG(ZELDA_PUZZLE);
36float tone_return[][2] = SONG(ZELDA_TREASURE);
37float tone_linux[][2] = SONG(UNICODE_LINUX);
38float tone_windows[][2] = SONG(UNICODE_WINDOWS);
39#endif
40
41/*-------------------*\
42|*-----TAP-DANCE-----*|
43\*-------------------*/
44#ifdef TAP_DANCE_ENABLE
45qk_tap_dance_action_t tap_dance_actions[] = {
46 // Shift on double tap of semicolon
47 [SCL] = ACTION_TAP_DANCE_DOUBLE( KC_SCLN, KC_COLN )
48};
49#endif
50
51/* In keymaps, instead of writing _user functions, write _keymap functions
52 * The __attribute__((weak)) allows for empty definitions here, and during
53 * compilation, if these functions are defined elsewhere, they are written
54 * over. This allows to include custom code from keymaps in the generic code
55 * in this file.
56 */
57__attribute__ ((weak)) void matrix_init_keymap(void) { }
58__attribute__ ((weak)) void matrix_scan_keymap(void) { }
59__attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
60 return true;
61}
62__attribute__ ((weak)) uint32_t layer_state_set_keymap (uint32_t state) {
63 return state;
64}
65__attribute__ ((weak)) void led_set_keymap(uint8_t usb_led) { }
66
67/* ----------------------- *\
68 * -----RGB Functions----- *
69\* ----------------------- */
70#ifdef RGBLIGHT_ENABLE
71
72// Set RGBLIGHT state depending on layer
73void rgblight_change( uint8_t this_layer ) {
74 // Enable RGB light; will not work without this
75 //rgblight_enable_noeeprom();
76 // Change RGB light
77 switch ( this_layer ) {
78 case _DV:
79 // Load base layer
80 rgblight_disable_noeeprom();
81 break;
82 case _AL:
83 // Do yellow for alternate
84 rgblight_enable_noeeprom();
85 rgblight_sethsv_noeeprom( 60,255,255);
86
87
88 break;
89 case _GA:
90 // Do purple for game
91 rgblight_enable_noeeprom();
92 rgblight_sethsv_noeeprom(285,255,255);
93
94
95 break;
96 case _NU:
97 // Do azure for number
98 rgblight_enable_noeeprom();
99 rgblight_sethsv_noeeprom(186,200,255);
100
101
102 break;
103 case _SE:
104 // Do red for settings
105 rgblight_enable_noeeprom();
106
107 rgblight_sethsv_noeeprom( 16,255,255);
108
109 break;
110 case _MO:
111 // Do green for mouse
112 rgblight_enable_noeeprom();
113 rgblight_sethsv_noeeprom(120,255,255);
114
115
116 break;
117 case _MU:
118 // Do orange for music
119
120 rgblight_enable_noeeprom();
121 rgblight_sethsv_noeeprom( 39,255,255);
122
123 break;
124 default:
125 // Something went wrong
126 rgblight_enable_noeeprom();
127 rgblight_sethsv_noeeprom( 0,255,255);
128
129 break;
130 }
131}
132
133#endif
134
135/*---------------------*\
136|*-----MATRIX INIT-----*|
137\*---------------------*/
138void matrix_init_user (void) {
139
140 // Keymap specific things, do it first thing to allow for delays etc
141 matrix_init_keymap();
142
143 // Correct unicode
144#ifdef UNICODE_ENABLE
145 set_unicode_input_mode(UC_LNX);
146#endif
147
148 // Make beginning layer DVORAK
149 set_single_persistent_default_layer(_DV);
150
151}
152
153/*---------------------*\
154|*-----MATRIX SCAN-----*|
155\*---------------------*/
156void matrix_scan_user (void) {
157 // Keymap specific, do it first
158 matrix_scan_keymap();
159}
160
161/*------------------*\
162|*-----KEYCODES-----*|
163\*------------------*/
164bool process_record_user(uint16_t keycode, keyrecord_t *record) {
165
166 // Shift check
167 bool is_capital = ( keyboard_report->mods & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)) );
168 static bool lock_flag = false;
169 uint8_t layer = biton32 (layer_state);
170
171 switch (keycode) {
172 // Secrets implementation
173#if (__has_include("secrets.h"))
174 case SECRET1:
175 if( !record->event.pressed ) {
176 send_string_P( secret[ keycode - SECRET1 ] );
177 }
178 return false;
179 break;
180 case SECRET2:
181 if( !record->event.pressed ) {
182 send_string_P( secret[ keycode - SECRET2 ] );
183 }
184 return false;
185 break;
186 case SECRET3:
187 if( !record->event.pressed ) {
188 send_string_P( secret[ keycode - SECRET3 ] );
189 }
190 return false;
191 break;
192#endif
193
194 // Lock functionality: These layers are locked if the LOCKED buttons are
195 // pressed. Otherwise, they are momentary toggles
196 case K_LOCK:
197 if (record->event.pressed) {
198 lock_flag = !lock_flag;
199 }
200 return false;
201 break;
202 case K_MOUSE:
203 if (record->event.pressed) {
204 layer_on(_MO);
205 lock_flag = false;
206 } else {
207 if ( lock_flag ) {
208 lock_flag = false;
209 } else {
210 layer_off(_MO);
211 }
212 }
213 return false;
214 break;
215 case K_NUMBR:
216 if (record->event.pressed) {
217 layer_on(_NU);
218 lock_flag = false;
219 } else {
220 if ( lock_flag ) {
221 lock_flag = false;
222 } else {
223 layer_off(_NU);
224 }
225 }
226 return false;
227 break;
228
229 // Layer switches with sound
230 case K_GAMES:
231 if (record->event.pressed) {
232 // On press, turn off layer if active
233 if ( layer == _GA ) {
234#ifdef AUDIO_ENABLE
235 stop_all_notes();
236 PLAY_SONG(tone_return);
237#endif
238 layer_off(_GA);
239 }
240 } else {
241 // After click, turn on layer if accessed from setting
242 if ( layer == _SE ) {
243#ifdef AUDIO_ENABLE
244 stop_all_notes();
245 PLAY_SONG(tone_game);
246#endif
247 layer_on(_GA);
248 layer_off(_SE);
249 }
250 }
251 return false;
252 break;
253 case MU_TOG:
254 if (record->event.pressed) {
255 // On press, turn off layer if active
256 if ( layer == _SE ) {
257 layer_off(_SE);
258 layer_on(_MU);
259 } else {
260 layer_off(_MU);
261 }
262 }
263 return true;
264 break;
265
266//------UNICODE
267 // Unicode switches with sound
268#ifdef UNICODE_ENABLE
269 case UNI_LI:
270 if (record->event.pressed) {
271#ifdef AUDIO_ENABLE
272 stop_all_notes();
273 PLAY_SONG(tone_linux);
274#endif
275 set_unicode_input_mode(UC_LNX);
276 }
277 return false;
278 break;
279 case UNI_WN:
280 if (record->event.pressed) {
281#ifdef AUDIO_ENABLE
282 stop_all_notes();
283 PLAY_SONG(tone_windows);
284#endif
285 set_unicode_input_mode(UC_WIN);
286 }
287 return false;
288 break;
289
290 // Turkish letters, with capital functionality
291 case TUR_A:
292 if (record->event.pressed) {
293 if ( is_capital ) {
294 unicode_input_start();
295 register_hex(0x00c2);
296 unicode_input_finish();
297 } else {
298 unicode_input_start();
299 register_hex(0x00e2);
300 unicode_input_finish();
301 }
302 }
303 return false;
304 break;
305 case TUR_O:
306 if (record->event.pressed) {
307 if ( is_capital ) {
308 unicode_input_start();
309 register_hex(0x00d6);
310 unicode_input_finish();
311 } else {
312 unicode_input_start();
313 register_hex(0x00f6);
314 unicode_input_finish();
315 }
316 }
317 return false;
318 break;
319 case TUR_U:
320 if (record->event.pressed) {
321 if ( is_capital ) {
322 unicode_input_start();
323 register_hex(0x00dc);
324 unicode_input_finish();
325 } else {
326 unicode_input_start();
327 register_hex(0x00fc);
328 unicode_input_finish();
329 }
330 }
331 return false;
332 break;
333 case TUR_I:
334 if (record->event.pressed) {
335 if ( is_capital ) {
336 unicode_input_start();
337 register_hex(0x0130);
338 unicode_input_finish();
339 } else {
340 unicode_input_start();
341 register_hex(0x0131);
342 unicode_input_finish();
343 }
344 }
345 return false;
346 break;
347 case TUR_G:
348 if (record->event.pressed) {
349 if ( is_capital ) {
350 unicode_input_start();
351 register_hex(0x011e);
352 unicode_input_finish();
353 } else {
354 unicode_input_start();
355 register_hex(0x011f);
356 unicode_input_finish();
357 }
358 }
359 return false;
360 break;
361 case TUR_C:
362 if (record->event.pressed) {
363 if ( is_capital ) {
364 unicode_input_start();
365 register_hex(0x00c7);
366 unicode_input_finish();
367 } else {
368 unicode_input_start();
369 register_hex(0x00e7);
370 unicode_input_finish();
371 }
372 }
373 return false;
374 break;
375 case TUR_S:
376 if (record->event.pressed) {
377 if ( is_capital ) {
378 unicode_input_start();
379 register_hex(0x015e);
380 unicode_input_finish();
381 } else {
382 unicode_input_start();
383 register_hex(0x015f);
384 unicode_input_finish();
385 }
386 }
387 return false;
388 break;
389#endif
390
391//-------Diagonal mouse movements
392#ifdef MOUSEKEY_ENABLE
393 case MO_NE:
394 if( record->event.pressed ) {
395 mousekey_on(MO_N);
396 mousekey_on(MO_E);
397 mousekey_send();
398 } else {
399 mousekey_off(MO_N);
400 mousekey_off(MO_E);
401 mousekey_send();
402 }
403 return false;
404 break;
405 case MO_NW:
406 if( record->event.pressed ) {
407 mousekey_on(MO_N);
408 mousekey_on(MO_W);
409 mousekey_send();
410 } else {
411 mousekey_off(MO_N);
412 mousekey_off(MO_W);
413 mousekey_send();
414 }
415 return false;
416 break;
417 case MO_SE:
418 if( record->event.pressed ) {
419 mousekey_on(MO_S);
420 mousekey_on(MO_E);
421 mousekey_send();
422 } else {
423 mousekey_off(MO_S);
424 mousekey_off(MO_E);
425 mousekey_send();
426 }
427 return false;
428 break;
429 case MO_SW:
430 if( record->event.pressed ) {
431 mousekey_on(MO_S);
432 mousekey_on(MO_W);
433 mousekey_send();
434 } else {
435 mousekey_off(MO_S);
436 mousekey_off(MO_W);
437 mousekey_send();
438 }
439 return false;
440 break;
441 case MO_S_NE:
442 if( record->event.pressed ) {
443 mousekey_on(MO_S_N);
444 mousekey_on(MO_S_E);
445 mousekey_send();
446 } else {
447 mousekey_off(MO_S_N);
448 mousekey_off(MO_S_E);
449 mousekey_send();
450 }
451 return false;
452 break;
453 case MO_S_NW:
454 if( record->event.pressed ) {
455 mousekey_on(MO_S_N);
456 mousekey_on(MO_S_W);
457 mousekey_send();
458 } else {
459 mousekey_off(MO_S_N);
460 mousekey_off(MO_S_W);
461 mousekey_send();
462 }
463 return false;
464 break;
465 case MO_S_SE:
466 if( record->event.pressed ) {
467 mousekey_on(MO_S_S);
468 mousekey_on(MO_S_E);
469 mousekey_send();
470 } else {
471 mousekey_off(MO_S_S);
472 mousekey_off(MO_S_E);
473 mousekey_send();
474 }
475 return false;
476 break;
477 case MO_S_SW:
478 if( record->event.pressed ) {
479 mousekey_on(MO_S_S);
480 mousekey_on(MO_S_W);
481 mousekey_send();
482 } else {
483 mousekey_off(MO_S_S);
484 mousekey_off(MO_S_W);
485 mousekey_send();
486 }
487 return false;
488 break;
489#endif
490
491//------DOUBLE PRESS, with added left navigation
492 case DBL_SPC:
493 if( record->event.pressed ) {
494 SEND_STRING(" "SS_TAP(X_LEFT));
495 }
496 return false;
497 break;
498 case DBL_ANG:
499 if( record->event.pressed ) {
500 SEND_STRING("<>"SS_TAP(X_LEFT));
501 }
502 return false;
503 break;
504 case DBL_PAR:
505 if( record->event.pressed ) {
506 SEND_STRING("()"SS_TAP(X_LEFT));
507 }
508 return false;
509 break;
510 case DBL_SQR:
511 if( record->event.pressed ) {
512 SEND_STRING("[]"SS_TAP(X_LEFT));
513 }
514 return false;
515 break;
516 case DBL_BRC:
517 if( record->event.pressed ) {
518 SEND_STRING("{}"SS_TAP(X_LEFT));
519 }
520 return false;
521 break;
522 case DBL_QUO:
523 if( record->event.pressed ) {
524 SEND_STRING("\'\'"SS_TAP(X_LEFT));
525 }
526 return false;
527 break;
528 case DBL_DQT:
529 if( record->event.pressed ) {
530 SEND_STRING("\"\""SS_TAP(X_LEFT));
531 }
532 return false;
533 break;
534 case DBL_GRV:
535 if( record->event.pressed ) {
536 SEND_STRING("``"SS_TAP(X_LEFT));
537 }
538 return false;
539 break;
540// END OF KEYCODES
541 }
542 return process_record_keymap(keycode, record);
543}
544
545/*----------------------*\
546|*-----LAYER CHANGE-----*|
547\*----------------------*/
548
549uint32_t layer_state_set_user(uint32_t state) {
550
551 state = layer_state_set_keymap (state);
552#ifdef RGBLIGHT_ENABLE
553 // Change RGB lighting depending on the last layer activated
554 rgblight_change( biton32(state) );
555#endif
556 return state;
557} \ No newline at end of file