1
0

Merge remote-tracking branch 'refs/remotes/tmk/master'

This commit is contained in:
di0ib 2016-10-19 19:36:03 -10:00
commit 61b54bd6ee
34 changed files with 4550 additions and 3927 deletions

View File

@ -31,44 +31,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host.h" #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 has_media_keys = false;
static bool is_iso_layout = false; static bool is_iso_layout = false;
static bool is_modified = false;
static report_mouse_t mouse_report = {}; static report_mouse_t mouse_report = {};
// matrix state buffer(1:on, 0:off) // matrix state buffer(1:on, 0:off)
#if (MATRIX_COLS <= 8) static matrix_row_t matrix[MATRIX_ROWS];
static uint8_t matrix[MATRIX_ROWS];
#else
static uint16_t matrix[MATRIX_ROWS];
#endif
#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif
static void register_key(uint8_t key); 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) void matrix_init(void)
{ {
// LED on // LED on
@ -208,8 +182,6 @@ uint8_t matrix_scan(void)
uint16_t codes; uint16_t codes;
uint8_t key0, key1; uint8_t key0, key1;
is_modified = false;
codes = extra_key; codes = extra_key;
extra_key = 0xFFFF; extra_key = 0xFFFF;
@ -328,93 +300,12 @@ uint8_t matrix_scan(void)
return 1; return 1;
} }
bool matrix_is_modified(void)
{
return is_modified;
}
inline inline
bool matrix_has_ghost(void) matrix_row_t matrix_get_row(uint8_t row)
{
#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
{ {
return matrix[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 inline
static void register_key(uint8_t key) static void register_key(uint8_t key)
{ {
@ -426,5 +317,4 @@ static void register_key(uint8_t key)
} else { } else {
matrix[row] |= (1<<col); matrix[row] |= (1<<col);
} }
is_modified = true;
} }

View File

@ -52,18 +52,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define COL(code) (code&0x07) #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) static void enable_break(void)
{ {
print("Enable break: "); print("Enable break: ");
@ -120,28 +108,12 @@ uint8_t matrix_scan(void)
return 1; return 1;
} }
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & (1<<col));
}
inline inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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 inline
static void matrix_make(uint8_t code) static void matrix_make(uint8_t code)
{ {

View File

@ -46,18 +46,6 @@ static uint8_t _matrix0[MATRIX_ROWS];
static void register_key(uint8_t key); 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) void matrix_init(void)
{ {
m0110_init(); m0110_init();
@ -95,48 +83,12 @@ uint8_t matrix_scan(void)
return 1; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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 inline
static void register_key(uint8_t key) static void register_key(uint8_t key)
{ {

View File

@ -47,20 +47,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) ((code>>3)&0xF) #define ROW(code) ((code>>3)&0xF)
#define COL(code) (code&0x07) #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) void matrix_init(void)
{ {
@ -74,8 +60,6 @@ void matrix_init(void)
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
is_modified = false;
uint8_t code; uint8_t code;
code = news_recv(); code = news_recv();
if (code == 0) { if (code == 0) {
@ -87,56 +71,18 @@ uint8_t matrix_scan(void)
// break code // break code
if (matrix_is_on(ROW(code), COL(code))) { if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code)); matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
} }
} else { } else {
// make code // make code
if (!matrix_is_on(ROW(code), COL(code))) { if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= (1<<COL(code)); matrix[ROW(code)] |= (1<<COL(code));
is_modified = true;
} }
} }
return code; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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;
}

View File

@ -66,20 +66,6 @@ static uint8_t matrix[MATRIX_ROWS];
static bool is_modified = false; 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 #ifndef NEXT_KBD_LED1_ON
#define NEXT_KBD_LED1_ON #define NEXT_KBD_LED1_ON
#endif #endif
@ -227,19 +213,6 @@ uint8_t matrix_scan(void)
return 1; 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 */ /* matrix state on row */
inline inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
@ -247,11 +220,6 @@ uint8_t matrix_get_row(uint8_t row)
return matrix[row]; return matrix[row];
} }
/* print matrix for debug */
void matrix_print(void)
{
}
inline inline
static void matrix_make(uint8_t code) static void matrix_make(uint8_t code)
{ {

View File

@ -46,20 +46,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) ((code>>3)&0xF) #define ROW(code) ((code>>3)&0xF)
#define COL(code) (code&0x07) #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) static void pc98_inhibit_repeat(void)
{ {
@ -128,8 +114,6 @@ void matrix_init(void)
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
is_modified = false;
uint16_t code; uint16_t code;
PC98_RDY_PORT |= (1<<PC98_RDY_BIT); PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
_delay_us(30); _delay_us(30);
@ -156,56 +140,18 @@ if (code == 0x60) {
// break code // break code
if (matrix_is_on(ROW(code), COL(code))) { if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code)); matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
} }
} else { } else {
// make code // make code
if (!matrix_is_on(ROW(code), COL(code))) { if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= (1<<COL(code)); matrix[ROW(code)] |= (1<<COL(code));
is_modified = true;
} }
} }
return code; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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;
}

View File

@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h" #include "matrix.h"
#include "debug.h" #include "debug.h"
#include "protocol/serial.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 ROW(code) ((code>>3)&0xF)
#define COL(code) (code&0x07) #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) void matrix_init(void)
{ {
@ -92,8 +80,6 @@ void matrix_init(void)
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
is_modified = false;
uint8_t code; uint8_t code;
code = serial_recv(); code = serial_recv();
if (!code) return 0; if (!code) return 0;
@ -131,56 +117,18 @@ uint8_t matrix_scan(void)
// break code // break code
if (matrix_is_on(ROW(code), COL(code))) { if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code)); matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
} }
} else { } else {
// make code // make code
if (!matrix_is_on(ROW(code), COL(code))) { if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= (1<<COL(code)); matrix[ROW(code)] |= (1<<COL(code));
is_modified = true;
} }
} }
return code; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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;
}

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_make(uint8_t code);
static void matrix_break(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 ROW(code) (code>>3)
#define COL(code) (code&0x07) #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) void matrix_init(void)
{ {
@ -93,8 +76,6 @@ uint8_t matrix_scan(void)
F0, F0,
} state = RESET; } state = RESET;
is_modified = false;
uint8_t code; uint8_t code;
if ((code = ps2_host_recv())) { if ((code = ps2_host_recv())) {
debug("r"); debug_hex(code); debug(" "); debug("r"); debug_hex(code); debug(" ");
@ -172,83 +153,17 @@ uint8_t matrix_scan(void)
return 1; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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 inline
static void matrix_make(uint8_t code) static void matrix_make(uint8_t code)
{ {
if (!matrix_is_on(ROW(code), COL(code))) { if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= 1<<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))) { if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code)); matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
} }
} }

View File

@ -1,4 +1,5 @@
TARGET = usb_usb_unimap TARGET = usb_usb_unimap
UNIMAP_ENABLE = yes UNIMAP_ENABLE = yes
KEYMAP_SECTION_ENABLE = yes KEYMAP_SECTION_ENABLE = yes
#LUFA_DEBUG = yes
include Makefile include Makefile

View File

@ -59,7 +59,6 @@ In case of Leonardo push reset button then run command. Serial port name(COM17)
Limitation Limitation
---------- ----------
Only supports 'HID Boot protocol'. Only supports 'HID Boot protocol'.
Not support keyboard LED yet.
Note that the converter can host only USB "boot protocol" keyboard(6KRO), not NKRO, it is possible to support NKRO keyboard but you will need to write HID report parser for that. Every NKRO keyboard can have different HID report and it is difficult to support all kind of NKRO keyboards in the market. Note that the converter can host only USB "boot protocol" keyboard(6KRO), not NKRO, it is possible to support NKRO keyboard but you will need to write HID report parser for that. Every NKRO keyboard can have different HID report and it is difficult to support all kind of NKRO keyboards in the market.
@ -77,6 +76,7 @@ Update
------ ------
2014/12/11 Added Hub support(confirmed with HHKB pro2) 2014/12/11 Added Hub support(confirmed with HHKB pro2)
2016/09/10 Unimap editor support 2016/09/10 Unimap editor support
2016/10/18 Fix LED state at startup

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "timer.h" #include "timer.h"
#include "matrix.h" #include "matrix.h"
#include "led.h" #include "led.h"
#include "host.h"
#include "keyboard.h"
/* KEY CODE to Matrix /* KEY CODE to Matrix
@ -151,6 +153,16 @@ uint8_t matrix_scan(void) {
dprintf("host.Task: %d\n", timer); dprintf("host.Task: %d\n", timer);
} }
static uint8_t usb_state = 0;
if (usb_state != usb_host.getUsbTaskState()) {
usb_state = usb_host.getUsbTaskState();
dprintf("usb_state: %02X\n", usb_state);
// restore LED state when keyboard comes up
if (usb_state == USB_STATE_RUNNING) {
keyboard_set_leds(host_keyboard_leds());
}
}
return 1; return 1;
} }

View File

@ -50,18 +50,6 @@ static uint8_t matrix[MATRIX_ROWS];
static bool is_modified = false; 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) void matrix_init(void)
{ {
serial_init(); serial_init();
@ -99,44 +87,8 @@ uint8_t matrix_scan(void)
return code; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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;
}

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_make(uint8_t code);
static void matrix_break(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]; static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) (code>>3) #define ROW(code) (code>>3)
@ -40,20 +37,6 @@ static uint8_t matrix[MATRIX_ROWS];
#define PRINT_SCREEN (0x7C) #define PRINT_SCREEN (0x7C)
#define PAUSE (0x7D) #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) void matrix_init(void)
{ {
@ -131,8 +114,6 @@ uint8_t matrix_scan(void)
} state = INIT; } state = INIT;
is_modified = false;
// 'pseudo break code' hack // 'pseudo break code' hack
if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) { if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) {
matrix_break(PAUSE); matrix_break(PAUSE);
@ -236,83 +217,17 @@ uint8_t matrix_scan(void)
return 1; 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 inline
uint8_t matrix_get_row(uint8_t row) uint8_t matrix_get_row(uint8_t row)
{ {
return matrix[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 inline
static void matrix_make(uint8_t code) static void matrix_make(uint8_t code)
{ {
if (!matrix_is_on(ROW(code), COL(code))) { if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= 1<<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))) { if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code)); matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
} }
} }

View File

@ -1,61 +1,21 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension). # Target file name (without extension).
TARGET = alps64 TARGET ?= alps64
# Directory common source filess exist # Directory common source filess exist
TMK_DIR = ../../tmk_core TMK_DIR ?= ../../tmk_core
# Directory keyboard dependent files exist # Directory keyboard dependent files exist
TARGET_DIR = . TARGET_DIR ?= .
# project specific files # project specific files
SRC = matrix.c \ SRC ?= matrix.c \
led.c led.c
CONFIG_H = config.h CONFIG_H ?= config.h
# MCU name # MCU name
MCU = atmega32u2 MCU ?= atmega32u2
# Processor frequency. # Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the # This will define a symbol, F_CPU, in all source code files equal to the
@ -68,14 +28,14 @@ MCU = atmega32u2
# does not *change* the processor frequency - it should merely be updated to # does not *change* the processor frequency - it should merely be updated to
# reflect the processor speed set externally so that the code can use accurate # reflect the processor speed set externally so that the code can use accurate
# software delays. # software delays.
F_CPU = 16000000 F_CPU ?= 16000000
# #
# LUFA specific # LUFA specific
# #
# Target architecture (see library "Board Types" documentation). # Target architecture (see library "Board Types" documentation).
ARCH = AVR8 ARCH ?= AVR8
# Input clock frequency. # Input clock frequency.
# This will define a symbol, F_USB, in all source code files equal to the # This will define a symbol, F_USB, in all source code files equal to the
@ -88,7 +48,7 @@ ARCH = AVR8
# #
# If no clock division is performed on the input clock inside the AVR (via the # If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU) F_USB ?= $(F_CPU)
# Interrupt driven control endpoint task(+60) # Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
@ -100,27 +60,35 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Atmel DFU loader 4096 # Atmel DFU loader 4096
# LUFA bootloader 4096 # LUFA bootloader 4096
# USBaspLoader 2048 # USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096 BOOTLOADER_SIZE ?= 4096
OPT_DEFS += -DBOOTLOADER_SIZE=$(BOOTLOADER_SIZE)
# Build Options # Build Options
# comment out to disable the options. # comment out to disable the options.
# #
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700) MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400) CONSOLE_ENABLE ?= yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration COMMAND_ENABLE ?= yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover #NKRO_ENABLE ?= yes # USB Nkey Rollover
#ACTIONMAP_ENABLE = yes # Use 16bit action codes in keymap instead of 8bit keycodes #ACTIONMAP_ENABLE ?= yes # Use 16bit action codes in keymap instead of 8bit keycodes
ifdef ACTIONMAP_ENABLE #
# Keymap file
#
ifeq (yes,$(strip $(UNIMAP_ENABLE)))
KEYMAP_FILE = unimap
else
ifeq (yes,$(strip $(ACTIONMAP_ENABLE)))
KEYMAP_FILE = actionmap KEYMAP_FILE = actionmap
else else
KEYMAP_FILE = keymap KEYMAP_FILE = keymap
endif endif
endif
ifdef KEYMAP ifdef KEYMAP
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC) SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
else else

View File

@ -0,0 +1,3 @@
TARGET = alps64_actionmap
ACTIONMAP_ENABLE = yes # Use 16bit action codes in keymap instead of 8bit keycodes
include Makefile

View File

@ -1,5 +1,4 @@
# build firmware for keymap editor TARGET = alps64_editor
#
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
KEYMAP = editor KEYMAP = editor
include Makefile include Makefile

View File

@ -0,0 +1,4 @@
TARGET = alps64_unimap
UNIMAP_ENABLE = yes
KEYMAP_SECTION_ENABLE = yes
include Makefile

File diff suppressed because it is too large Load Diff

View File

@ -43,18 +43,6 @@ static void unselect_rows(void);
static void select_row(uint8_t row); 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_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0)
#define LED_OFF() 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) #define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0)
@ -107,28 +95,12 @@ uint8_t matrix_scan(void)
return 1; return 1;
} }
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}
inline inline
matrix_row_t matrix_get_row(uint8_t row) matrix_row_t matrix_get_row(uint8_t row)
{ {
return matrix[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 /* Column pin configuration
* col: 0 1 2 3 4 5 6 7 * col: 0 1 2 3 4 5 6 7
* pin: B0 B1 B2 B3 B4 B5 B6 B7 * pin: B0 B1 B2 B3 B4 B5 B6 B7

View File

@ -0,0 +1,64 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "unimap_trans.h"
#define AC_FN0 ACTION_LAYER_MOMENTARY(1)
#ifdef KEYMAP_SECTION_ENABLE
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
#endif
/*
* Universal keyboard layout
* ,-----------------------------------------------.
* |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
* ,---. |-----------------------------------------------| ,-----------. ,-----------.
* |Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|
* `---' `-----------------------------------------------' `-----------' `-----------'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
* |-----------------------------------------------------------| |-----------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +|
* |-----------------------------------------------------------| `-----------' |---------------|
* |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,|
* |-----------------------------------------------------------| ,---. |---------------|
* |Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|KP=|
* |-----------------------------------------------------------| ,-----------. |---------------|
* |Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent|
* `-----------------------------------------------------------' `-----------' `---------------'
*/
UNIMAP(
NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,
ESC, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS,BSPC, NO, NO, NO, NO, NO, NO, NO,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, NO, NO, NO, NO, NO, NO, NO,
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NO, ENT, NO, NO, NO, NO,
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, NO, RSFT, NO, NO, NO, NO, NO,
LCTL,LGUI,LALT,NO, SPC, NO, NO, RALT,RGUI,APP, FN0, NO, NO, NO, NO, NO, NO
),
UNIMAP(
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, TRNS,PENT, TRNS,TRNS,TRNS,TRNS,
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,
TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS
),
};

View File

@ -0,0 +1,63 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UNIMAP_TRNAS_H
#define UNIMAP_TRNAS_H
#include <stdint.h>
#include <avr/pgmspace.h>
#include "unimap.h"
/* Mapping to Universal keyboard layout
* ,-----------------------------------------------------------.
* |` | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ |
* |-----------------------------------------------------------|
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter |
* |-----------------------------------------------------------|
* |Shft| \| Z| X| C| V| B| N| M| ,| .| /|Shift |Esc|
* |-----------------------------------------------------------'
* |Ctrl|Gui |Alt | Space |App |Alt |Gui |Ctrl |
* `-----------------------------------------------------------'
*
* ,-----------------------------------------------------------.
* |36 |37 |46 |47 |56 |57 |66 |67 |76 |77 |06 |07 |17 |26 |27 |
* |-----------------------------------------------------------|
* |34 |35 |44 |45 |54 |55 |64 |65 |75 |05 |15 |16 |25 |24 |
* |-----------------------------------------------------------|
* |32 |33 |43 |52 |53 |63 |73 |74 |03 |04 |13 |14 | 23 |
* |-----------------------------------------------------------|
* |31 |41 |42 |51 |61 |62 |71 |72 |01 |02 |11 |12 |21 |22 |
* |-----------------------------------------------------------|
* |30 |40 |50 | 60 |70 |00 |10 |20 |
* `-----------------------------------------------------------'
*/
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
{ UNIMAP_RALT, UNIMAP_M, UNIMAP_COMM, UNIMAP_K, UNIMAP_L, UNIMAP_O, UNIMAP_0, UNIMAP_MINS }, /* 00-07 */
{ UNIMAP_RGUI, UNIMAP_DOT, UNIMAP_SLSH, UNIMAP_SCLN, UNIMAP_QUOT, UNIMAP_P, UNIMAP_LBRC, UNIMAP_EQL }, /* 10-17 */
{ UNIMAP_RCTL, UNIMAP_RSFT, UNIMAP_ESC, UNIMAP_ENT, UNIMAP_BSLS, UNIMAP_RBRC, UNIMAP_JYEN, UNIMAP_BSPC }, /* 20-27 */
{ UNIMAP_LCTL, UNIMAP_LSFT, UNIMAP_CAPS, UNIMAP_A, UNIMAP_TAB, UNIMAP_Q, UNIMAP_GRV, UNIMAP_1 }, /* 30-37 */
{ UNIMAP_LGUI, UNIMAP_NUBS, UNIMAP_Z, UNIMAP_S, UNIMAP_W, UNIMAP_E, UNIMAP_2, UNIMAP_3 }, /* 40-47 */
{ UNIMAP_LALT, UNIMAP_X, UNIMAP_D, UNIMAP_F, UNIMAP_R, UNIMAP_T, UNIMAP_4, UNIMAP_5 }, /* 50-57 */
{ UNIMAP_SPC, UNIMAP_C, UNIMAP_V, UNIMAP_G, UNIMAP_Y, UNIMAP_U, UNIMAP_6, UNIMAP_7 }, /* 60-67 */
{ UNIMAP_APP, UNIMAP_B, UNIMAP_N, UNIMAP_H, UNIMAP_J, UNIMAP_I, UNIMAP_8, UNIMAP_9 }, /* 70-77 */
};
#endif

View File

@ -43,18 +43,6 @@ static void unselect_rows(void);
static void select_row(uint8_t row); 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) void matrix_init(void)
{ {
// initialize row and col // initialize row and col
@ -97,43 +85,12 @@ uint8_t matrix_scan(void)
return 1; 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 inline
matrix_row_t matrix_get_row(uint8_t row) matrix_row_t matrix_get_row(uint8_t row)
{ {
return matrix[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 /* Column pin configuration
* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 * 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) * pin: F0 F1 E6 C7 C6 B6 D4 B1 B0 B5 B4 D7 D6 B3 (Rev.A)

View File

@ -41,26 +41,11 @@ static uint8_t debouncing = DEBOUNCE;
static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[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 matrix_row_t read_cols(void);
static void unselect_rows(void); static void unselect_rows(void);
static void select_row(uint8_t row); 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) void matrix_init(void)
{ {
// JTAG disable for PORT F. write JTD bit twice within four cycles. // JTAG disable for PORT F. write JTD bit twice within four cycles.
@ -110,56 +95,12 @@ uint8_t matrix_scan(void)
return 1; 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 inline
matrix_row_t matrix_get_row(uint8_t row) matrix_row_t matrix_get_row(uint8_t row)
{ {
return matrix[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 inline
static matrix_row_t read_cols(void) static matrix_row_t read_cols(void)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -43,18 +43,6 @@ static matrix_row_t _matrix0[MATRIX_ROWS];
static matrix_row_t _matrix1[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) void matrix_init(void)
{ {
#ifdef DEBUG #ifdef DEBUG
@ -153,41 +141,12 @@ uint8_t matrix_scan(void)
return 1; 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 inline
matrix_row_t matrix_get_row(uint8_t row) matrix_row_t matrix_get_row(uint8_t row)
{ {
return matrix[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) { void matrix_power_up(void) {
KEY_POWER_ON(); KEY_POWER_ON();
} }

View File

@ -43,18 +43,6 @@ static void unselect_rows(void);
static void select_row(uint8_t row); 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) void matrix_init(void)
{ {
debug_enable = true; debug_enable = true;
@ -100,43 +88,12 @@ uint8_t matrix_scan(void)
return 1; 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 inline
matrix_row_t matrix_get_row(uint8_t row) matrix_row_t matrix_get_row(uint8_t row)
{ {
return matrix[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 /* Column pin configuration
* col: 0 * col: 0
* pin: B0 * pin: B0

View File

@ -45,10 +45,17 @@ void sleep_led_disable(void)
TIMSK1 &= ~_BV(OCIE1A); TIMSK1 &= ~_BV(OCIE1A);
} }
void sleep_led_toggle(void)
__attribute__ ((weak))
void sleep_led_on(void)
{ {
/* Disable Compare Match Interrupt */ led_set(1<<USB_LED_CAPS_LOCK);
TIMSK1 ^= _BV(OCIE1A); }
__attribute__ ((weak))
void sleep_led_off(void)
{
led_set(0);
} }
@ -86,10 +93,10 @@ ISR(TIMER1_COMPA_vect)
// LED on // LED on
if (timer.pwm.count == 0) { if (timer.pwm.count == 0) {
led_set(1<<USB_LED_CAPS_LOCK); sleep_led_on();
} }
// LED off // LED off
if (timer.pwm.count == pgm_read_byte(&breathing_table[timer.pwm.index])) { if (timer.pwm.count == pgm_read_byte(&breathing_table[timer.pwm.index])) {
led_set(0); sleep_led_off();
} }
} }

View File

@ -96,7 +96,11 @@ void suspend_idle(uint8_t time)
void suspend_power_down(void) void suspend_power_down(void)
{ {
#ifdef SUSPEND_MODE_STANDBY #ifdef NO_SUSPEND_POWER_DOWN
;
#elif defined(SUSPEND_MODE_NOPOWERSAVE)
;
#elif defined(SUSPEND_MODE_STANDBY)
standby(); standby();
#elif defined(SUSPEND_MODE_IDLE) #elif defined(SUSPEND_MODE_IDLE)
idle(); idle();

View File

@ -182,14 +182,22 @@ static bool command_common(uint8_t code)
{ {
#ifdef KEYBOARD_LOCK_ENABLE #ifdef KEYBOARD_LOCK_ENABLE
static host_driver_t *host_driver = 0; static host_driver_t *host_driver = 0;
#endif
#ifdef SLEEP_LED_ENABLE
static bool sleep_led_test = false;
#endif #endif
switch (code) { switch (code) {
#ifdef SLEEP_LED_ENABLE #ifdef SLEEP_LED_ENABLE
case KC_Z: case KC_Z:
// test breathing sleep LED // test breathing sleep LED
print("Sleep LED test\n"); print("Sleep LED test\n");
sleep_led_toggle(); if (sleep_led_test) {
sleep_led_disable();
led_set(host_keyboard_leds()); led_set(host_keyboard_leds());
} else {
sleep_led_enable();
}
sleep_led_test = !sleep_led_test;
break; break;
#endif #endif
#ifdef BOOTMAGIC_ENABLE #ifdef BOOTMAGIC_ENABLE

View File

@ -54,7 +54,7 @@ void host_keyboard_send(report_keyboard_t *report)
(*driver->send_keyboard)(report); (*driver->send_keyboard)(report);
if (debug_keyboard) { if (debug_keyboard) {
dprint("keyboard_report: "); dprint("keyboard: ");
for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
dprintf("%02X ", report->raw[i]); dprintf("%02X ", report->raw[i]);
} }
@ -75,6 +75,10 @@ void host_system_send(uint16_t report)
if (!driver) return; if (!driver) return;
(*driver->send_system)(report); (*driver->send_system)(report);
if (debug_keyboard) {
dprintf("system: %04X\n", report);
}
} }
void host_consumer_send(uint16_t report) void host_consumer_send(uint16_t report)
@ -84,6 +88,10 @@ void host_consumer_send(uint16_t report)
if (!driver) return; if (!driver) return;
(*driver->send_consumer)(report); (*driver->send_consumer)(report);
if (debug_keyboard) {
dprintf("consumer: %04X\n", report);
}
} }
uint16_t host_last_sysytem_report(void) uint16_t host_last_sysytem_report(void)

View File

@ -33,7 +33,6 @@ uint8_t matrix_cols(void)
__attribute__ ((weak)) __attribute__ ((weak))
void matrix_clear(void) void matrix_clear(void)
{ {
matrix_init();
} }
__attribute__ ((weak)) __attribute__ ((weak))
@ -55,23 +54,22 @@ void matrix_print(void)
#elif (MATRIX_COLS <= 32) #elif (MATRIX_COLS <= 32)
print("r/c 0123456789ABCDEF0123456789ABCDEF\n"); print("r/c 0123456789ABCDEF0123456789ABCDEF\n");
#endif #endif
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
xprintf("%02X:", row);
#if (MATRIX_COLS <= 8) #if (MATRIX_COLS <= 8)
print_bin_reverse8(matrix_get_row(row)); xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)),
#elif (MATRIX_COLS <= 16) #elif (MATRIX_COLS <= 16)
print_bin_reverse16(matrix_get_row(row)); xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)),
#elif (MATRIX_COLS <= 32) #elif (MATRIX_COLS <= 32)
print_bin_reverse32(matrix_get_row(row)); xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)),
#endif #endif
#ifdef MATRIX_HAS_GHOST #ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) { matrix_has_ghost_in_row(row) ? " <ghost" : ""
print(" <ghost"); #else
} ""
#endif #endif
print("\n"); );
} }
} }

View File

@ -32,6 +32,10 @@ typedef uint32_t matrix_row_t;
#error "MATRIX_COLS: invalid value" #error "MATRIX_COLS: invalid value"
#endif #endif
#if (MATRIX_ROWS > 255)
#error "MATRIX_ROWS must not exceed 255"
#endif
#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<<col)) #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<<col))

View File

@ -2,20 +2,10 @@
#define SLEEP_LED_H #define SLEEP_LED_H
#ifdef SLEEP_LED_ENABLE
void sleep_led_init(void); void sleep_led_init(void);
void sleep_led_enable(void); void sleep_led_enable(void);
void sleep_led_disable(void); void sleep_led_disable(void);
void sleep_led_toggle(void); void sleep_led_on(void);
void sleep_led_off(void);
#else
#define sleep_led_init()
#define sleep_led_enable()
#define sleep_led_disable()
#define sleep_led_toggle()
#endif
#endif #endif