diff options
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 504 |
1 files changed, 162 insertions, 342 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 571dda4c5..2def99ac8 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #ifdef BACKLIGHT_ENABLE | 27 | #ifdef BACKLIGHT_ENABLE |
| 28 | # include "backlight.h" | 28 | # include "backlight.h" |
| 29 | extern backlight_config_t backlight_config; | 29 | extern backlight_config_t backlight_config; |
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | #ifdef FAUXCLICKY_ENABLE | 32 | #ifdef FAUXCLICKY_ENABLE |
| @@ -57,23 +57,7 @@ | |||
| 57 | # ifndef GOODBYE_SONG | 57 | # ifndef GOODBYE_SONG |
| 58 | # define GOODBYE_SONG SONG(GOODBYE_SOUND) | 58 | # define GOODBYE_SONG SONG(GOODBYE_SOUND) |
| 59 | # endif | 59 | # endif |
| 60 | # ifndef AG_NORM_SONG | ||
| 61 | # define AG_NORM_SONG SONG(AG_NORM_SOUND) | ||
| 62 | # endif | ||
| 63 | # ifndef AG_SWAP_SONG | ||
| 64 | # define AG_SWAP_SONG SONG(AG_SWAP_SOUND) | ||
| 65 | # endif | ||
| 66 | # ifndef CG_NORM_SONG | ||
| 67 | # define CG_NORM_SONG SONG(AG_NORM_SOUND) | ||
| 68 | # endif | ||
| 69 | # ifndef CG_SWAP_SONG | ||
| 70 | # define CG_SWAP_SONG SONG(AG_SWAP_SOUND) | ||
| 71 | # endif | ||
| 72 | float goodbye_song[][2] = GOODBYE_SONG; | 60 | float goodbye_song[][2] = GOODBYE_SONG; |
| 73 | float ag_norm_song[][2] = AG_NORM_SONG; | ||
| 74 | float ag_swap_song[][2] = AG_SWAP_SONG; | ||
| 75 | float cg_norm_song[][2] = CG_NORM_SONG; | ||
| 76 | float cg_swap_song[][2] = CG_SWAP_SONG; | ||
| 77 | # ifdef DEFAULT_LAYER_SONGS | 61 | # ifdef DEFAULT_LAYER_SONGS |
| 78 | float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; | 62 | float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; |
| 79 | # endif | 63 | # endif |
| @@ -89,7 +73,7 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) { | |||
| 89 | 73 | ||
| 90 | uint8_t mods_to_send = 0; | 74 | uint8_t mods_to_send = 0; |
| 91 | 75 | ||
| 92 | if (code & QK_RMODS_MIN) { // Right mod flag is set | 76 | if (code & QK_RMODS_MIN) { // Right mod flag is set |
| 93 | if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL); | 77 | if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL); |
| 94 | if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT); | 78 | if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT); |
| 95 | if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT); | 79 | if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT); |
| @@ -164,11 +148,6 @@ void reset_keyboard(void) { | |||
| 164 | bootloader_jump(); | 148 | bootloader_jump(); |
| 165 | } | 149 | } |
| 166 | 150 | ||
| 167 | /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise. | ||
| 168 | * Used to ensure that the correct keycode is released if the key is released. | ||
| 169 | */ | ||
| 170 | static bool grave_esc_was_shifted = false; | ||
| 171 | |||
| 172 | /* Convert record into usable keycode via the contained event. */ | 151 | /* Convert record into usable keycode via the contained event. */ |
| 173 | uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); } | 152 | uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); } |
| 174 | 153 | ||
| @@ -222,6 +201,10 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 222 | // Must run first to be able to mask key_up events. | 201 | // Must run first to be able to mask key_up events. |
| 223 | process_key_lock(&keycode, record) && | 202 | process_key_lock(&keycode, record) && |
| 224 | #endif | 203 | #endif |
| 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) && | ||
| 207 | #endif | ||
| 225 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) | 208 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) |
| 226 | process_clicky(keycode, record) && | 209 | process_clicky(keycode, record) && |
| 227 | #endif // AUDIO_CLICKY | 210 | #endif // AUDIO_CLICKY |
| @@ -268,402 +251,226 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 268 | #ifdef SPACE_CADET_ENABLE | 251 | #ifdef SPACE_CADET_ENABLE |
| 269 | process_space_cadet(keycode, record) && | 252 | process_space_cadet(keycode, record) && |
| 270 | #endif | 253 | #endif |
| 254 | #ifdef MAGIC_KEYCODE_ENABLE | ||
| 255 | process_magic(keycode, record) && | ||
| 256 | #endif | ||
| 271 | true)) { | 257 | true)) { |
| 272 | return false; | 258 | return false; |
| 273 | } | 259 | } |
| 274 | 260 | ||
| 275 | // Shift / paren setup | 261 | if (record->event.pressed) { |
| 276 | 262 | switch (keycode) { | |
| 277 | switch (keycode) { | 263 | case RESET: |
| 278 | case RESET: | ||
| 279 | if (record->event.pressed) { | ||
| 280 | reset_keyboard(); | 264 | reset_keyboard(); |
| 281 | } | 265 | return false; |
| 282 | return false; | 266 | #ifndef NO_DEBUG |
| 283 | case DEBUG: | 267 | case DEBUG: |
| 284 | if (record->event.pressed) { | ||
| 285 | debug_enable ^= 1; | 268 | debug_enable ^= 1; |
| 286 | if (debug_enable) { | 269 | if (debug_enable) { |
| 287 | print("DEBUG: enabled.\n"); | 270 | print("DEBUG: enabled.\n"); |
| 288 | } else { | 271 | } else { |
| 289 | print("DEBUG: disabled.\n"); | 272 | print("DEBUG: disabled.\n"); |
| 290 | } | 273 | } |
| 291 | } | 274 | #endif |
| 292 | return false; | 275 | return false; |
| 293 | case EEPROM_RESET: | 276 | case EEPROM_RESET: |
| 294 | if (record->event.pressed) { | ||
| 295 | eeconfig_init(); | 277 | eeconfig_init(); |
| 296 | } | 278 | return false; |
| 297 | return false; | ||
| 298 | #ifdef FAUXCLICKY_ENABLE | 279 | #ifdef FAUXCLICKY_ENABLE |
| 299 | case FC_TOG: | 280 | case FC_TOG: |
| 300 | if (record->event.pressed) { | ||
| 301 | FAUXCLICKY_TOGGLE; | 281 | FAUXCLICKY_TOGGLE; |
| 302 | } | 282 | return false; |
| 303 | return false; | 283 | case FC_ON: |
| 304 | case FC_ON: | ||
| 305 | if (record->event.pressed) { | ||
| 306 | FAUXCLICKY_ON; | 284 | FAUXCLICKY_ON; |
| 307 | } | 285 | return false; |
| 308 | return false; | 286 | case FC_OFF: |
| 309 | case FC_OFF: | ||
| 310 | if (record->event.pressed) { | ||
| 311 | FAUXCLICKY_OFF; | 287 | FAUXCLICKY_OFF; |
| 312 | } | 288 | return false; |
| 313 | return false; | 289 | #endif |
| 290 | #ifdef VELOCIKEY_ENABLE | ||
| 291 | case VLK_TOG: | ||
| 292 | velocikey_toggle(); | ||
| 293 | return false; | ||
| 294 | #endif | ||
| 295 | #ifdef BLUETOOTH_ENABLE | ||
| 296 | case OUT_AUTO: | ||
| 297 | set_output(OUTPUT_AUTO); | ||
| 298 | return false; | ||
| 299 | case OUT_USB: | ||
| 300 | set_output(OUTPUT_USB); | ||
| 301 | return false; | ||
| 302 | case OUT_BT: | ||
| 303 | set_output(OUTPUT_BLUETOOTH); | ||
| 304 | return false; | ||
| 305 | #endif | ||
| 306 | #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING) | ||
| 307 | case BL_BRTG: | ||
| 308 | backlight_toggle_breathing(); | ||
| 309 | return false; | ||
| 314 | #endif | 310 | #endif |
| 311 | } | ||
| 312 | } | ||
| 313 | |||
| 315 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) | 314 | #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) |
| 316 | case RGB_TOG: | ||
| 317 | // Split keyboards need to trigger on key-up for edge-case issue | ||
| 318 | # ifndef SPLIT_KEYBOARD | 315 | # ifndef SPLIT_KEYBOARD |
| 319 | if (record->event.pressed) { | 316 | if (record->event.pressed) { |
| 320 | # else | 317 | # else |
| 321 | if (!record->event.pressed) { | 318 | // Split keyboards need to trigger on key-up for edge-case issue |
| 319 | if (!record->event.pressed) { | ||
| 322 | # endif | 320 | # endif |
| 321 | uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); | ||
| 322 | switch (keycode) { | ||
| 323 | case RGB_TOG: | ||
| 323 | rgblight_toggle(); | 324 | rgblight_toggle(); |
| 324 | } | 325 | return false; |
| 325 | return false; | 326 | case RGB_MODE_FORWARD: |
| 326 | case RGB_MODE_FORWARD: | ||
| 327 | if (record->event.pressed) { | ||
| 328 | uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); | ||
| 329 | if (shifted) { | 327 | if (shifted) { |
| 330 | rgblight_step_reverse(); | 328 | rgblight_step_reverse(); |
| 331 | } else { | 329 | } else { |
| 332 | rgblight_step(); | 330 | rgblight_step(); |
| 333 | } | 331 | } |
| 334 | } | 332 | return false; |
| 335 | return false; | 333 | case RGB_MODE_REVERSE: |
| 336 | case RGB_MODE_REVERSE: | ||
| 337 | if (record->event.pressed) { | ||
| 338 | uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)); | ||
| 339 | if (shifted) { | 334 | if (shifted) { |
| 340 | rgblight_step(); | 335 | rgblight_step(); |
| 341 | } else { | 336 | } else { |
| 342 | rgblight_step_reverse(); | 337 | rgblight_step_reverse(); |
| 343 | } | 338 | } |
| 344 | } | 339 | return false; |
| 345 | return false; | 340 | case RGB_HUI: |
| 346 | case RGB_HUI: | 341 | if (shifted) { |
| 347 | // Split keyboards need to trigger on key-up for edge-case issue | 342 | rgblight_decrease_hue(); |
| 348 | # ifndef SPLIT_KEYBOARD | 343 | } else { |
| 349 | if (record->event.pressed) { | 344 | rgblight_increase_hue(); |
| 350 | # else | 345 | } |
| 351 | if (!record->event.pressed) { | 346 | return false; |
| 352 | # endif | 347 | case RGB_HUD: |
| 353 | rgblight_increase_hue(); | 348 | if (shifted) { |
| 354 | } | 349 | rgblight_increase_hue(); |
| 355 | return false; | 350 | } else { |
| 356 | case RGB_HUD: | 351 | rgblight_decrease_hue(); |
| 357 | // Split keyboards need to trigger on key-up for edge-case issue | 352 | } |
| 358 | # ifndef SPLIT_KEYBOARD | 353 | return false; |
| 359 | if (record->event.pressed) { | 354 | case RGB_SAI: |
| 360 | # else | 355 | if (shifted) { |
| 361 | if (!record->event.pressed) { | 356 | rgblight_decrease_sat(); |
| 362 | # endif | 357 | } else { |
| 363 | rgblight_decrease_hue(); | 358 | rgblight_increase_sat(); |
| 364 | } | 359 | } |
| 365 | return false; | 360 | return false; |
| 366 | case RGB_SAI: | 361 | case RGB_SAD: |
| 367 | // Split keyboards need to trigger on key-up for edge-case issue | 362 | if (shifted) { |
| 368 | # ifndef SPLIT_KEYBOARD | 363 | rgblight_increase_sat(); |
| 369 | if (record->event.pressed) { | 364 | } else { |
| 370 | # else | 365 | rgblight_decrease_sat(); |
| 371 | if (!record->event.pressed) { | 366 | } |
| 372 | # endif | 367 | return false; |
| 373 | rgblight_increase_sat(); | 368 | case RGB_VAI: |
| 374 | } | 369 | if (shifted) { |
| 375 | return false; | 370 | rgblight_decrease_val(); |
| 376 | case RGB_SAD: | 371 | } else { |
| 377 | // Split keyboards need to trigger on key-up for edge-case issue | 372 | rgblight_increase_val(); |
| 378 | # ifndef SPLIT_KEYBOARD | 373 | } |
| 379 | if (record->event.pressed) { | 374 | return false; |
| 380 | # else | 375 | case RGB_VAD: |
| 381 | if (!record->event.pressed) { | 376 | if (shifted) { |
| 382 | # endif | 377 | rgblight_increase_val(); |
| 383 | rgblight_decrease_sat(); | 378 | } else { |
| 384 | } | 379 | rgblight_decrease_val(); |
| 385 | return false; | 380 | } |
| 386 | case RGB_VAI: | 381 | return false; |
| 387 | // Split keyboards need to trigger on key-up for edge-case issue | 382 | case RGB_SPI: |
| 388 | # ifndef SPLIT_KEYBOARD | 383 | if (shifted) { |
| 389 | if (record->event.pressed) { | 384 | rgblight_decrease_speed(); |
| 390 | # else | 385 | } else { |
| 391 | if (!record->event.pressed) { | 386 | rgblight_increase_speed(); |
| 392 | # endif | 387 | } |
| 393 | rgblight_increase_val(); | 388 | return false; |
| 394 | } | 389 | case RGB_SPD: |
| 395 | return false; | 390 | if (shifted) { |
| 396 | case RGB_VAD: | 391 | rgblight_increase_speed(); |
| 397 | // Split keyboards need to trigger on key-up for edge-case issue | 392 | } else { |
| 398 | # ifndef SPLIT_KEYBOARD | 393 | rgblight_decrease_speed(); |
| 399 | if (record->event.pressed) { | 394 | } |
| 400 | # else | 395 | return false; |
| 401 | if (!record->event.pressed) { | 396 | case RGB_MODE_PLAIN: |
| 402 | # endif | ||
| 403 | rgblight_decrease_val(); | ||
| 404 | } | ||
| 405 | return false; | ||
| 406 | case RGB_SPI: | ||
| 407 | if (record->event.pressed) { | ||
| 408 | rgblight_increase_speed(); | ||
| 409 | } | ||
| 410 | return false; | ||
| 411 | case RGB_SPD: | ||
| 412 | if (record->event.pressed) { | ||
| 413 | rgblight_decrease_speed(); | ||
| 414 | } | ||
| 415 | return false; | ||
| 416 | case RGB_MODE_PLAIN: | ||
| 417 | if (record->event.pressed) { | ||
| 418 | rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); | 397 | rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); |
| 419 | } | 398 | return false; |
| 420 | return false; | 399 | case RGB_MODE_BREATHE: |
| 421 | case RGB_MODE_BREATHE: | ||
| 422 | # ifdef RGBLIGHT_EFFECT_BREATHING | 400 | # ifdef RGBLIGHT_EFFECT_BREATHING |
| 423 | if (record->event.pressed) { | ||
| 424 | if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) { | 401 | if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) { |
| 425 | rgblight_step(); | 402 | rgblight_step(); |
| 426 | } else { | 403 | } else { |
| 427 | rgblight_mode(RGBLIGHT_MODE_BREATHING); | 404 | rgblight_mode(RGBLIGHT_MODE_BREATHING); |
| 428 | } | 405 | } |
| 429 | } | ||
| 430 | # endif | 406 | # endif |
| 431 | return false; | 407 | return false; |
| 432 | case RGB_MODE_RAINBOW: | 408 | case RGB_MODE_RAINBOW: |
| 433 | # ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD | 409 | # ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD |
| 434 | if (record->event.pressed) { | ||
| 435 | if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) { | 410 | if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) { |
| 436 | rgblight_step(); | 411 | rgblight_step(); |
| 437 | } else { | 412 | } else { |
| 438 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD); | 413 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD); |
| 439 | } | 414 | } |
| 440 | } | ||
| 441 | # endif | 415 | # endif |
| 442 | return false; | 416 | case RGB_MODE_SWIRL: |
| 443 | case RGB_MODE_SWIRL: | ||
| 444 | # ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL | 417 | # ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL |
| 445 | if (record->event.pressed) { | ||
| 446 | if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) { | 418 | if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) { |
| 447 | rgblight_step(); | 419 | rgblight_step(); |
| 448 | } else { | 420 | } else { |
| 449 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); | 421 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); |
| 450 | } | 422 | } |
| 451 | } | ||
| 452 | # endif | 423 | # endif |
| 453 | return false; | 424 | return false; |
| 454 | case RGB_MODE_SNAKE: | 425 | case RGB_MODE_SNAKE: |
| 455 | # ifdef RGBLIGHT_EFFECT_SNAKE | 426 | # ifdef RGBLIGHT_EFFECT_SNAKE |
| 456 | if (record->event.pressed) { | ||
| 457 | if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) { | 427 | if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) { |
| 458 | rgblight_step(); | 428 | rgblight_step(); |
| 459 | } else { | 429 | } else { |
| 460 | rgblight_mode(RGBLIGHT_MODE_SNAKE); | 430 | rgblight_mode(RGBLIGHT_MODE_SNAKE); |
| 461 | } | 431 | } |
| 462 | } | ||
| 463 | # endif | 432 | # endif |
| 464 | return false; | 433 | return false; |
| 465 | case RGB_MODE_KNIGHT: | 434 | case RGB_MODE_KNIGHT: |
| 466 | # ifdef RGBLIGHT_EFFECT_KNIGHT | 435 | # ifdef RGBLIGHT_EFFECT_KNIGHT |
| 467 | if (record->event.pressed) { | ||
| 468 | if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) { | 436 | if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) { |
| 469 | rgblight_step(); | 437 | rgblight_step(); |
| 470 | } else { | 438 | } else { |
| 471 | rgblight_mode(RGBLIGHT_MODE_KNIGHT); | 439 | rgblight_mode(RGBLIGHT_MODE_KNIGHT); |
| 472 | } | 440 | } |
| 473 | } | ||
| 474 | # endif | 441 | # endif |
| 475 | return false; | 442 | return false; |
| 476 | case RGB_MODE_XMAS: | 443 | case RGB_MODE_XMAS: |
| 477 | # ifdef RGBLIGHT_EFFECT_CHRISTMAS | 444 | # ifdef RGBLIGHT_EFFECT_CHRISTMAS |
| 478 | if (record->event.pressed) { | ||
| 479 | rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); | 445 | rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); |
| 480 | } | ||
| 481 | # endif | 446 | # endif |
| 482 | return false; | 447 | return false; |
| 483 | case RGB_MODE_GRADIENT: | 448 | case RGB_MODE_GRADIENT: |
| 484 | # ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT | 449 | # ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT |
| 485 | if (record->event.pressed) { | ||
| 486 | if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) { | 450 | if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) { |
| 487 | rgblight_step(); | 451 | rgblight_step(); |
| 488 | } else { | 452 | } else { |
| 489 | rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT); | 453 | rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT); |
| 490 | } | 454 | } |
| 491 | } | ||
| 492 | # endif | 455 | # endif |
| 493 | return false; | 456 | return false; |
| 494 | case RGB_MODE_RGBTEST: | 457 | case RGB_MODE_RGBTEST: |
| 495 | # ifdef RGBLIGHT_EFFECT_RGB_TEST | 458 | # ifdef RGBLIGHT_EFFECT_RGB_TEST |
| 496 | if (record->event.pressed) { | ||
| 497 | rgblight_mode(RGBLIGHT_MODE_RGB_TEST); | 459 | rgblight_mode(RGBLIGHT_MODE_RGB_TEST); |
| 498 | } | ||
| 499 | # endif | ||
| 500 | return false; | ||
| 501 | #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) | ||
| 502 | #ifdef VELOCIKEY_ENABLE | ||
| 503 | case VLK_TOG: | ||
| 504 | if (record->event.pressed) { | ||
| 505 | velocikey_toggle(); | ||
| 506 | } | ||
| 507 | return false; | ||
| 508 | #endif | ||
| 509 | #ifdef PROTOCOL_LUFA | ||
| 510 | case OUT_AUTO: | ||
| 511 | if (record->event.pressed) { | ||
| 512 | set_output(OUTPUT_AUTO); | ||
| 513 | } | ||
| 514 | return false; | ||
| 515 | case OUT_USB: | ||
| 516 | if (record->event.pressed) { | ||
| 517 | set_output(OUTPUT_USB); | ||
| 518 | } | ||
| 519 | return false; | ||
| 520 | # ifdef BLUETOOTH_ENABLE | ||
| 521 | case OUT_BT: | ||
| 522 | if (record->event.pressed) { | ||
| 523 | set_output(OUTPUT_BLUETOOTH); | ||
| 524 | } | ||
| 525 | return false; | ||
| 526 | # endif | 460 | # endif |
| 527 | #endif | ||
| 528 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI: | ||
| 529 | case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: | ||
| 530 | if (record->event.pressed) { | ||
| 531 | // MAGIC actions (BOOTMAGIC without the boot) | ||
| 532 | if (!eeconfig_is_enabled()) { | ||
| 533 | eeconfig_init(); | ||
| 534 | } | ||
| 535 | /* keymap config */ | ||
| 536 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 537 | switch (keycode) { | ||
| 538 | case MAGIC_SWAP_CONTROL_CAPSLOCK: | ||
| 539 | keymap_config.swap_control_capslock = true; | ||
| 540 | break; | ||
| 541 | case MAGIC_CAPSLOCK_TO_CONTROL: | ||
| 542 | keymap_config.capslock_to_control = true; | ||
| 543 | break; | ||
| 544 | case MAGIC_SWAP_LALT_LGUI: | ||
| 545 | keymap_config.swap_lalt_lgui = true; | ||
| 546 | break; | ||
| 547 | case MAGIC_SWAP_RALT_RGUI: | ||
| 548 | keymap_config.swap_ralt_rgui = true; | ||
| 549 | break; | ||
| 550 | case MAGIC_SWAP_LCTL_LGUI: | ||
| 551 | keymap_config.swap_lctl_lgui = true; | ||
| 552 | break; | ||
| 553 | case MAGIC_SWAP_RCTL_RGUI: | ||
| 554 | keymap_config.swap_rctl_rgui = true; | ||
| 555 | break; | ||
| 556 | case MAGIC_NO_GUI: | ||
| 557 | keymap_config.no_gui = true; | ||
| 558 | break; | ||
| 559 | case MAGIC_SWAP_GRAVE_ESC: | ||
| 560 | keymap_config.swap_grave_esc = true; | ||
| 561 | break; | ||
| 562 | case MAGIC_SWAP_BACKSLASH_BACKSPACE: | ||
| 563 | keymap_config.swap_backslash_backspace = true; | ||
| 564 | break; | ||
| 565 | case MAGIC_HOST_NKRO: | ||
| 566 | clear_keyboard(); // clear first buffer to prevent stuck keys | ||
| 567 | keymap_config.nkro = true; | ||
| 568 | break; | ||
| 569 | case MAGIC_SWAP_ALT_GUI: | ||
| 570 | keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = true; | ||
| 571 | #ifdef AUDIO_ENABLE | ||
| 572 | PLAY_SONG(ag_swap_song); | ||
| 573 | #endif | ||
| 574 | break; | ||
| 575 | case MAGIC_SWAP_CTL_GUI: | ||
| 576 | keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = true; | ||
| 577 | #ifdef AUDIO_ENABLE | ||
| 578 | PLAY_SONG(cg_swap_song); | ||
| 579 | #endif | ||
| 580 | break; | ||
| 581 | case MAGIC_UNSWAP_CONTROL_CAPSLOCK: | ||
| 582 | keymap_config.swap_control_capslock = false; | ||
| 583 | break; | ||
| 584 | case MAGIC_UNCAPSLOCK_TO_CONTROL: | ||
| 585 | keymap_config.capslock_to_control = false; | ||
| 586 | break; | ||
| 587 | case MAGIC_UNSWAP_LALT_LGUI: | ||
| 588 | keymap_config.swap_lalt_lgui = false; | ||
| 589 | break; | ||
| 590 | case MAGIC_UNSWAP_RALT_RGUI: | ||
| 591 | keymap_config.swap_ralt_rgui = false; | ||
| 592 | break; | ||
| 593 | case MAGIC_UNSWAP_LCTL_LGUI: | ||
| 594 | keymap_config.swap_lctl_lgui = false; | ||
| 595 | break; | ||
| 596 | case MAGIC_UNSWAP_RCTL_RGUI: | ||
| 597 | keymap_config.swap_rctl_rgui = false; | ||
| 598 | break; | ||
| 599 | case MAGIC_UNNO_GUI: | ||
| 600 | keymap_config.no_gui = false; | ||
| 601 | break; | ||
| 602 | case MAGIC_UNSWAP_GRAVE_ESC: | ||
| 603 | keymap_config.swap_grave_esc = false; | ||
| 604 | break; | ||
| 605 | case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: | ||
| 606 | keymap_config.swap_backslash_backspace = false; | ||
| 607 | break; | ||
| 608 | case MAGIC_UNHOST_NKRO: | ||
| 609 | clear_keyboard(); // clear first buffer to prevent stuck keys | ||
| 610 | keymap_config.nkro = false; | ||
| 611 | break; | ||
| 612 | case MAGIC_UNSWAP_ALT_GUI: | ||
| 613 | keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = false; | ||
| 614 | #ifdef AUDIO_ENABLE | ||
| 615 | PLAY_SONG(ag_norm_song); | ||
| 616 | #endif | ||
| 617 | break; | ||
| 618 | case MAGIC_UNSWAP_CTL_GUI: | ||
| 619 | keymap_config.swap_lctl_lgui = keymap_config.swap_rctl_rgui = false; | ||
| 620 | #ifdef AUDIO_ENABLE | ||
| 621 | PLAY_SONG(cg_norm_song); | ||
| 622 | #endif | ||
| 623 | break; | ||
| 624 | case MAGIC_TOGGLE_ALT_GUI: | ||
| 625 | keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; | ||
| 626 | keymap_config.swap_ralt_rgui = keymap_config.swap_lalt_lgui; | ||
| 627 | #ifdef AUDIO_ENABLE | ||
| 628 | if (keymap_config.swap_ralt_rgui) { | ||
| 629 | PLAY_SONG(ag_swap_song); | ||
| 630 | } else { | ||
| 631 | PLAY_SONG(ag_norm_song); | ||
| 632 | } | ||
| 633 | #endif | ||
| 634 | break; | ||
| 635 | case MAGIC_TOGGLE_CTL_GUI: | ||
| 636 | keymap_config.swap_lctl_lgui = !keymap_config.swap_lctl_lgui; | ||
| 637 | keymap_config.swap_rctl_rgui = keymap_config.swap_lctl_lgui; | ||
| 638 | #ifdef AUDIO_ENABLE | ||
| 639 | if (keymap_config.swap_rctl_rgui) { | ||
| 640 | PLAY_SONG(cg_swap_song); | ||
| 641 | } else { | ||
| 642 | PLAY_SONG(cg_norm_song); | ||
| 643 | } | ||
| 644 | #endif | ||
| 645 | break; | ||
| 646 | case MAGIC_TOGGLE_NKRO: | ||
| 647 | clear_keyboard(); // clear first buffer to prevent stuck keys | ||
| 648 | keymap_config.nkro = !keymap_config.nkro; | ||
| 649 | break; | ||
| 650 | case MAGIC_EE_HANDS_LEFT: | ||
| 651 | eeconfig_update_handedness(true); | ||
| 652 | break; | ||
| 653 | case MAGIC_EE_HANDS_RIGHT: | ||
| 654 | eeconfig_update_handedness(false); | ||
| 655 | break; | ||
| 656 | default: | ||
| 657 | break; | ||
| 658 | } | ||
| 659 | eeconfig_update_keymap(keymap_config.raw); | ||
| 660 | clear_keyboard(); // clear to prevent stuck keys | ||
| 661 | |||
| 662 | return false; | 461 | return false; |
| 663 | } | 462 | } |
| 664 | break; | 463 | } |
| 464 | #endif | ||
| 665 | 465 | ||
| 466 | // keycodes that depend on both pressed and non-pressed state | ||
| 467 | switch (keycode) { | ||
| 666 | case GRAVE_ESC: { | 468 | case GRAVE_ESC: { |
| 469 | /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise. | ||
| 470 | * Used to ensure that the correct keycode is released if the key is released. | ||
| 471 | */ | ||
| 472 | static bool grave_esc_was_shifted = false; | ||
| 473 | |||
| 667 | uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))); | 474 | uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))); |
| 668 | 475 | ||
| 669 | #ifdef GRAVE_ESC_ALT_OVERRIDE | 476 | #ifdef GRAVE_ESC_ALT_OVERRIDE |
| @@ -707,14 +514,6 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 707 | return false; | 514 | return false; |
| 708 | } | 515 | } |
| 709 | 516 | ||
| 710 | #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING) | ||
| 711 | case BL_BRTG: { | ||
| 712 | if (record->event.pressed) { | ||
| 713 | backlight_toggle_breathing(); | ||
| 714 | } | ||
| 715 | return false; | ||
| 716 | } | ||
| 717 | #endif | ||
| 718 | } | 517 | } |
| 719 | 518 | ||
| 720 | return process_action_kb(record); | 519 | return process_action_kb(record); |
| @@ -1066,10 +865,30 @@ void api_send_unicode(uint32_t unicode) { | |||
| 1066 | #endif | 865 | #endif |
| 1067 | } | 866 | } |
| 1068 | 867 | ||
| 868 | /** \brief Lock LED set callback - keymap/user level | ||
| 869 | * | ||
| 870 | * \deprecated Use led_update_user() instead. | ||
| 871 | */ | ||
| 1069 | __attribute__((weak)) void led_set_user(uint8_t usb_led) {} | 872 | __attribute__((weak)) void led_set_user(uint8_t usb_led) {} |
| 1070 | 873 | ||
| 874 | /** \brief Lock LED set callback - keyboard level | ||
| 875 | * | ||
| 876 | * \deprecated Use led_update_kb() instead. | ||
| 877 | */ | ||
| 1071 | __attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } | 878 | __attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } |
| 1072 | 879 | ||
| 880 | /** \brief Lock LED update callback - keymap/user level | ||
| 881 | * | ||
| 882 | * \return True if led_update_kb() should run its own code, false otherwise. | ||
| 883 | */ | ||
| 884 | __attribute__((weak)) bool led_update_user(led_t led_state) { return true; } | ||
| 885 | |||
| 886 | /** \brief Lock LED update callback - keyboard level | ||
| 887 | * | ||
| 888 | * \return Ignored for now. | ||
| 889 | */ | ||
| 890 | __attribute__((weak)) bool led_update_kb(led_t led_state) { return led_update_user(led_state); } | ||
| 891 | |||
| 1073 | __attribute__((weak)) void led_init_ports(void) {} | 892 | __attribute__((weak)) void led_init_ports(void) {} |
| 1074 | 893 | ||
| 1075 | __attribute__((weak)) void led_set(uint8_t usb_led) { | 894 | __attribute__((weak)) void led_set(uint8_t usb_led) { |
| @@ -1092,6 +911,7 @@ __attribute__((weak)) void led_set(uint8_t usb_led) { | |||
| 1092 | #endif | 911 | #endif |
| 1093 | 912 | ||
| 1094 | led_set_kb(usb_led); | 913 | led_set_kb(usb_led); |
| 914 | led_update_kb((led_t)usb_led); | ||
| 1095 | } | 915 | } |
| 1096 | 916 | ||
| 1097 | //------------------------------------------------------------------------------ | 917 | //------------------------------------------------------------------------------ |
