Provide a mechanism for split keyboards to process key press on both halves (#9001)

This commit is contained in:
Joel Challis
2020-05-03 00:39:37 +01:00
committed by Florian Didron
parent 1aa5d2d6d0
commit 528f7d27d9

View File

@@ -208,6 +208,13 @@ void keyboard_setup(void) {
*/ */
__attribute__((weak)) bool is_keyboard_master(void) { return true; } __attribute__((weak)) bool is_keyboard_master(void) { return true; }
/** \brief should_process_keypress
*
* Override this function if you have a condition where keypresses processing should change:
* - splits where the slave side needs to process for rgb/oled functionality
*/
__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); }
/** \brief keyboard_init /** \brief keyboard_init
* *
* FIXME: needs doc * FIXME: needs doc
@@ -287,7 +294,7 @@ void keyboard_task(void) {
matrix_scan(); matrix_scan();
#endif #endif
if (is_keyboard_master()) { if (should_process_keypress()) {
for (uint8_t r = 0; r < MATRIX_ROWS; r++) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
matrix_row = matrix_get_row(r); matrix_row = matrix_get_row(r);
matrix_change = matrix_row ^ matrix_prev[r]; matrix_change = matrix_row ^ matrix_prev[r];