mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 11:30:30 +08:00
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>
This commit is contained in:
parent
db1eeea478
commit
3ae87b1555
|
@ -252,6 +252,14 @@ __attribute__((weak)) void keyboard_post_init_kb(void) {
|
||||||
keyboard_post_init_user();
|
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
|
/** \brief keyboard_setup
|
||||||
*
|
*
|
||||||
* FIXME: needs doc
|
* FIXME: needs doc
|
||||||
|
@ -449,10 +457,14 @@ static inline void generate_tick_event(void) {
|
||||||
* @return false Matrix didn't change
|
* @return false Matrix didn't change
|
||||||
*/
|
*/
|
||||||
static bool matrix_task(void) {
|
static bool matrix_task(void) {
|
||||||
|
if (!matrix_can_read()) {
|
||||||
|
generate_tick_event();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static matrix_row_t matrix_previous[MATRIX_ROWS];
|
static matrix_row_t matrix_previous[MATRIX_ROWS];
|
||||||
|
|
||||||
matrix_scan();
|
matrix_scan();
|
||||||
|
|
||||||
bool matrix_changed = false;
|
bool matrix_changed = false;
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
|
for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
|
||||||
matrix_changed |= matrix_previous[row] ^ matrix_get_row(row);
|
matrix_changed |= matrix_previous[row] ^ matrix_get_row(row);
|
||||||
|
|
|
@ -51,6 +51,8 @@ void matrix_setup(void);
|
||||||
void matrix_init(void);
|
void matrix_init(void);
|
||||||
/* scan all key states on matrix */
|
/* scan all key states on matrix */
|
||||||
uint8_t matrix_scan(void);
|
uint8_t matrix_scan(void);
|
||||||
|
/* whether matrix scanning operations should be executed */
|
||||||
|
bool matrix_can_read(void);
|
||||||
/* whether a switch is on */
|
/* whether a switch is on */
|
||||||
bool matrix_is_on(uint8_t row, uint8_t col);
|
bool matrix_is_on(uint8_t row, uint8_t col);
|
||||||
/* matrix state on row */
|
/* matrix state on row */
|
||||||
|
|
Loading…
Reference in a new issue