Skip to content

Commit

Permalink
fixed wrong keycode issue by moving col comparison values to xdata
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossless committed Dec 30, 2023
1 parent 92eea41 commit a7ff972
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ SMK_VERSION ?= alpha
USB_VID ?= 0x05ac
USB_PID ?= 0x024f

DEBUG ?= 1

CFLAGS := -V -mmcs51 --model-small \
--xram-size $(XRAM_SIZE) --xram-loc $(XRAM_LOC) \
--code-size $(CODE_SIZE) \
--std-c2x \
-I$(ROOT_DIR)../include \
-DDEBUG=1 \
-DDEBUG=$(DEBUG) \
-DFREQ_SYS=$(FREQ_SYS) \
-DWATCHDOG_ENABLE=1 \
-DUSB_VID=$(USB_VID) \
Expand Down
14 changes: 6 additions & 8 deletions src/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ uint8_t matrix_task()
return false;
}

bool matrix_changed = false;
__xdata bool matrix_changed = false;

for (uint8_t col = 0; col < MATRIX_COLS && !matrix_changed; col++) {
matrix_changed |= matrix_previous[col] ^ matrix_get_col(col);
Expand All @@ -131,25 +131,23 @@ uint8_t matrix_task()
}

for (uint8_t col = 0; col < MATRIX_COLS; col++) {
const matrix_col_t current_col = matrix_get_col(col);
const matrix_col_t col_changes = matrix_get_col(col) ^ matrix_previous[col];
__xdata const matrix_col_t current_col = matrix_get_col(col);
__xdata const matrix_col_t col_changes = current_col ^ matrix_previous[col];

if (!col_changes) {
continue;
}

matrix_col_t row_mask = 1;
__xdata matrix_col_t row_mask = 1;

for (uint8_t row = 0; row < MATRIX_COLS; row++, row_mask <<= 1) {
for (uint8_t row = 0; row < MATRIX_ROWS; row++, row_mask <<= 1) {
if (col_changes & row_mask) {
const bool key_pressed = current_col & row_mask;
__xdata const bool key_pressed = current_col & row_mask;

process_key_state(row, col, key_pressed);
}
}

// send_keyboard_report();

matrix_previous[col] = current_col;
}

Expand Down

0 comments on commit a7ff972

Please sign in to comment.