diff options
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 122 |
1 files changed, 105 insertions, 17 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index e60378afe..ac8857df8 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -25,10 +25,6 @@ | |||
| 25 | # include "backlight.h" | 25 | # include "backlight.h" |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #ifdef API_ENABLE | ||
| 29 | # include "api.h" | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #ifdef MIDI_ENABLE | 28 | #ifdef MIDI_ENABLE |
| 33 | # include "process_midi.h" | 29 | # include "process_midi.h" |
| 34 | #endif | 30 | #endif |
| @@ -145,12 +141,13 @@ void reset_keyboard(void) { | |||
| 145 | /* Convert record into usable keycode via the contained event. */ | 141 | /* Convert record into usable keycode via the contained event. */ |
| 146 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { | 142 | uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { |
| 147 | #ifdef COMBO_ENABLE | 143 | #ifdef COMBO_ENABLE |
| 148 | if (record->keycode) { return record->keycode; } | 144 | if (record->keycode) { |
| 145 | return record->keycode; | ||
| 146 | } | ||
| 149 | #endif | 147 | #endif |
| 150 | return get_event_keycode(record->event, update_layer_cache); | 148 | return get_event_keycode(record->event, update_layer_cache); |
| 151 | } | 149 | } |
| 152 | 150 | ||
| 153 | |||
| 154 | /* Convert event into usable keycode. Checks the layer cache to ensure that it | 151 | /* 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. | 152 | * retains the correct keycode after a layer change, if the key is still pressed. |
| 156 | * "update_layer_cache" is to ensure that it only updates the layer cache when | 153 | * "update_layer_cache" is to ensure that it only updates the layer cache when |
| @@ -179,12 +176,12 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) { | |||
| 179 | bool pre_process_record_quantum(keyrecord_t *record) { | 176 | bool pre_process_record_quantum(keyrecord_t *record) { |
| 180 | if (!( | 177 | if (!( |
| 181 | #ifdef COMBO_ENABLE | 178 | #ifdef COMBO_ENABLE |
| 182 | process_combo(get_record_keycode(record, true), record) && | 179 | process_combo(get_record_keycode(record, true), record) && |
| 183 | #endif | 180 | #endif |
| 184 | true)) { | 181 | true)) { |
| 185 | return false; | 182 | return false; |
| 186 | } | 183 | } |
| 187 | return true; // continue processing | 184 | return true; // continue processing |
| 188 | } | 185 | } |
| 189 | 186 | ||
| 190 | /* Get keycode, and then call keyboard function */ | 187 | /* Get keycode, and then call keyboard function */ |
| @@ -296,6 +293,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 296 | #ifdef JOYSTICK_ENABLE | 293 | #ifdef JOYSTICK_ENABLE |
| 297 | process_joystick(keycode, record) && | 294 | process_joystick(keycode, record) && |
| 298 | #endif | 295 | #endif |
| 296 | #ifdef PROGRAMMABLE_BUTTON_ENABLE | ||
| 297 | process_programmable_button(keycode, record) && | ||
| 298 | #endif | ||
| 299 | true)) { | 299 | true)) { |
| 300 | return false; | 300 | return false; |
| 301 | } | 301 | } |
| @@ -465,14 +465,6 @@ void matrix_scan_quantum() { | |||
| 465 | # include "hd44780.h" | 465 | # include "hd44780.h" |
| 466 | #endif | 466 | #endif |
| 467 | 467 | ||
| 468 | void api_send_unicode(uint32_t unicode) { | ||
| 469 | #ifdef API_ENABLE | ||
| 470 | uint8_t chunk[4]; | ||
| 471 | dword_to_bytes(unicode, chunk); | ||
| 472 | MT_SEND_DATA(DT_UNICODE, chunk, 5); | ||
| 473 | #endif | ||
| 474 | } | ||
| 475 | |||
| 476 | //------------------------------------------------------------------------------ | 468 | //------------------------------------------------------------------------------ |
| 477 | // Override these functions in your keymap file to play different tunes on | 469 | // Override these functions in your keymap file to play different tunes on |
| 478 | // different events such as startup and bootloader jump | 470 | // different events such as startup and bootloader jump |
| @@ -480,3 +472,99 @@ void api_send_unicode(uint32_t unicode) { | |||
| 480 | __attribute__((weak)) void startup_user() {} | 472 | __attribute__((weak)) void startup_user() {} |
| 481 | 473 | ||
| 482 | __attribute__((weak)) void shutdown_user() {} | 474 | __attribute__((weak)) void shutdown_user() {} |
| 475 | |||
| 476 | /** \brief Run keyboard level Power down | ||
| 477 | * | ||
| 478 | * FIXME: needs doc | ||
| 479 | */ | ||
| 480 | __attribute__((weak)) void suspend_power_down_user(void) {} | ||
| 481 | /** \brief Run keyboard level Power down | ||
| 482 | * | ||
| 483 | * FIXME: needs doc | ||
| 484 | */ | ||
| 485 | __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } | ||
| 486 | |||
| 487 | void suspend_power_down_quantum(void) { | ||
| 488 | #ifndef NO_SUSPEND_POWER_DOWN | ||
| 489 | // Turn off backlight | ||
| 490 | # ifdef BACKLIGHT_ENABLE | ||
| 491 | backlight_set(0); | ||
| 492 | # endif | ||
| 493 | |||
| 494 | # ifdef LED_MATRIX_ENABLE | ||
| 495 | led_matrix_task(); | ||
| 496 | # endif | ||
| 497 | # ifdef RGB_MATRIX_ENABLE | ||
| 498 | rgb_matrix_task(); | ||
| 499 | # endif | ||
| 500 | |||
| 501 | // Turn off LED indicators | ||
| 502 | uint8_t leds_off = 0; | ||
| 503 | # if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 504 | if (is_backlight_enabled()) { | ||
| 505 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 506 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 507 | } | ||
| 508 | # endif | ||
| 509 | led_set(leds_off); | ||
| 510 | |||
| 511 | // Turn off audio | ||
| 512 | # ifdef AUDIO_ENABLE | ||
| 513 | stop_all_notes(); | ||
| 514 | # endif | ||
| 515 | |||
| 516 | // Turn off underglow | ||
| 517 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 518 | rgblight_suspend(); | ||
| 519 | # endif | ||
| 520 | |||
| 521 | # if defined(LED_MATRIX_ENABLE) | ||
| 522 | led_matrix_set_suspend_state(true); | ||
| 523 | # endif | ||
| 524 | # if defined(RGB_MATRIX_ENABLE) | ||
| 525 | rgb_matrix_set_suspend_state(true); | ||
| 526 | # endif | ||
| 527 | |||
| 528 | # ifdef OLED_ENABLE | ||
| 529 | oled_off(); | ||
| 530 | # endif | ||
| 531 | # ifdef ST7565_ENABLE | ||
| 532 | st7565_off(); | ||
| 533 | # endif | ||
| 534 | #endif | ||
| 535 | } | ||
| 536 | |||
| 537 | /** \brief run user level code immediately after wakeup | ||
| 538 | * | ||
| 539 | * FIXME: needs doc | ||
| 540 | */ | ||
| 541 | __attribute__((weak)) void suspend_wakeup_init_user(void) {} | ||
| 542 | |||
| 543 | /** \brief run keyboard level code immediately after wakeup | ||
| 544 | * | ||
| 545 | * FIXME: needs doc | ||
| 546 | */ | ||
| 547 | __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); } | ||
| 548 | |||
| 549 | __attribute__((weak)) void suspend_wakeup_init_quantum(void) { | ||
| 550 | // Turn on backlight | ||
| 551 | #ifdef BACKLIGHT_ENABLE | ||
| 552 | backlight_init(); | ||
| 553 | #endif | ||
| 554 | |||
| 555 | // Restore LED indicators | ||
| 556 | led_set(host_keyboard_leds()); | ||
| 557 | |||
| 558 | // Wake up underglow | ||
| 559 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 560 | rgblight_wakeup(); | ||
| 561 | #endif | ||
| 562 | |||
| 563 | #if defined(LED_MATRIX_ENABLE) | ||
| 564 | led_matrix_set_suspend_state(false); | ||
| 565 | #endif | ||
| 566 | #if defined(RGB_MATRIX_ENABLE) | ||
| 567 | rgb_matrix_set_suspend_state(false); | ||
| 568 | #endif | ||
| 569 | suspend_wakeup_init_kb(); | ||
| 570 | } | ||
