Browse Source

Fix matrix.c to use new default impl.

master
tmk 5 years ago
parent
commit
1ad31539a6

+ 2
- 112
converter/adb_usb/matrix.c View File

@@ -31,44 +31,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host.h"


#if (MATRIX_COLS > 16)
# error "MATRIX_COLS must not exceed 16"
#endif
#if (MATRIX_ROWS > 255)
# error "MATRIX_ROWS must not exceed 255"
#endif


static bool has_media_keys = false;
static bool is_iso_layout = false;
static bool is_modified = false;
static report_mouse_t mouse_report = {};

// matrix state buffer(1:on, 0:off)
#if (MATRIX_COLS <= 8)
static uint8_t matrix[MATRIX_ROWS];
#else
static uint16_t matrix[MATRIX_ROWS];
#endif
static matrix_row_t matrix[MATRIX_ROWS];

#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif
static void register_key(uint8_t key);


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
// LED on
@@ -208,8 +182,6 @@ uint8_t matrix_scan(void)
uint16_t codes;
uint8_t key0, key1;

is_modified = false;

codes = extra_key;
extra_key = 0xFFFF;

@@ -328,93 +300,12 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
#ifdef MATRIX_HAS_GHOST
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix_has_ghost_in_row(i))
return true;
}
#endif
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
#if (MATRIX_COLS <= 8)
uint8_t matrix_get_row(uint8_t row)
#else
uint16_t matrix_get_row(uint8_t row)
#endif
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
if (!debug_matrix) return;
#if (MATRIX_COLS <= 8)
print("r/c 01234567\n");
#else
print("r/c 0123456789ABCDEF\n");
#endif
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
#if (MATRIX_COLS <= 8)
pbin_reverse(matrix_get_row(row));
#else
pbin_reverse16(matrix_get_row(row));
#endif
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
#if (MATRIX_COLS <= 8)
count += bitpop(matrix[i]);
#else
count += bitpop16(matrix[i]);
#endif
}
return count;
}

#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;

// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
return true;
}
return false;
}
#endif

inline
static void register_key(uint8_t key)
{
@@ -426,5 +317,4 @@ static void register_key(uint8_t key)
} else {
matrix[row] |= (1<<col);
}
is_modified = true;
}

+ 0
- 28
converter/ibm4704_usb/matrix.c View File

@@ -52,18 +52,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define COL(code) (code&0x07)


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

static void enable_break(void)
{
print("Enable break: ");
@@ -120,28 +108,12 @@ uint8_t matrix_scan(void)
return 1;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row)));
}
}



inline
static void matrix_make(uint8_t code)
{

+ 0
- 48
converter/m0110_usb/matrix.c View File

@@ -46,18 +46,6 @@ static uint8_t _matrix0[MATRIX_ROWS];
static void register_key(uint8_t key);


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
m0110_init();
@@ -95,48 +83,12 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

inline
static void register_key(uint8_t key)
{

+ 0
- 54
converter/news_usb/matrix.c View File

@@ -47,20 +47,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) ((code>>3)&0xF)
#define COL(code) (code&0x07)

static bool is_modified = false;


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
@@ -74,8 +60,6 @@ void matrix_init(void)

uint8_t matrix_scan(void)
{
is_modified = false;

uint8_t code;
code = news_recv();
if (code == 0) {
@@ -87,56 +71,18 @@ uint8_t matrix_scan(void)
// break code
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
}
} else {
// make code
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= (1<<COL(code));
is_modified = true;
}
}
return code;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

+ 0
- 32
converter/next_usb/matrix.c View File

@@ -66,20 +66,6 @@ static uint8_t matrix[MATRIX_ROWS];

static bool is_modified = false;

/* number of matrix rows */
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

/* number of matrix columns */
inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

#ifndef NEXT_KBD_LED1_ON
#define NEXT_KBD_LED1_ON
#endif
@@ -227,19 +213,6 @@ uint8_t matrix_scan(void)
return 1;
}

/* whether modified from previous scan. used after matrix_scan. */
bool matrix_is_modified()
{
return is_modified;
}

/* whether a switch is on */
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

/* matrix state on row */
inline
uint8_t matrix_get_row(uint8_t row)
@@ -247,11 +220,6 @@ uint8_t matrix_get_row(uint8_t row)
return matrix[row];
}

/* print matrix for debug */
void matrix_print(void)
{
}

inline
static void matrix_make(uint8_t code)
{

+ 0
- 54
converter/pc98_usb/matrix.c View File

@@ -46,20 +46,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) ((code>>3)&0xF)
#define COL(code) (code&0x07)

static bool is_modified = false;


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

static void pc98_inhibit_repeat(void)
{
@@ -128,8 +114,6 @@ void matrix_init(void)

uint8_t matrix_scan(void)
{
is_modified = false;

uint16_t code;
PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
_delay_us(30);
@@ -156,56 +140,18 @@ if (code == 0x60) {
// break code
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
}
} else {
// make code
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= (1<<COL(code));
is_modified = true;
}
}
return code;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

+ 2
- 54
converter/sun_usb/matrix.c View File

@@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h"
#include "debug.h"
#include "protocol/serial.h"
#include "led.h"
#include "host.h"


/*
@@ -46,20 +48,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) ((code>>3)&0xF)
#define COL(code) (code&0x07)

static bool is_modified = false;


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
@@ -92,8 +80,6 @@ void matrix_init(void)

uint8_t matrix_scan(void)
{
is_modified = false;

uint8_t code;
code = serial_recv();
if (!code) return 0;
@@ -131,56 +117,18 @@ uint8_t matrix_scan(void)
// break code
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
}
} else {
// make code
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= (1<<COL(code));
is_modified = true;
}
}
return code;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

+ 0
- 86
converter/terminal_usb/matrix.c View File

@@ -28,9 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

static void matrix_make(uint8_t code);
static void matrix_break(uint8_t code);
#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif


/*
@@ -49,20 +46,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) (code>>3)
#define COL(code) (code&0x07)

static bool is_modified = false;


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
@@ -93,8 +76,6 @@ uint8_t matrix_scan(void)
F0,
} state = RESET;

is_modified = false;

uint8_t code;
if ((code = ps2_host_recv())) {
debug("r"); debug_hex(code); debug(" ");
@@ -172,83 +153,17 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
#ifdef MATRIX_HAS_GHOST
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix_has_ghost_in_row(i))
return true;
}
#endif
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;

// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
return true;
}
return false;
}
#endif


inline
static void matrix_make(uint8_t code)
{
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= 1<<COL(code);
is_modified = true;
}
}

@@ -257,6 +172,5 @@ static void matrix_break(uint8_t code)
{
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
}
}

+ 0
- 48
converter/x68k_usb/matrix.c View File

@@ -50,18 +50,6 @@ static uint8_t matrix[MATRIX_ROWS];
static bool is_modified = false;


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
serial_init();
@@ -99,44 +87,8 @@ uint8_t matrix_scan(void)
return code;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

+ 0
- 86
converter/xt_usb/matrix.c View File

@@ -28,9 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

static void matrix_make(uint8_t code);
static void matrix_break(uint8_t code);
#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif

static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) (code>>3)
@@ -40,20 +37,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define PRINT_SCREEN (0x7C)
#define PAUSE (0x7D)

static bool is_modified = false;


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
@@ -131,8 +114,6 @@ uint8_t matrix_scan(void)
} state = INIT;


is_modified = false;

// 'pseudo break code' hack
if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) {
matrix_break(PAUSE);
@@ -236,83 +217,17 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
return is_modified;
}

inline
bool matrix_has_ghost(void)
{
#ifdef MATRIX_HAS_GHOST
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix_has_ghost_in_row(i))
return true;
}
#endif
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;

// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
return true;
}
return false;
}
#endif


inline
static void matrix_make(uint8_t code)
{
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= 1<<COL(code);
is_modified = true;
}
}

@@ -321,7 +236,6 @@ static void matrix_break(uint8_t code)
{
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
}
}


+ 0
- 28
keyboard/alps64/matrix.c View File

@@ -43,18 +43,6 @@ static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

#define LED_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0)
#define LED_OFF() do { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } while (0)
#define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0)
@@ -107,28 +95,12 @@ uint8_t matrix_scan(void)
return 1;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
pbin_reverse16(matrix_get_row(row));
print("\n");
}
}

/* Column pin configuration
* col: 0 1 2 3 4 5 6 7
* pin: B0 B1 B2 B3 B4 B5 B6 B7

+ 0
- 43
keyboard/gh60/matrix.c View File

@@ -43,18 +43,6 @@ static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
// initialize row and col
@@ -97,43 +85,12 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
if (debouncing) return false;
return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
pbin_reverse16(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop16(matrix[i]);
}
return count;
}

/* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
* pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 (Rev.A)

+ 0
- 59
keyboard/hbkb/matrix.c View File

@@ -41,26 +41,11 @@ static uint8_t debouncing = DEBOUNCE;
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];

#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif
static matrix_row_t read_cols(void);
static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
// JTAG disable for PORT F. write JTD bit twice within four cycles.
@@ -110,56 +95,12 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
if (debouncing) return false;
return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}

#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;

// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]))
return true;
}
return false;
}
#endif

inline
static matrix_row_t read_cols(void)
{

+ 0
- 41
keyboard/hhkb/matrix.c View File

@@ -43,18 +43,6 @@ static matrix_row_t _matrix0[MATRIX_ROWS];
static matrix_row_t _matrix1[MATRIX_ROWS];


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
#ifdef DEBUG
@@ -153,41 +141,12 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
if (matrix[i] != matrix_prev[i])
return true;
}
return false;
}

inline
bool matrix_has_ghost(void)
{
return false;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row)));
}
}

void matrix_power_up(void) {
KEY_POWER_ON();
}

+ 0
- 43
keyboard/onekey/matrix.c View File

@@ -43,18 +43,6 @@ static void unselect_rows(void);
static void select_row(uint8_t row);


inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}

inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}

void matrix_init(void)
{
debug_enable = true;
@@ -100,43 +88,12 @@ uint8_t matrix_scan(void)
return 1;
}

bool matrix_is_modified(void)
{
if (debouncing) return false;
return true;
}

inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}

inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
phex(row); print(": ");
pbin_reverse16(matrix_get_row(row));
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop16(matrix[i]);
}
return count;
}

/* Column pin configuration
* col: 0
* pin: B0

Loading…
Cancel
Save