Skip to content

Conversation

@Xelus22
Copy link
Contributor

@Xelus22 Xelus22 commented Jan 25, 2026

Description

  • Moves matrix_previous[MATRIX_ROWS] into the respective matrix.c and matrix_common.c.
  • Consolidate matrix masked right into matrix_scan()
  • matrix_scan() now returns changed, rather than a comparison
  • memcmp over looping per row

My speed up went from 13800 scans to 14800 scans ~6% increase (with custom matrix) 👍

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

  • N/A

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions bot added the core label Jan 25, 2026
quantum/matrix.h Outdated
void matrix_init(void);
/* scan all key states on matrix */
uint8_t matrix_scan(void);
bool matrix_scan(void);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the API that custom matrix has to implement, breaking anything that already exists.

Comment on lines 599 to 602
bool matrix_changed = false;
for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) {
matrix_changed |= matrix_previous[row] ^ matrix_get_row(row);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentional, as the result of matrix_scan for custom matrix is not consistently implemented.

changed = debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed) | matrix_post_scan();
#else
changed = debounce(raw_matrix, matrix, changed);
changed = debounce(raw_matrix, matrix, ROWS_PER_HAND, changed);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a 4th argument being introduced again?

}
}

matrix_row_t matrix_previous[MATRIX_ROWS];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this increases what "full" custom matrix would have to implement, cascading changes to multiple keyboards.

@zvecr zvecr added the invalid label Jan 25, 2026
@Xelus22 Xelus22 marked this pull request as draft January 25, 2026 12:58
@Xelus22 Xelus22 force-pushed the dev/speed-up-keyboard-matrix-task branch from 5fb9fd6 to fe75b36 Compare January 25, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants