13 #ifdef RGBLIGHT_ENABLE
26 // Enabled by adding a non-tracked secrets.h to this dir.
27 #if (__has_include("secrets.h"))
35 float tone_game[][2] = SONG(ZELDA_PUZZLE);
36 float tone_return[][2] = SONG(ZELDA_TREASURE);
37 float tone_linux[][2] = SONG(UNICODE_LINUX);
38 float tone_windows[][2] = SONG(UNICODE_WINDOWS);
41 /*-------------------*\
42 |*-----TAP-DANCE-----*|
43 \*-------------------*/
44 #ifdef TAP_DANCE_ENABLE
45 qk_tap_dance_action_t tap_dance_actions[] = {
46 // Shift on double tap of semicolon
47 [SCL] = ACTION_TAP_DANCE_DOUBLE( KC_SCLN, KC_COLN )
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
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) {
62 __attribute__ ((weak)) uint32_t layer_state_set_keymap (uint32_t state) {
65 __attribute__ ((weak)) void led_set_keymap(uint8_t usb_led) { }
67 /* ----------------------- *\
68 * -----RGB Functions----- *
69 \* ----------------------- */
70 #ifdef RGBLIGHT_ENABLE
72 extern rgblight_config_t rgblight_config;
73 bool base_sta; // Keeps track if in saveable state
74 bool base_tog; // Whether base state is active or not
75 int base_hue; // Hue value of base state
76 int base_sat; // Saturation value of base state
77 int base_val; // Brightness value of base state
78 uint8_t base_mod; // Animation mode of the base state
80 // Save the current state of the rgb mode
81 void rgblight_saveBase(void) {
82 base_hue = rgblight_config.hue;
83 base_sat = rgblight_config.sat;
84 base_val = rgblight_config.val;
85 base_mod = rgblight_config.mode;
86 base_tog = rgblight_config.enable;
87 base_sta = false; // If saving, that means base layer is being left
90 // Load the base state back
91 void rgblight_loadBase(void) {
92 // Don't do anything if not enabled
96 rgblight_mode( base_mod );
97 rgblight_sethsv( base_hue, base_sat, base_val );
102 // Mark that base is loaded, and to be saved before leaving
106 // Set to plain HSV color
107 void rgblight_colorStatic( int hu, int sa, int va ) {
108 // First, it must be enabled or color change is not written
111 rgblight_sethsv(hu,sa,va);
116 * coral ( 16, 176, 255)
117 * orange ( 39, 255, 255)
118 * goldenrod ( 43, 218, 218)
119 * gold ( 51, 255, 255)
120 * yellow ( 60, 255, 255)
121 * chartreuse ( 90, 255, 255)
122 * green (120, 255, 255)
123 * springgreen (150, 255, 255)
124 * turquoise (174, 90, 112)
125 * teal (180, 255, 128)
126 * cyan (180, 255, 255)
127 * azure (186, 102, 255)
128 * blue (240, 255, 255)
129 * purple (270, 255, 255)
130 * magenta (300, 255, 255)
131 * pink (330, 128, 255)
134 // Set RGBLIGHT state depending on layer
135 void rgblight_change( uint8_t this_layer ) {
136 // Save state, if saving is requested
141 switch ( this_layer ) {
147 // Do yellow for alternate
148 rgblight_colorStatic( 60,255,255);
151 // Do purple for game
152 rgblight_colorStatic(285,255,255);
155 // Do azure for number
156 rgblight_colorStatic(186,200,255);
159 // Do red for settings
160 rgblight_colorStatic( 16,255,255);
163 // Do green for mouse
164 rgblight_colorStatic(120,255,255);
167 // Do orange for music
168 rgblight_colorStatic( 39,255,255);
171 // Something went wrong
172 rgblight_colorStatic( 0,255,255);
179 /*---------------------*\
180 |*-----MATRIX INIT-----*|
181 \*---------------------*/
182 void matrix_init_user (void) {
184 // Keymap specific things, do it first thing to allow for delays etc
185 matrix_init_keymap();
188 #ifdef UNICODE_ENABLE
189 set_unicode_input_mode(UC_LNX);
192 // Make beginning layer DVORAK
193 set_single_persistent_default_layer(_DV);
195 //--RGB light initialize base layer
196 #ifdef RGBLIGHT_ENABLE
197 // Base hue is white, and RGB disabled
204 rgblight_mode(base_mod);
205 rgblight_sethsv(base_hue,base_sat,base_val);
212 /*---------------------*\
213 |*-----MATRIX SCAN-----*|
214 \*---------------------*/
215 void matrix_scan_user (void) {
216 // Keymap specific, do it first
217 matrix_scan_keymap();
220 /*------------------*\
221 |*-----KEYCODES-----*|
222 \*------------------*/
223 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
226 bool is_capital = ( keyboard_report->mods & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)) );
227 static bool lock_flag = false;
228 uint8_t layer = biton32 (layer_state);
231 // Secrets implementation
232 #if (__has_include("secrets.h"))
234 if( !record->event.pressed ) {
235 send_string_P( secret[ keycode - SECRET1 ] );
240 if( !record->event.pressed ) {
241 send_string_P( secret[ keycode - SECRET2 ] );
246 if( !record->event.pressed ) {
247 send_string_P( secret[ keycode - SECRET3 ] );
253 // If these keys are pressed, load base layer config, and mark saving
254 #ifdef RGBLIGHT_ENABLE
270 // Lock functionality: These layers are locked if the LOCKED buttons are
271 // pressed. Otherwise, they are momentary toggles
273 if (record->event.pressed) {
274 lock_flag = !lock_flag;
279 if (record->event.pressed) {
292 if (record->event.pressed) {
305 // Layer switches with sound
307 if (record->event.pressed) {
308 // On press, turn off layer if active
309 if ( layer == _GA ) {
312 PLAY_SONG(tone_return);
317 // After click, turn on layer if accessed from setting
318 if ( layer == _SE ) {
321 PLAY_SONG(tone_game);
330 if (record->event.pressed) {
331 // On press, turn off layer if active
332 if ( layer == _SE ) {
343 // Unicode switches with sound
344 #ifdef UNICODE_ENABLE
346 if (record->event.pressed) {
349 PLAY_SONG(tone_linux);
351 set_unicode_input_mode(UC_LNX);
356 if (record->event.pressed) {
359 PLAY_SONG(tone_windows);
361 set_unicode_input_mode(UC_WIN);
366 // Turkish letters, with capital functionality
368 if (record->event.pressed) {
370 unicode_input_start();
371 register_hex(0x00c2);
372 unicode_input_finish();
374 unicode_input_start();
375 register_hex(0x00e2);
376 unicode_input_finish();
382 if (record->event.pressed) {
384 unicode_input_start();
385 register_hex(0x00d6);
386 unicode_input_finish();
388 unicode_input_start();
389 register_hex(0x00f6);
390 unicode_input_finish();
396 if (record->event.pressed) {
398 unicode_input_start();
399 register_hex(0x00dc);
400 unicode_input_finish();
402 unicode_input_start();
403 register_hex(0x00fc);
404 unicode_input_finish();
410 if (record->event.pressed) {
412 unicode_input_start();
413 register_hex(0x0130);
414 unicode_input_finish();
416 unicode_input_start();
417 register_hex(0x0131);
418 unicode_input_finish();
424 if (record->event.pressed) {
426 unicode_input_start();
427 register_hex(0x011e);
428 unicode_input_finish();
430 unicode_input_start();
431 register_hex(0x011f);
432 unicode_input_finish();
438 if (record->event.pressed) {
440 unicode_input_start();
441 register_hex(0x00c7);
442 unicode_input_finish();
444 unicode_input_start();
445 register_hex(0x00e7);
446 unicode_input_finish();
452 if (record->event.pressed) {
454 unicode_input_start();
455 register_hex(0x015e);
456 unicode_input_finish();
458 unicode_input_start();
459 register_hex(0x015f);
460 unicode_input_finish();
467 //-------Diagonal mouse movements
468 #ifdef MOUSEKEY_ENABLE
470 if( record->event.pressed ) {
482 if( record->event.pressed ) {
494 if( record->event.pressed ) {
506 if( record->event.pressed ) {
518 if( record->event.pressed ) {
523 mousekey_off(MO_S_N);
524 mousekey_off(MO_S_E);
530 if( record->event.pressed ) {
535 mousekey_off(MO_S_N);
536 mousekey_off(MO_S_W);
542 if( record->event.pressed ) {
547 mousekey_off(MO_S_S);
548 mousekey_off(MO_S_E);
554 if( record->event.pressed ) {
559 mousekey_off(MO_S_S);
560 mousekey_off(MO_S_W);
567 //------DOUBLE PRESS, with added left navigation
569 if( record->event.pressed ) {
570 SEND_STRING(" "SS_TAP(X_LEFT));
575 if( record->event.pressed ) {
576 SEND_STRING("<>"SS_TAP(X_LEFT));
581 if( record->event.pressed ) {
582 SEND_STRING("()"SS_TAP(X_LEFT));
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));
618 return process_record_keymap(keycode, record);
621 /*----------------------*\
622 |*-----LAYER CHANGE-----*|
623 \*----------------------*/
625 uint32_t layer_state_set_user(uint32_t state) {
627 state = layer_state_set_keymap (state);
628 #ifdef RGBLIGHT_ENABLE
629 // Change RGB lighting depending on the last layer activated
630 rgblight_change( biton32(state) );