1 /* Copyright 2016-2017 Jack Humbert
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.
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.
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/>.
21 # include "outputselect.h"
24 #ifdef BACKLIGHT_ENABLE
25 # include "backlight.h"
26 extern backlight_config_t backlight_config
;
29 #ifdef FAUXCLICKY_ENABLE
30 # include "fauxclicky.h"
38 # include "process_midi.h"
41 #ifdef VELOCIKEY_ENABLE
42 # include "velocikey.h"
55 # define GOODBYE_SONG SONG(GOODBYE_SOUND)
57 float goodbye_song
[][2] = GOODBYE_SONG
;
58 # ifdef DEFAULT_LAYER_SONGS
59 float default_layer_songs
[][16][2] = DEFAULT_LAYER_SONGS
;
61 # ifdef SENDSTRING_BELL
62 float bell_song
[][2] = SONG(TERMINAL_SOUND
);
66 static void do_code16(uint16_t code
, void (*f
)(uint8_t)) {
68 case QK_MODS
... QK_MODS_MAX
:
74 uint8_t mods_to_send
= 0;
76 if (code
& QK_RMODS_MIN
) { // Right mod flag is set
77 if (code
& QK_LCTL
) mods_to_send
|= MOD_BIT(KC_RCTL
);
78 if (code
& QK_LSFT
) mods_to_send
|= MOD_BIT(KC_RSFT
);
79 if (code
& QK_LALT
) mods_to_send
|= MOD_BIT(KC_RALT
);
80 if (code
& QK_LGUI
) mods_to_send
|= MOD_BIT(KC_RGUI
);
82 if (code
& QK_LCTL
) mods_to_send
|= MOD_BIT(KC_LCTL
);
83 if (code
& QK_LSFT
) mods_to_send
|= MOD_BIT(KC_LSFT
);
84 if (code
& QK_LALT
) mods_to_send
|= MOD_BIT(KC_LALT
);
85 if (code
& QK_LGUI
) mods_to_send
|= MOD_BIT(KC_LGUI
);
91 void register_code16(uint16_t code
) {
92 if (IS_MOD(code
) || code
== KC_NO
) {
93 do_code16(code
, register_mods
);
95 do_code16(code
, register_weak_mods
);
100 void unregister_code16(uint16_t code
) {
101 unregister_code(code
);
102 if (IS_MOD(code
) || code
== KC_NO
) {
103 do_code16(code
, unregister_mods
);
105 do_code16(code
, unregister_weak_mods
);
109 void tap_code16(uint16_t code
) {
110 register_code16(code
);
111 #if TAP_CODE_DELAY > 0
112 wait_ms(TAP_CODE_DELAY
);
114 unregister_code16(code
);
117 __attribute__((weak
)) bool process_action_kb(keyrecord_t
*record
) { return true; }
119 __attribute__((weak
)) bool process_record_kb(uint16_t keycode
, keyrecord_t
*record
) { return process_record_user(keycode
, record
); }
121 __attribute__((weak
)) bool process_record_user(uint16_t keycode
, keyrecord_t
*record
) { return true; }
123 void reset_keyboard(void) {
125 #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
126 process_midi_all_notes_off();
129 # ifndef NO_MUSIC_MODE
130 music_all_notes_off();
132 uint16_t timer_start
= timer_read();
133 PLAY_SONG(goodbye_song
);
135 while (timer_elapsed(timer_start
) < 250) wait_ms(1);
144 // this is also done later in bootloader.c - not sure if it's neccesary here
145 #ifdef BOOTLOADER_CATERINA
146 *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
151 /* Convert record into usable keycode via the contained event. */
152 uint16_t get_record_keycode(keyrecord_t
*record
) { return get_event_keycode(record
->event
); }
154 /* Convert event into usable keycode. Checks the layer cache to ensure that it
155 * retains the correct keycode after a layer change, if the key is still pressed.
157 uint16_t get_event_keycode(keyevent_t event
) {
158 #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
159 /* TODO: Use store_or_get_action() or a similar function. */
160 if (!disable_action_cache
) {
164 layer
= layer_switch_get_layer(event
.key
);
165 update_source_layers_cache(event
.key
, layer
);
167 layer
= read_source_layers_cache(event
.key
);
169 return keymap_key_to_keycode(layer
, event
.key
);
172 return keymap_key_to_keycode(layer_switch_get_layer(event
.key
), event
.key
);
175 /* Main keycode processing function. Hands off handling to other functions,
176 * then processes internal Quantum keycodes, then processes ACTIONs.
178 bool process_record_quantum(keyrecord_t
*record
) {
179 uint16_t keycode
= get_record_keycode(record
);
181 // This is how you use actions here
182 // if (keycode == KC_LEAD) {
184 // action.code = ACTION_DEFAULT_LAYER_SET(0);
185 // process_action(record, action);
189 #ifdef VELOCIKEY_ENABLE
190 if (velocikey_enabled() && record
->event
.pressed
) {
191 velocikey_accelerate();
195 #ifdef TAP_DANCE_ENABLE
196 preprocess_tap_dance(keycode
, record
);
200 #if defined(KEY_LOCK_ENABLE)
201 // Must run first to be able to mask key_up events.
202 process_key_lock(&keycode
, record
) &&
204 #if defined(DYNAMIC_MACRO_ENABLE) && !defined(DYNAMIC_MACRO_USER_CALL)
205 // Must run asap to ensure all keypresses are recorded.
206 process_dynamic_macro(keycode
, record
) &&
208 #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
209 process_clicky(keycode
, record
) &&
210 #endif // AUDIO_CLICKY
212 process_haptic(keycode
, record
) &&
213 #endif // HAPTIC_ENABLE
214 #if defined(RGB_MATRIX_ENABLE)
215 process_rgb_matrix(keycode
, record
) &&
217 #if defined(VIA_ENABLE)
218 process_record_via(keycode
, record
) &&
220 process_record_kb(keycode
, record
) &&
221 #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
222 process_midi(keycode
, record
) &&
225 process_audio(keycode
, record
) &&
227 #ifdef BACKLIGHT_ENABLE
228 process_backlight(keycode
, record
) &&
231 process_steno(keycode
, record
) &&
233 #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
234 process_music(keycode
, record
) &&
236 #ifdef TAP_DANCE_ENABLE
237 process_tap_dance(keycode
, record
) &&
239 #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
240 process_unicode_common(keycode
, record
) &&
243 process_leader(keycode
, record
) &&
246 process_combo(keycode
, record
) &&
248 #ifdef PRINTING_ENABLE
249 process_printer(keycode
, record
) &&
251 #ifdef AUTO_SHIFT_ENABLE
252 process_auto_shift(keycode
, record
) &&
254 #ifdef TERMINAL_ENABLE
255 process_terminal(keycode
, record
) &&
257 #ifdef SPACE_CADET_ENABLE
258 process_space_cadet(keycode
, record
) &&
260 #ifdef MAGIC_KEYCODE_ENABLE
261 process_magic(keycode
, record
) &&
263 #ifdef GRAVE_ESC_ENABLE
264 process_grave_esc(keycode
, record
) &&
266 #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
267 process_rgb(keycode
, record
) &&
273 if (record
->event
.pressed
) {
282 print("DEBUG: enabled.\n");
284 print("DEBUG: disabled.\n");
291 #ifdef FAUXCLICKY_ENABLE
302 #ifdef VELOCIKEY_ENABLE
307 #ifdef BLUETOOTH_ENABLE
309 set_output(OUTPUT_AUTO
);
312 set_output(OUTPUT_USB
);
315 set_output(OUTPUT_BLUETOOTH
);
321 return process_action_kb(record
);
326 /* Bit-Packed look-up table to convert an ASCII character to whether
327 * [Shift] needs to be sent with the keycode.
329 __attribute__((weak
)) const uint8_t ascii_to_shift_lut
[16] PROGMEM
= {
330 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
331 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
332 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
333 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
335 KCLUT_ENTRY(0, 1, 1, 1, 1, 1, 1, 0),
336 KCLUT_ENTRY(1, 1, 1, 1, 0, 0, 0, 0),
337 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
338 KCLUT_ENTRY(0, 0, 1, 0, 1, 0, 1, 1),
339 KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
340 KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
341 KCLUT_ENTRY(1, 1, 1, 1, 1, 1, 1, 1),
342 KCLUT_ENTRY(1, 1, 1, 0, 0, 0, 1, 1),
343 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
344 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
345 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
346 KCLUT_ENTRY(0, 0, 0, 1, 1, 1, 1, 0),
349 /* Bit-Packed look-up table to convert an ASCII character to whether
350 * [AltGr] needs to be sent with the keycode.
352 __attribute__((weak
)) const uint8_t ascii_to_altgr_lut
[16] PROGMEM
= {
353 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
354 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
355 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
356 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
358 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
359 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
360 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
361 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
362 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
363 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
364 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
365 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
366 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
367 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
368 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
369 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
372 /* Look-up table to convert an ASCII character to a keycode.
374 __attribute__((weak
)) const uint8_t ascii_to_keycode_lut
[128] PROGMEM
= {
375 // NUL SOH STX ETX EOT ENQ ACK BEL
376 XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
,
377 // BS TAB LF VT FF CR SO SI
378 KC_BSPC
, KC_TAB
, KC_ENT
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
,
379 // DLE DC1 DC2 DC3 DC4 NAK SYN ETB
380 XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
,
381 // CAN EM SUB ESC FS GS RS US
382 XXXXXXX
, XXXXXXX
, XXXXXXX
, KC_ESC
, XXXXXXX
, XXXXXXX
, XXXXXXX
, XXXXXXX
,
385 KC_SPC
, KC_1
, KC_QUOT
, KC_3
, KC_4
, KC_5
, KC_7
, KC_QUOT
,
387 KC_9
, KC_0
, KC_8
, KC_EQL
, KC_COMM
, KC_MINS
, KC_DOT
, KC_SLSH
,
389 KC_0
, KC_1
, KC_2
, KC_3
, KC_4
, KC_5
, KC_6
, KC_7
,
391 KC_8
, KC_9
, KC_SCLN
, KC_SCLN
, KC_COMM
, KC_EQL
, KC_DOT
, KC_SLSH
,
393 KC_2
, KC_A
, KC_B
, KC_C
, KC_D
, KC_E
, KC_F
, KC_G
,
395 KC_H
, KC_I
, KC_J
, KC_K
, KC_L
, KC_M
, KC_N
, KC_O
,
397 KC_P
, KC_Q
, KC_R
, KC_S
, KC_T
, KC_U
, KC_V
, KC_W
,
399 KC_X
, KC_Y
, KC_Z
, KC_LBRC
, KC_BSLS
, KC_RBRC
, KC_6
, KC_MINS
,
401 KC_GRV
, KC_A
, KC_B
, KC_C
, KC_D
, KC_E
, KC_F
, KC_G
,
403 KC_H
, KC_I
, KC_J
, KC_K
, KC_L
, KC_M
, KC_N
, KC_O
,
405 KC_P
, KC_Q
, KC_R
, KC_S
, KC_T
, KC_U
, KC_V
, KC_W
,
407 KC_X
, KC_Y
, KC_Z
, KC_LBRC
, KC_BSLS
, KC_RBRC
, KC_GRV
, KC_DEL
412 // Note: we bit-pack in "reverse" order to optimize loading
413 #define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
415 void send_string(const char *str
) { send_string_with_delay(str
, 0); }
417 void send_string_P(const char *str
) { send_string_with_delay_P(str
, 0); }
419 void send_string_with_delay(const char *str
, uint8_t interval
) {
421 char ascii_code
= *str
;
422 if (!ascii_code
) break;
423 if (ascii_code
== SS_QMK_PREFIX
) {
424 ascii_code
= *(++str
);
425 if (ascii_code
== SS_TAP_CODE
) {
427 uint8_t keycode
= *(++str
);
428 register_code(keycode
);
429 unregister_code(keycode
);
430 } else if (ascii_code
== SS_DOWN_CODE
) {
432 uint8_t keycode
= *(++str
);
433 register_code(keycode
);
434 } else if (ascii_code
== SS_UP_CODE
) {
436 uint8_t keycode
= *(++str
);
437 unregister_code(keycode
);
438 } else if (ascii_code
== SS_DELAY_CODE
) {
441 uint8_t keycode
= *(++str
);
442 while (isdigit(keycode
)) {
447 while (ms
--) wait_ms(1);
450 send_char(ascii_code
);
455 uint8_t ms
= interval
;
456 while (ms
--) wait_ms(1);
461 void send_string_with_delay_P(const char *str
, uint8_t interval
) {
463 char ascii_code
= pgm_read_byte(str
);
464 if (!ascii_code
) break;
465 if (ascii_code
== SS_QMK_PREFIX
) {
466 ascii_code
= pgm_read_byte(++str
);
467 if (ascii_code
== SS_TAP_CODE
) {
469 uint8_t keycode
= pgm_read_byte(++str
);
470 register_code(keycode
);
471 unregister_code(keycode
);
472 } else if (ascii_code
== SS_DOWN_CODE
) {
474 uint8_t keycode
= pgm_read_byte(++str
);
475 register_code(keycode
);
476 } else if (ascii_code
== SS_UP_CODE
) {
478 uint8_t keycode
= pgm_read_byte(++str
);
479 unregister_code(keycode
);
480 } else if (ascii_code
== SS_DELAY_CODE
) {
483 uint8_t keycode
= pgm_read_byte(++str
);
484 while (isdigit(keycode
)) {
487 keycode
= pgm_read_byte(++str
);
489 while (ms
--) wait_ms(1);
492 send_char(ascii_code
);
497 uint8_t ms
= interval
;
498 while (ms
--) wait_ms(1);
503 void send_char(char ascii_code
) {
504 #if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
505 if (ascii_code
== '\a') { // BEL
506 PLAY_SONG(bell_song
);
511 uint8_t keycode
= pgm_read_byte(&ascii_to_keycode_lut
[(uint8_t)ascii_code
]);
512 bool is_shifted
= PGM_LOADBIT(ascii_to_shift_lut
, (uint8_t)ascii_code
);
513 bool is_altgred
= PGM_LOADBIT(ascii_to_altgr_lut
, (uint8_t)ascii_code
);
516 register_code(KC_LSFT
);
519 register_code(KC_RALT
);
523 unregister_code(KC_RALT
);
526 unregister_code(KC_LSFT
);
530 void set_single_persistent_default_layer(uint8_t default_layer
) {
531 #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
532 PLAY_SONG(default_layer_songs
[default_layer
]);
534 eeconfig_update_default_layer(1U << default_layer
);
535 default_layer_set(1U << default_layer
);
538 layer_state_t
update_tri_layer_state(layer_state_t state
, uint8_t layer1
, uint8_t layer2
, uint8_t layer3
) {
539 layer_state_t mask12
= (1UL << layer1
) | (1UL << layer2
);
540 layer_state_t mask3
= 1UL << layer3
;
541 return (state
& mask12
) == mask12
? (state
| mask3
) : (state
& ~mask3
);
544 void update_tri_layer(uint8_t layer1
, uint8_t layer2
, uint8_t layer3
) { layer_state_set(update_tri_layer_state(layer_state
, layer1
, layer2
, layer3
)); }
546 void tap_random_base64(void) {
547 #if defined(__AVR_ATmega32U4__)
548 uint8_t key
= (TCNT0
+ TCNT1
+ TCNT3
+ TCNT4
) % 64;
550 uint8_t key
= rand() % 64;
554 register_code(KC_LSFT
);
555 register_code(key
+ KC_A
);
556 unregister_code(key
+ KC_A
);
557 unregister_code(KC_LSFT
);
560 register_code(key
- 26 + KC_A
);
561 unregister_code(key
- 26 + KC_A
);
565 unregister_code(KC_0
);
568 register_code(key
- 53 + KC_1
);
569 unregister_code(key
- 53 + KC_1
);
572 register_code(KC_LSFT
);
573 register_code(KC_EQL
);
574 unregister_code(KC_EQL
);
575 unregister_code(KC_LSFT
);
578 register_code(KC_SLSH
);
579 unregister_code(KC_SLSH
);
584 __attribute__((weak
)) void bootmagic_lite(void) {
585 // The lite version of TMK's bootmagic based on Wilba.
586 // 100% less potential for accidentally making the
587 // keyboard do stupid things.
589 // We need multiple scans because debouncing can't be turned off.
591 #if defined(DEBOUNCE) && DEBOUNCE > 0
592 wait_ms(DEBOUNCE
* 2);
598 // If the Esc and space bar are held down on power up,
599 // reset the EEPROM valid state and jump to bootloader.
600 // Assumes Esc is at [0,0].
601 // This isn't very generalized, but we need something that doesn't
602 // rely on user's keymaps in firmware or EEPROM.
603 if (matrix_get_row(BOOTMAGIC_LITE_ROW
) & (1 << BOOTMAGIC_LITE_COLUMN
)) {
605 // Jump to bootloader.
610 void matrix_init_quantum() {
611 #ifdef BOOTMAGIC_LITE
614 if (!eeconfig_is_enabled()) {
617 #ifdef BACKLIGHT_ENABLE
618 # ifdef LED_MATRIX_ENABLE
621 backlight_init_ports();
627 #ifdef RGB_MATRIX_ENABLE
630 #ifdef ENCODER_ENABLE
633 #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
634 unicode_input_mode_init();
639 #ifdef OUTPUT_AUTO_ENABLE
640 set_output(OUTPUT_AUTO
);
642 #ifdef DIP_SWITCH_ENABLE
649 void matrix_scan_quantum() {
650 #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
654 #ifdef TAP_DANCE_ENABLE
655 matrix_scan_tap_dance();
662 #ifdef LED_MATRIX_ENABLE
666 #ifdef RGB_MATRIX_ENABLE
670 #ifdef ENCODER_ENABLE
678 #ifdef DIP_SWITCH_ENABLE
679 dip_switch_read(false);
685 #ifdef HD44780_ENABLED
686 # include "hd44780.h"
689 // Functions for spitting out values
692 void send_dword(uint32_t number
) {
693 uint16_t word
= (number
>> 16);
695 send_word(number
& 0xFFFFUL
);
698 void send_word(uint16_t number
) {
699 uint8_t byte
= number
>> 8;
701 send_byte(number
& 0xFF);
704 void send_byte(uint8_t number
) {
705 uint8_t nibble
= number
>> 4;
707 send_nibble(number
& 0xF);
710 void send_nibble(uint8_t number
) {
714 unregister_code(KC_0
);
717 register_code(KC_1
+ (number
- 1));
718 unregister_code(KC_1
+ (number
- 1));
721 register_code(KC_A
+ (number
- 0xA));
722 unregister_code(KC_A
+ (number
- 0xA));
727 __attribute__((weak
)) uint16_t hex_to_keycode(uint8_t hex
) {
731 } else if (hex
< 0xA) {
732 return KC_1
+ (hex
- 0x1);
734 return KC_A
+ (hex
- 0xA);
738 void api_send_unicode(uint32_t unicode
) {
741 dword_to_bytes(unicode
, chunk
);
742 MT_SEND_DATA(DT_UNICODE
, chunk
, 5);
746 /** \brief Lock LED set callback - keymap/user level
748 * \deprecated Use led_update_user() instead.
750 __attribute__((weak
)) void led_set_user(uint8_t usb_led
) {}
752 /** \brief Lock LED set callback - keyboard level
754 * \deprecated Use led_update_kb() instead.
756 __attribute__((weak
)) void led_set_kb(uint8_t usb_led
) { led_set_user(usb_led
); }
758 /** \brief Lock LED update callback - keymap/user level
760 * \return True if led_update_kb() should run its own code, false otherwise.
762 __attribute__((weak
)) bool led_update_user(led_t led_state
) { return true; }
764 /** \brief Lock LED update callback - keyboard level
766 * \return Ignored for now.
768 __attribute__((weak
)) bool led_update_kb(led_t led_state
) { return led_update_user(led_state
); }
770 __attribute__((weak
)) void led_init_ports(void) {}
772 __attribute__((weak
)) void led_set(uint8_t usb_led
) {
773 #if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
774 // Use backlight as Caps Lock indicator
775 uint8_t bl_toggle_lvl
= 0;
777 if (IS_LED_ON(usb_led
, USB_LED_CAPS_LOCK
) && !backlight_config
.enable
) {
778 // Turning Caps Lock ON and backlight is disabled in config
779 // Toggling backlight to the brightest level
780 bl_toggle_lvl
= BACKLIGHT_LEVELS
;
781 } else if (IS_LED_OFF(usb_led
, USB_LED_CAPS_LOCK
) && backlight_config
.enable
) {
782 // Turning Caps Lock OFF and backlight is enabled in config
783 // Toggling backlight and restoring config level
784 bl_toggle_lvl
= backlight_config
.level
;
787 // Set level without modify backlight_config to keep ability to restore state
788 backlight_set(bl_toggle_lvl
);
792 led_update_kb((led_t
)usb_led
);
795 //------------------------------------------------------------------------------
796 // Override these functions in your keymap file to play different tunes on
797 // different events such as startup and bootloader jump
799 __attribute__((weak
)) void startup_user() {}
801 __attribute__((weak
)) void shutdown_user() {}
803 //------------------------------------------------------------------------------