logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keyboard.c (19799B)


  1. /*
  2. Copyright 2011, 2012, 2013 Jun Wako <wakojun@gmail.com>
  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.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include <stdint.h>
  15. #include "keyboard.h"
  16. #include "keycode_config.h"
  17. #include "matrix.h"
  18. #include "keymap_introspection.h"
  19. #include "host.h"
  20. #include "led.h"
  21. #include "keycode.h"
  22. #include "timer.h"
  23. #include "sync_timer.h"
  24. #include "print.h"
  25. #include "debug.h"
  26. #include "command.h"
  27. #include "util.h"
  28. #include "sendchar.h"
  29. #include "eeconfig.h"
  30. #include "action_layer.h"
  31. #ifdef BOOTMAGIC_ENABLE
  32. # include "bootmagic.h"
  33. #endif
  34. #ifdef AUDIO_ENABLE
  35. # include "audio.h"
  36. #endif
  37. #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))
  38. # include "process_music.h"
  39. #endif
  40. #ifdef BACKLIGHT_ENABLE
  41. # include "backlight.h"
  42. #endif
  43. #ifdef MOUSEKEY_ENABLE
  44. # include "mousekey.h"
  45. #endif
  46. #ifdef PS2_MOUSE_ENABLE
  47. # include "ps2_mouse.h"
  48. #endif
  49. #ifdef RGBLIGHT_ENABLE
  50. # include "rgblight.h"
  51. #endif
  52. #ifdef LED_MATRIX_ENABLE
  53. # include "led_matrix.h"
  54. #endif
  55. #ifdef RGB_MATRIX_ENABLE
  56. # include "rgb_matrix.h"
  57. #endif
  58. #ifdef ENCODER_ENABLE
  59. # include "encoder.h"
  60. #endif
  61. #ifdef HAPTIC_ENABLE
  62. # include "haptic.h"
  63. #endif
  64. #ifdef AUTO_SHIFT_ENABLE
  65. # include "process_auto_shift.h"
  66. #endif
  67. #ifdef COMBO_ENABLE
  68. # include "process_combo.h"
  69. #endif
  70. #ifdef TAP_DANCE_ENABLE
  71. # include "process_tap_dance.h"
  72. #endif
  73. #ifdef STENO_ENABLE
  74. # include "process_steno.h"
  75. #endif
  76. #ifdef KEY_OVERRIDE_ENABLE
  77. # include "process_key_override.h"
  78. #endif
  79. #ifdef SECURE_ENABLE
  80. # include "secure.h"
  81. #endif
  82. #ifdef POINTING_DEVICE_ENABLE
  83. # include "pointing_device.h"
  84. #endif
  85. #ifdef MIDI_ENABLE
  86. # include "process_midi.h"
  87. #endif
  88. #ifdef JOYSTICK_ENABLE
  89. # include "joystick.h"
  90. #endif
  91. #ifdef HD44780_ENABLE
  92. # include "hd44780.h"
  93. #endif
  94. #ifdef OLED_ENABLE
  95. # include "oled_driver.h"
  96. #endif
  97. #ifdef ST7565_ENABLE
  98. # include "st7565.h"
  99. #endif
  100. #ifdef VIA_ENABLE
  101. # include "via.h"
  102. #endif
  103. #ifdef DIP_SWITCH_ENABLE
  104. # include "dip_switch.h"
  105. #endif
  106. #ifdef EEPROM_DRIVER
  107. # include "eeprom_driver.h"
  108. #endif
  109. #if defined(CRC_ENABLE)
  110. # include "crc.h"
  111. #endif
  112. #ifdef VIRTSER_ENABLE
  113. # include "virtser.h"
  114. #endif
  115. #ifdef SLEEP_LED_ENABLE
  116. # include "sleep_led.h"
  117. #endif
  118. #ifdef SPLIT_KEYBOARD
  119. # include "split_util.h"
  120. #endif
  121. #ifdef BATTERY_DRIVER
  122. # include "battery.h"
  123. #endif
  124. #ifdef BLUETOOTH_ENABLE
  125. # include "bluetooth.h"
  126. #endif
  127. #ifdef CAPS_WORD_ENABLE
  128. # include "caps_word.h"
  129. #endif
  130. #ifdef LEADER_ENABLE
  131. # include "leader.h"
  132. #endif
  133. #ifdef UNICODE_COMMON_ENABLE
  134. # include "unicode.h"
  135. #endif
  136. #ifdef WPM_ENABLE
  137. # include "wpm.h"
  138. #endif
  139. #ifdef OS_DETECTION_ENABLE
  140. # include "os_detection.h"
  141. #endif
  142. #ifdef LAYER_LOCK_ENABLE
  143. # include "layer_lock.h"
  144. #endif
  145. #ifdef CONNECTION_ENABLE
  146. # include "connection.h"
  147. #endif
  148. static uint32_t last_input_modification_time = 0;
  149. uint32_t last_input_activity_time(void) {
  150. return last_input_modification_time;
  151. }
  152. uint32_t last_input_activity_elapsed(void) {
  153. return sync_timer_elapsed32(last_input_modification_time);
  154. }
  155. static uint32_t last_matrix_modification_time = 0;
  156. uint32_t last_matrix_activity_time(void) {
  157. return last_matrix_modification_time;
  158. }
  159. uint32_t last_matrix_activity_elapsed(void) {
  160. return sync_timer_elapsed32(last_matrix_modification_time);
  161. }
  162. void last_matrix_activity_trigger(void) {
  163. last_matrix_modification_time = last_input_modification_time = sync_timer_read32();
  164. }
  165. static uint32_t last_encoder_modification_time = 0;
  166. uint32_t last_encoder_activity_time(void) {
  167. return last_encoder_modification_time;
  168. }
  169. uint32_t last_encoder_activity_elapsed(void) {
  170. return sync_timer_elapsed32(last_encoder_modification_time);
  171. }
  172. void last_encoder_activity_trigger(void) {
  173. last_encoder_modification_time = last_input_modification_time = sync_timer_read32();
  174. }
  175. static uint32_t last_pointing_device_modification_time = 0;
  176. uint32_t last_pointing_device_activity_time(void) {
  177. return last_pointing_device_modification_time;
  178. }
  179. uint32_t last_pointing_device_activity_elapsed(void) {
  180. return sync_timer_elapsed32(last_pointing_device_modification_time);
  181. }
  182. void last_pointing_device_activity_trigger(void) {
  183. last_pointing_device_modification_time = last_input_modification_time = sync_timer_read32();
  184. }
  185. void set_activity_timestamps(uint32_t matrix_timestamp, uint32_t encoder_timestamp, uint32_t pointing_device_timestamp) {
  186. last_matrix_modification_time = matrix_timestamp;
  187. last_encoder_modification_time = encoder_timestamp;
  188. last_pointing_device_modification_time = pointing_device_timestamp;
  189. last_input_modification_time = MAX(matrix_timestamp, MAX(encoder_timestamp, pointing_device_timestamp));
  190. }
  191. // Only enable this if console is enabled to print to
  192. #if defined(DEBUG_MATRIX_SCAN_RATE)
  193. static uint32_t matrix_timer = 0;
  194. static uint32_t matrix_scan_count = 0;
  195. static uint32_t last_matrix_scan_count = 0;
  196. void matrix_scan_perf_task(void) {
  197. matrix_scan_count++;
  198. uint32_t timer_now = timer_read32();
  199. if (TIMER_DIFF_32(timer_now, matrix_timer) >= 1000) {
  200. # if defined(CONSOLE_ENABLE)
  201. dprintf("matrix scan frequency: %lu\n", matrix_scan_count);
  202. # endif
  203. last_matrix_scan_count = matrix_scan_count;
  204. matrix_timer = timer_now;
  205. matrix_scan_count = 0;
  206. }
  207. }
  208. uint32_t get_matrix_scan_rate(void) {
  209. return last_matrix_scan_count;
  210. }
  211. #else
  212. # define matrix_scan_perf_task()
  213. #endif
  214. #ifdef MATRIX_HAS_GHOST
  215. static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) {
  216. matrix_row_t out = 0;
  217. for (uint8_t col = 0; col < MATRIX_COLS; col++) {
  218. // read each key in the row data and check if the keymap defines it as a real key
  219. if (keycode_at_keymap_location(0, row, col) && (rowdata & (((matrix_row_t)1) << col))) {
  220. // this creates new row data, if a key is defined in the keymap, it will be set here
  221. out |= ((matrix_row_t)1) << col;
  222. }
  223. }
  224. return out;
  225. }
  226. static inline bool popcount_more_than_one(matrix_row_t rowdata) {
  227. rowdata &= rowdata - 1; // if there are less than two bits (keys) set, rowdata will become zero
  228. return rowdata;
  229. }
  230. static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) {
  231. /* No ghost exists when less than 2 keys are down on the row.
  232. If there are "active" blanks in the matrix, the key can't be pressed by the user,
  233. there is no doubt as to which keys are really being pressed.
  234. The ghosts will be ignored, they are KC_NO. */
  235. rowdata = get_real_keys(row, rowdata);
  236. if ((popcount_more_than_one(rowdata)) == 0) {
  237. return false;
  238. }
  239. /* Ghost occurs when the row shares a column line with other row,
  240. and two columns are read on each row. Blanks in the matrix don't matter,
  241. so they are filtered out.
  242. If there are two or more real keys pressed and they match columns with
  243. at least two of another row's real keys, the row will be ignored. Keep in mind,
  244. we are checking one row at a time, not all of them at once.
  245. */
  246. for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
  247. if (i != row && popcount_more_than_one(get_real_keys(i, matrix_get_row(i)) & rowdata)) {
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253. #else
  254. static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata) {
  255. return false;
  256. }
  257. #endif
  258. /** \brief matrix_setup
  259. *
  260. * FIXME: needs doc
  261. */
  262. __attribute__((weak)) void matrix_setup(void) {}
  263. /** \brief keyboard_pre_init_user
  264. *
  265. * FIXME: needs doc
  266. */
  267. __attribute__((weak)) void keyboard_pre_init_user(void) {}
  268. /** \brief keyboard_pre_init_kb
  269. *
  270. * FIXME: needs doc
  271. */
  272. __attribute__((weak)) void keyboard_pre_init_kb(void) {
  273. keyboard_pre_init_user();
  274. }
  275. /** \brief keyboard_pre_init_modules
  276. *
  277. * FIXME: needs doc
  278. */
  279. __attribute__((weak)) void keyboard_pre_init_modules(void) {}
  280. /** \brief keyboard_pre_init_quantum
  281. *
  282. * FIXME: needs doc
  283. */
  284. void keyboard_pre_init_quantum(void) {
  285. keyboard_pre_init_modules();
  286. keyboard_pre_init_kb();
  287. }
  288. /** \brief keyboard_post_init_user
  289. *
  290. * FIXME: needs doc
  291. */
  292. __attribute__((weak)) void keyboard_post_init_user(void) {}
  293. /** \brief keyboard_post_init_kb
  294. *
  295. * FIXME: needs doc
  296. */
  297. __attribute__((weak)) void keyboard_post_init_kb(void) {
  298. keyboard_post_init_user();
  299. }
  300. /** \brief keyboard_post_init_modules
  301. *
  302. * FIXME: needs doc
  303. */
  304. __attribute__((weak)) void keyboard_post_init_modules(void) {}
  305. /** \brief keyboard_post_init_quantum
  306. *
  307. * FIXME: needs doc
  308. */
  309. void keyboard_post_init_quantum(void) {
  310. keyboard_post_init_modules();
  311. keyboard_post_init_kb();
  312. }
  313. /** \brief matrix_can_read
  314. *
  315. * Allows overriding when matrix scanning operations should be executed.
  316. */
  317. __attribute__((weak)) bool matrix_can_read(void) {
  318. return true;
  319. }
  320. /** \brief keyboard_setup
  321. *
  322. * FIXME: needs doc
  323. */
  324. void keyboard_setup(void) {
  325. print_set_sendchar(sendchar);
  326. #ifdef EEPROM_DRIVER
  327. eeprom_driver_init();
  328. #endif
  329. matrix_setup();
  330. keyboard_pre_init_quantum();
  331. }
  332. #ifndef SPLIT_KEYBOARD
  333. /** \brief is_keyboard_master
  334. *
  335. * FIXME: needs doc
  336. */
  337. __attribute__((weak)) bool is_keyboard_master(void) {
  338. return true;
  339. }
  340. /** \brief is_keyboard_left
  341. *
  342. * FIXME: needs doc
  343. */
  344. __attribute__((weak)) bool is_keyboard_left(void) {
  345. return true;
  346. }
  347. #endif
  348. /** \brief should_process_keypress
  349. *
  350. * Override this function if you have a condition where keypresses processing should change:
  351. * - splits where the slave side needs to process for rgb/oled functionality
  352. */
  353. __attribute__((weak)) bool should_process_keypress(void) {
  354. return is_keyboard_master();
  355. }
  356. /** \brief housekeeping_task_modules
  357. *
  358. * Codegen will override this if community modules are enabled.
  359. * This is specific to keyboard-level functionality.
  360. */
  361. __attribute__((weak)) void housekeeping_task_modules(void) {}
  362. /** \brief housekeeping_task_kb
  363. *
  364. * Override this function if you have a need to execute code for every keyboard main loop iteration.
  365. * This is specific to keyboard-level functionality.
  366. */
  367. __attribute__((weak)) void housekeeping_task_kb(void) {}
  368. /** \brief housekeeping_task_user
  369. *
  370. * Override this function if you have a need to execute code for every keyboard main loop iteration.
  371. * This is specific to user/keymap-level functionality.
  372. */
  373. __attribute__((weak)) void housekeeping_task_user(void) {}
  374. /** \brief housekeeping_task
  375. *
  376. * Invokes hooks for executing code after QMK is done after each loop iteration.
  377. */
  378. void housekeeping_task(void) {
  379. housekeeping_task_modules();
  380. housekeeping_task_kb();
  381. housekeeping_task_user();
  382. }
  383. /** \brief quantum_init
  384. *
  385. * Init global state
  386. */
  387. void quantum_init(void) {
  388. /* check signature */
  389. if (!eeconfig_is_enabled()) {
  390. eeconfig_init();
  391. }
  392. /* init globals */
  393. eeconfig_read_debug(&debug_config);
  394. eeconfig_read_keymap(&keymap_config);
  395. #ifdef BOOTMAGIC_ENABLE
  396. bootmagic();
  397. #endif
  398. /* read here just incase bootmagic process changed its value */
  399. layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer();
  400. default_layer_set(default_layer);
  401. /* Also initialize layer state to trigger callback functions for layer_state */
  402. layer_state_set_kb((layer_state_t)layer_state);
  403. }
  404. /** \brief keyboard_init
  405. *
  406. * FIXME: needs doc
  407. */
  408. void keyboard_init(void) {
  409. timer_init();
  410. sync_timer_init();
  411. #ifdef VIA_ENABLE
  412. via_init();
  413. #endif
  414. #ifdef SPLIT_KEYBOARD
  415. split_pre_init();
  416. #endif
  417. #ifdef ENCODER_ENABLE
  418. encoder_init();
  419. #endif
  420. matrix_init();
  421. quantum_init();
  422. #ifdef CONNECTION_ENABLE
  423. connection_init();
  424. #endif
  425. led_init_ports();
  426. #ifdef BACKLIGHT_ENABLE
  427. backlight_init_ports();
  428. #endif
  429. #ifdef AUDIO_ENABLE
  430. audio_init();
  431. #endif
  432. #ifdef LED_MATRIX_ENABLE
  433. led_matrix_init();
  434. #endif
  435. #ifdef RGB_MATRIX_ENABLE
  436. rgb_matrix_init();
  437. #endif
  438. #if defined(UNICODE_COMMON_ENABLE)
  439. unicode_input_mode_init();
  440. #endif
  441. #if defined(CRC_ENABLE)
  442. crc_init();
  443. #endif
  444. #ifdef OLED_ENABLE
  445. oled_init(OLED_ROTATION_0);
  446. #endif
  447. #ifdef ST7565_ENABLE
  448. st7565_init(DISPLAY_ROTATION_0);
  449. #endif
  450. #ifdef PS2_MOUSE_ENABLE
  451. ps2_mouse_init();
  452. #endif
  453. #ifdef BACKLIGHT_ENABLE
  454. backlight_init();
  455. #endif
  456. #ifdef RGBLIGHT_ENABLE
  457. rgblight_init();
  458. #endif
  459. #ifdef STENO_ENABLE_ALL
  460. steno_init();
  461. #endif
  462. #if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
  463. # pragma message "FORCE_NKRO option is now deprecated - Please migrate to NKRO_DEFAULT_ON instead."
  464. keymap_config.nkro = 1;
  465. eeconfig_update_keymap(&keymap_config);
  466. #endif
  467. #ifdef DIP_SWITCH_ENABLE
  468. dip_switch_init();
  469. #endif
  470. #ifdef JOYSTICK_ENABLE
  471. joystick_init();
  472. #endif
  473. #ifdef SLEEP_LED_ENABLE
  474. sleep_led_init();
  475. #endif
  476. #ifdef VIRTSER_ENABLE
  477. virtser_init();
  478. #endif
  479. #ifdef SPLIT_KEYBOARD
  480. split_post_init();
  481. #endif
  482. #ifdef POINTING_DEVICE_ENABLE
  483. // init after split init
  484. pointing_device_init();
  485. #endif
  486. #ifdef BATTERY_DRIVER
  487. battery_init();
  488. #endif
  489. #ifdef BLUETOOTH_ENABLE
  490. bluetooth_init();
  491. #endif
  492. #ifdef HAPTIC_ENABLE
  493. haptic_init();
  494. #endif
  495. #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
  496. debug_enable = true;
  497. #endif
  498. keyboard_post_init_quantum(); /* Always keep this last */
  499. }
  500. /** \brief key_event_task
  501. *
  502. * This function is responsible for calling into other systems when they need to respond to electrical switch press events.
  503. * This is differnet than keycode events as no layer processing, or filtering occurs.
  504. */
  505. void switch_events(uint8_t row, uint8_t col, bool pressed) {
  506. #if defined(LED_MATRIX_ENABLE)
  507. led_matrix_handle_key_event(row, col, pressed);
  508. #endif
  509. #if defined(RGB_MATRIX_ENABLE)
  510. rgb_matrix_handle_key_event(row, col, pressed);
  511. #endif
  512. }
  513. /**
  514. * @brief Generates a tick event at a maximum rate of 1KHz that drives the
  515. * internal QMK state machine.
  516. */
  517. static inline void generate_tick_event(void) {
  518. static uint16_t last_tick = 0;
  519. const uint16_t now = timer_read();
  520. if (TIMER_DIFF_16(now, last_tick) != 0) {
  521. action_exec(MAKE_TICK_EVENT);
  522. last_tick = now;
  523. }
  524. }
  525. /**
  526. * @brief This task scans the keyboards matrix and processes any key presses
  527. * that occur.
  528. *
  529. * @return true Matrix did change
  530. * @return false Matrix didn't change
  531. */
  532. static bool matrix_task(void) {
  533. if (!matrix_can_read()) {
  534. generate_tick_event();
  535. return false;
  536. }
  537. static matrix_row_t matrix_previous[MATRIX_ROWS];
  538. matrix_scan();
  539. bool matrix_changed = false;
  540. for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
  541. matrix_changed |= matrix_previous[row] ^ matrix_get_row(row);
  542. }
  543. matrix_scan_perf_task();
  544. // Short-circuit the complete matrix processing if it is not necessary
  545. if (!matrix_changed) {
  546. generate_tick_event();
  547. return matrix_changed;
  548. }
  549. if (debug_config.matrix) {
  550. matrix_print();
  551. }
  552. const bool process_keypress = should_process_keypress();
  553. for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
  554. const matrix_row_t current_row = matrix_get_row(row);
  555. const matrix_row_t row_changes = current_row ^ matrix_previous[row];
  556. if (!row_changes || has_ghost_in_row(row, current_row)) {
  557. continue;
  558. }
  559. matrix_row_t col_mask = 1;
  560. for (uint8_t col = 0; col < MATRIX_COLS; col++, col_mask <<= 1) {
  561. if (row_changes & col_mask) {
  562. const bool key_pressed = current_row & col_mask;
  563. if (process_keypress) {
  564. action_exec(MAKE_KEYEVENT(row, col, key_pressed));
  565. }
  566. switch_events(row, col, key_pressed);
  567. }
  568. }
  569. matrix_previous[row] = current_row;
  570. }
  571. return matrix_changed;
  572. }
  573. /** \brief Tasks previously located in matrix_scan_quantum
  574. *
  575. * TODO: rationalise against keyboard_task and current split role
  576. */
  577. void quantum_task(void) {
  578. #ifdef SPLIT_KEYBOARD
  579. // some tasks should only run on master
  580. if (!is_keyboard_master()) return;
  581. #endif
  582. #if defined(AUDIO_ENABLE) && defined(AUDIO_INIT_DELAY)
  583. // There are some tasks that need to be run a little bit
  584. // after keyboard startup, or else they will not work correctly
  585. // because of interaction with the USB device state, which
  586. // may still be in flux...
  587. //
  588. // At the moment the only feature that needs this is the
  589. // startup song.
  590. static bool delayed_tasks_run = false;
  591. static uint16_t delayed_task_timer = 0;
  592. if (!delayed_tasks_run) {
  593. if (!delayed_task_timer) {
  594. delayed_task_timer = timer_read();
  595. } else if (timer_elapsed(delayed_task_timer) > 300) {
  596. audio_startup();
  597. delayed_tasks_run = true;
  598. }
  599. }
  600. #endif
  601. #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
  602. music_task();
  603. #endif
  604. #ifdef KEY_OVERRIDE_ENABLE
  605. key_override_task();
  606. #endif
  607. #ifdef SEQUENCER_ENABLE
  608. sequencer_task();
  609. #endif
  610. #ifdef TAP_DANCE_ENABLE
  611. tap_dance_task();
  612. #endif
  613. #ifdef COMBO_ENABLE
  614. combo_task();
  615. #endif
  616. #ifdef LEADER_ENABLE
  617. leader_task();
  618. #endif
  619. #ifdef WPM_ENABLE
  620. decay_wpm();
  621. #endif
  622. #ifdef DIP_SWITCH_ENABLE
  623. dip_switch_task();
  624. #endif
  625. #ifdef AUTO_SHIFT_ENABLE
  626. autoshift_matrix_scan();
  627. #endif
  628. #ifdef CAPS_WORD_ENABLE
  629. caps_word_task();
  630. #endif
  631. #ifdef SECURE_ENABLE
  632. secure_task();
  633. #endif
  634. #ifdef LAYER_LOCK_ENABLE
  635. layer_lock_task();
  636. #endif
  637. }
  638. /** \brief Main task that is repeatedly called as fast as possible. */
  639. void keyboard_task(void) {
  640. __attribute__((unused)) bool activity_has_occurred = false;
  641. if (matrix_task()) {
  642. last_matrix_activity_trigger();
  643. activity_has_occurred = true;
  644. }
  645. quantum_task();
  646. #if defined(SPLIT_WATCHDOG_ENABLE)
  647. split_watchdog_task();
  648. #endif
  649. #if defined(RGBLIGHT_ENABLE)
  650. rgblight_task();
  651. #endif
  652. #ifdef LED_MATRIX_ENABLE
  653. led_matrix_task();
  654. #endif
  655. #ifdef RGB_MATRIX_ENABLE
  656. rgb_matrix_task();
  657. #endif
  658. #if defined(BACKLIGHT_ENABLE)
  659. # if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
  660. backlight_task();
  661. # endif
  662. #endif
  663. #ifdef ENCODER_ENABLE
  664. if (encoder_task()) {
  665. last_encoder_activity_trigger();
  666. activity_has_occurred = true;
  667. }
  668. #endif
  669. #ifdef POINTING_DEVICE_ENABLE
  670. if (pointing_device_task()) {
  671. last_pointing_device_activity_trigger();
  672. activity_has_occurred = true;
  673. }
  674. #endif
  675. #ifdef OLED_ENABLE
  676. oled_task();
  677. # if OLED_TIMEOUT > 0
  678. // Wake up oled if user is using those fabulous keys or spinning those encoders!
  679. if (activity_has_occurred) oled_on();
  680. # endif
  681. #endif
  682. #ifdef ST7565_ENABLE
  683. st7565_task();
  684. # if ST7565_TIMEOUT > 0
  685. // Wake up display if user is using those fabulous keys or spinning those encoders!
  686. if (activity_has_occurred) st7565_on();
  687. # endif
  688. #endif
  689. #ifdef MOUSEKEY_ENABLE
  690. // mousekey repeat & acceleration
  691. mousekey_task();
  692. #endif
  693. #ifdef PS2_MOUSE_ENABLE
  694. ps2_mouse_task();
  695. #endif
  696. #ifdef MIDI_ENABLE
  697. midi_task();
  698. #endif
  699. #ifdef JOYSTICK_ENABLE
  700. joystick_task();
  701. #endif
  702. #ifdef BATTERY_DRIVER
  703. battery_task();
  704. #endif
  705. #ifdef BLUETOOTH_ENABLE
  706. bluetooth_task();
  707. #endif
  708. #ifdef HAPTIC_ENABLE
  709. haptic_task();
  710. #endif
  711. led_task();
  712. #ifdef OS_DETECTION_ENABLE
  713. os_detection_task();
  714. #endif
  715. }