3ae87b155531b4529970c65c7a92a7399ab0233f
Author dexter93 <d3xter93@gmail.com> Committer GitHub <noreply@github.com> Date 2023-02-12 16:38 UTC
Message 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>
Diff 1 diff --git a/quantum/keyboard.c b/quantum/keyboard.c
2 index e8e3292dbc5b9c304e453043163248406075b65c..ec2f2e4496ffcdeffe80135c042c93c64bf201d5 100644
3 --- a/quantum/keyboard.c
4 +++ b/quantum/keyboard.c
5 @@ -252,6 +252,14 @@ __attribute__((weak)) void keyboard_post_init_kb(void) {
6 keyboard_post_init_user();
7 }
8
9 +/** \brief matrix_can_read
10 + *
11 + * Allows overriding when matrix scanning operations should be executed.
12 + */
13 +__attribute__((weak)) bool matrix_can_read(void) {
14 + return true;
15 +}
16 +
17 /** \brief keyboard_setup
18 *
19 * FIXME: needs doc
20 @@ -449,10 +457,14 @@ static inline void generate_tick_event(void) {
21 * @return false Matrix didn't change
22 */
23 static bool matrix_task(void) {
24 + if (!matrix_can_read()) {
25 + generate_tick_event();
26 + return false;
27 + }
28 +
29 static matrix_row_t matrix_previous[MATRIX_ROWS];
30
31 matrix_scan();
32 -
33 bool matrix_changed = false;
34 for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
35 matrix_changed |= matrix_previous[row] ^ matrix_get_row(row);
36 diff --git a/quantum/matrix.h b/quantum/matrix.h
37 index 760d21e0c1a4b95df039509208af21530c75d16e..a5b628fc59c9514e50a3ef4ef45344a276d39c36 100644
38 --- a/quantum/matrix.h
39 +++ b/quantum/matrix.h
40 @@ -51,6 +51,8 @@ void matrix_setup(void);
41 void matrix_init(void);
42 /* scan all key states on matrix */
43 uint8_t matrix_scan(void);
44 +/* whether matrix scanning operations should be executed */
45 +bool matrix_can_read(void);
46 /* whether a switch is on */
47 bool matrix_is_on(uint8_t row, uint8_t col);
48 /* matrix state on row */