22 lines
599 B
C
22 lines
599 B
C
#pragma once
|
||
#include <stdint.h>
|
||
|
||
// 5×5 button matrix
|
||
// COL_0 × ROW_0–3 = encoder SW buttons
|
||
// COL_1–4 × ROW_0–4 = 20 Cherry MX buttons
|
||
// COL_0 × ROW_4 = not connected
|
||
|
||
#define MATRIX_COLS 5
|
||
#define MATRIX_ROWS 5
|
||
#define MATRIX_KEYS 25 // col * MATRIX_ROWS + row
|
||
|
||
// Callback: key index (0–24), pressed = true / released = false
|
||
typedef void (*matrix_cb_t)(uint8_t key, bool pressed);
|
||
|
||
void matrix_init(matrix_cb_t cb);
|
||
void matrix_scan();
|
||
|
||
// Helper: key index from logical position
|
||
inline uint8_t matrix_key(uint8_t col, uint8_t row) {
|
||
return col * MATRIX_ROWS + row;
|
||
}
|