13 #ifdef RGBLIGHT_ENABLE
20 // Enabled by adding a non-tracked secrets.h to this dir.
21 #if (__has_include("secrets.h"))
29 float tone_game[][2] = SONG(ZELDA_PUZZLE);
30 float tone_return[][2] = SONG(ZELDA_TREASURE);
31 float tone_linux[][2] = SONG(UNICODE_LINUX);
32 float tone_windows[][2] = SONG(UNICODE_WINDOWS);
35 /*-------------------*\
36 |*-----TAP-DANCE-----*|
37 \*-------------------*/
38 #ifdef TAP_DANCE_ENABLE
39 qk_tap_dance_action_t tap_dance_actions[] = {
40 // Shift on double tap of semicolon
41 [SCL] = ACTION_TAP_DANCE_DOUBLE( KC_SCLN, KC_COLN )
45 /* In keymaps, instead of writing _user functions, write _keymap functions
46 * The __attribute__((weak)) allows for empty definitions here, and during
47 * compilation, if these functions are defined elsewhere, they are written
48 * over. This allows to include custom code from keymaps in the generic code
51 __attribute__ ((weak)) void matrix_init_keymap(void) { }
52 __attribute__ ((weak)) void matrix_scan_keymap(void) { }
53 __attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
56 __attribute__ ((weak)) uint32_t layer_state_set_keymap (uint32_t state) {
59 __attribute__ ((weak)) void led_set_keymap(uint8_t usb_led) { }
61 /* ----------------------- *\
62 * -----RGB Functions----- *
63 \* ----------------------- */
66 #ifdef RGBLIGHT_ENABLE
68 extern rgblight_config_t rgblight_config;
69 bool base_sta; // Keeps track if in saveable state
70 bool base_tog; // Whether base state is active or not
71 int base_hue; // Hue value of base state
72 int base_sat; // Saturation value of base state
73 int base_val; // Brightness value of base state
74 uint8_t base_mod; // Animation mode of the base state
76 // Save the current state of the rgb mode
77 void rgblight_saveBase(void) {
78 base_hue = rgblight_config.hue;
79 base_sat = rgblight_config.sat;
80 base_val = rgblight_config.val;
81 base_mod = rgblight_config.mode;
82 base_tog = rgblight_config.enable;
83 base_sta = false; // If saving, that means base layer is being left
86 // Load the base state back
87 void rgblight_loadBase(void) {
88 // Don't do anything if not enabled
92 rgblight_mode( base_mod );
93 rgblight_sethsv( base_hue, base_sat, base_val );
98 // Mark that base is loaded, and to be saved before leaving
102 // Set to plain HSV color
103 void rgblight_colorStatic( int hu, int sa, int va ) {
104 // First, it must be enabled or color change is not written
107 rgblight_sethsv(hu,sa,va);
109 /* HSV values, thank you @drashna!
112 * coral ( 16, 176, 255)
113 * orange ( 39, 255, 255)
114 * goldenrod ( 43, 218, 218)
115 * gold ( 51, 255, 255)
116 * yellow ( 60, 255, 255)
117 * chartreuse ( 90, 255, 255)
118 * green (120, 255, 255)
119 * springgreen (150, 255, 255)
120 * turquoise (174, 90, 112)
121 * teal (180, 255, 128)
122 * cyan (180, 255, 255)
123 * azure (186, 102, 255)
124 * blue (240, 255, 255)
125 * purple (270, 255, 255)
126 * magenta (300, 255, 255)
127 * pink (330, 128, 255)
129 // Set RGBLIGHT state depending on layer
130 void rgblight_change( uint8_t last_layer ) {
131 // Save state, if saving is requested
138 switch ( last_layer ) {
144 // Do yellow for alternate
145 rgblight_colorStatic( 60,255,255);
148 // Do purple for game
149 rgblight_colorStatic(285,255,255);
152 // Do azure for number
153 rgblight_colorStatic(186,200,255);
156 // Do red for settings
157 rgblight_colorStatic( 16,255,255);
160 // Do green for mouse
161 rgblight_colorStatic(120,255,255);
165 // Do orange for music
166 rgblight_colorStatic( 39,255,255);
170 // Something went wrong
171 rgblight_colorStatic( 0,255,255);
178 /*---------------------*\
179 |*-----MATRIX INIT-----*|
180 \*---------------------*/
181 void matrix_init_user (void) {
183 // Keymap specific things, do it first thing to allow for delays etc
184 matrix_init_keymap();
187 set_unicode_input_mode(UC_LNX);
189 // Make beginning layer DVORAK
190 set_single_persistent_default_layer(_DV);
192 //--RGB light initialize base layer
193 #ifdef RGBLIGHT_ENABLE
194 // Base hue is white, and RGB disabled
201 rgblight_mode(base_mod);
202 rgblight_sethsv(base_hue,base_sat,base_val);
209 /*---------------------*\
210 |*-----MATRIX SCAN-----*|
211 \*---------------------*/
212 void matrix_scan_user (void) {
213 // Keymap specific, do it first
214 matrix_scan_keymap();
215 // Moved RGB check to layer_state_set_user
218 /*------------------*\
219 |*-----KEYCODES-----*|
220 \*------------------*/
221 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
224 bool is_capital = ( keyboard_report->mods & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)) );
225 static bool lock_flag = false;
226 uint8_t layer = biton32 (layer_state);
229 // Secrets implementation
230 case SECRET1 ... SECRET3:
231 #if (__has_include("secrets.h"))
232 if( !record->event.pressed ) {
233 send_string_P( secret[ keycode - SECRET1 ] );
238 // If these keys are pressed, load base layer config, and mark saving
247 #ifdef RGBLIGHT_ENABLE
255 // Lock functionality: These layers are locked if the LOCKED buttons are
256 // pressed. Otherwise, they are momentary toggles
258 if (record->event.pressed) {
259 lock_flag = !lock_flag;
264 #ifdef MOUSEKEY_ENABLE
265 if (record->event.pressed) {
279 if (record->event.pressed) {
292 // Layer switches with sound
294 if (record->event.pressed) {
295 // On press, turn off layer if active
296 if ( layer == _GA ) {
299 PLAY_SONG(tone_return);
304 // After click, turn on layer if accessed from setting
305 if ( layer == _SE ) {
308 PLAY_SONG(tone_game);
318 if (record->event.pressed) {
319 // On press, turn off layer if active
320 if ( layer == _SE ) {
332 // Unicode switches with sound
334 #ifdef UNICODE_ENABLE
335 if (record->event.pressed) {
338 PLAY_SONG(tone_linux);
340 set_unicode_input_mode(UC_LNX);
346 #ifdef UNICODE_ENABLE
347 if (record->event.pressed) {
350 PLAY_SONG(tone_windows);
352 set_unicode_input_mode(UC_WIN);
358 // Turkish letters, with capital functionality
360 #ifdef UNICODE_ENABLE
361 if (record->event.pressed) {
363 unicode_input_start();
364 register_hex(0x00c2);
365 unicode_input_finish();
367 unicode_input_start();
368 register_hex(0x00e2);
369 unicode_input_finish();
376 #ifdef UNICODE_ENABLE
377 if (record->event.pressed) {
379 unicode_input_start();
380 register_hex(0x00d6);
381 unicode_input_finish();
383 unicode_input_start();
384 register_hex(0x00f6);
385 unicode_input_finish();
392 #ifdef UNICODE_ENABLE
393 if (record->event.pressed) {
395 unicode_input_start();
396 register_hex(0x00dc);
397 unicode_input_finish();
399 unicode_input_start();
400 register_hex(0x00fc);
401 unicode_input_finish();
408 #ifdef UNICODE_ENABLE
409 if (record->event.pressed) {
411 unicode_input_start();
412 register_hex(0x0130);
413 unicode_input_finish();
415 unicode_input_start();
416 register_hex(0x0131);
417 unicode_input_finish();
424 #ifdef UNICODE_ENABLE
425 if (record->event.pressed) {
427 unicode_input_start();
428 register_hex(0x011e);
429 unicode_input_finish();
431 unicode_input_start();
432 register_hex(0x011f);
433 unicode_input_finish();
440 #ifdef UNICODE_ENABLE
441 if (record->event.pressed) {
443 unicode_input_start();
444 register_hex(0x00c7);
445 unicode_input_finish();
447 unicode_input_start();
448 register_hex(0x00e7);
449 unicode_input_finish();
456 #ifdef UNICODE_ENABLE
457 if (record->event.pressed) {
459 unicode_input_start();
460 register_hex(0x015e);
461 unicode_input_finish();
463 unicode_input_start();
464 register_hex(0x015f);
465 unicode_input_finish();
472 //-------Diagonal mouse movements
474 #ifdef MOUSEKEY_ENABLE
475 if( record->event.pressed ) {
488 #ifdef MOUSEKEY_ENABLE
489 if( record->event.pressed ) {
502 #ifdef MOUSEKEY_ENABLE
503 if( record->event.pressed ) {
516 #ifdef MOUSEKEY_ENABLE
517 if( record->event.pressed ) {
530 #ifdef MOUSEKEY_ENABLE
531 if( record->event.pressed ) {
536 mousekey_off(MO_S_N);
537 mousekey_off(MO_S_E);
544 #ifdef MOUSEKEY_ENABLE
545 if( record->event.pressed ) {
550 mousekey_off(MO_S_N);
551 mousekey_off(MO_S_W);
558 #ifdef MOUSEKEY_ENABLE
559 if( record->event.pressed ) {
564 mousekey_off(MO_S_S);
565 mousekey_off(MO_S_E);
572 #ifdef MOUSEKEY_ENABLE
573 if( record->event.pressed ) {
578 mousekey_off(MO_S_S);
579 mousekey_off(MO_S_W);
585 //------DOUBLE PRESS, with added left navigation
587 if( record->event.pressed ) {
588 SEND_STRING(" "SS_TAP(X_LEFT));
593 if( record->event.pressed ) {
594 SEND_STRING("<>"SS_TAP(X_LEFT));
599 if( record->event.pressed ) {
600 SEND_STRING("()"SS_TAP(X_LEFT));
605 if( record->event.pressed ) {
606 SEND_STRING("[]"SS_TAP(X_LEFT));
611 if( record->event.pressed ) {
612 SEND_STRING("{}"SS_TAP(X_LEFT));
617 if( record->event.pressed ) {
618 SEND_STRING("\'\'"SS_TAP(X_LEFT));
623 if( record->event.pressed ) {
624 SEND_STRING("\"\""SS_TAP(X_LEFT));
629 if( record->event.pressed ) {
630 SEND_STRING("``"SS_TAP(X_LEFT));
636 return process_record_keymap(keycode, record);
639 /*----------------------*\
640 |*-----LAYER CHANGE-----*|
641 \*----------------------*/
643 uint32_t layer_state_set_user(uint32_t state) {
645 state = layer_state_set_keymap (state);
646 #ifdef RGBLIGHT_ENABLE
647 // Change RGB lighting depending on the last layer activated
648 rgblight_change( biton32(state) );