diff options
author | dexter93 <d3xter93@gmail.com> | 2023-02-12 18:38:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-13 03:38:36 +1100 |
commit | 3ae87b155531b4529970c65c7a92a7399ab0233f (patch) | |
tree | 965b795d54fcd7859e133e9a098b6d34a109443c /quantum/keyboard.c | |
parent | db1eeea4788de062eccf327da5844fc3f46844f9 (diff) |
core: allow locking the matrix state (#18852)
Co-authored-by: Sergey Vlasov <sigprof@gmail.com>
Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'quantum/keyboard.c')
-rw-r--r-- | quantum/keyboard.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/quantum/keyboard.c b/quantum/keyboard.c index e8e3292dbc..ec2f2e4496 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -252,6 +252,14 @@ __attribute__((weak)) void keyboard_post_init_kb(void) { keyboard_post_init_user(); } +/** \brief matrix_can_read + * + * Allows overriding when matrix scanning operations should be executed. + */ +__attribute__((weak)) bool matrix_can_read(void) { + return true; +} + /** \brief keyboard_setup * * FIXME: needs doc @@ -449,10 +457,14 @@ static inline void generate_tick_event(void) { * @return false Matrix didn't change */ static bool matrix_task(void) { + if (!matrix_can_read()) { + generate_tick_event(); + return false; + } + static matrix_row_t matrix_previous[MATRIX_ROWS]; matrix_scan(); - bool matrix_changed = false; for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) { matrix_changed |= matrix_previous[row] ^ matrix_get_row(row); |