m0110: Attempt international layout support

This commit is contained in:
tmk 2022-12-23 15:16:51 +09:00
parent 8fd2ba90e7
commit 2dd9483383
3 changed files with 57 additions and 4 deletions

View file

@ -48,6 +48,7 @@ static void register_key(uint8_t key);
void matrix_init(void) void matrix_init(void)
{ {
debug_enable = true;
m0110_init(); m0110_init();
// initialize matrix state: all keys off // initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
@ -61,16 +62,34 @@ void matrix_init(void)
return; return;
} }
static bool m0110_intl = false;
static uint8_t m0110_model = 0xFF;
static uint8_t get_m0110_model(void)
{
m0110_send(M0110_MODEL);
return m0110_recv();
}
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
uint8_t key; uint8_t key;
if (m0110_model == 0xFF) {
m0110_model = get_m0110_model();
if (m0110_model == 0xFF) {
return 0;
}
xprintf("model: %02X\n", m0110_model);
// TODO: detect international M0110 and config m0110_intl
}
is_modified = false; is_modified = false;
key = m0110_recv_key(); key = m0110_recv_key();
if (key == M0110_NULL) { if (key == M0110_NULL) {
return 0; return 0;
} else if (key == M0110_ERROR) { } else if (key == M0110_ERROR) {
m0110_model = 0xFF;
return 0; return 0;
} else { } else {
is_modified = true; is_modified = true;
@ -89,9 +108,37 @@ uint8_t matrix_get_row(uint8_t row)
return matrix[row]; return matrix[row];
} }
static uint8_t intl_key(uint8_t key)
{
switch (key) {
// Intl code -> TMK matrix
case 0x06: return 0x0A; // Non-US bslash
case 0x07: return 0x06; // Z
case 0x08: return 0x07; // X
case 0x09: return 0x08; // C
case 0x0B: return 0x09; // V
case 0x2D: return 0x0B; // B
case 0x2E: return 0x2D; // N
case 0x2B: return 0x2E; // M
case 0x2F: return 0x2B; // ,
case 0x2C: return 0x2F; // .
case 0x0A: return 0x2C; // /
case 0x34: return 0x31; // Space
case 0x31: return 0x34; // RGUI
case 0x24: return 0x2A; // bslash
case 0x2A: return 0x24; // Enter
}
return key;
}
inline inline
static void register_key(uint8_t key) static void register_key(uint8_t key)
{ {
if (m0110_intl) {
key = (key & 0x80) | intl_key(key & 0x7F);
dprintf("<%02X> ", key);
}
if (key&0x80) { if (key&0x80) {
matrix[ROW(key)] &= ~(1<<COL(key)); matrix[ROW(key)] &= ~(1<<COL(key));
} else { } else {

View file

@ -89,7 +89,7 @@ const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
{ {
UNIMAP_C, // 0x08 UNIMAP_C, // 0x08
UNIMAP_V, // 0x09 UNIMAP_V, // 0x09
UNIMAP_NO, // 0x0A UNIMAP_NONUS_BSLASH, // 0x0A
UNIMAP_B, // 0x0B UNIMAP_B, // 0x0B
#endif #endif
UNIMAP_Q, // 0x0C UNIMAP_Q, // 0x0C

View file

@ -495,9 +495,15 @@ RAW CODE:
MODEL NUMBER: MODEL NUMBER:
M0110: 0x09 00001001 : model number 4 (100) M0110(GS536): 0x03 00000011 : model number 1 (001)
M0110A: 0x0B 00001011 : model number 5 (101) M0110(GS624): 0x09 00001001 : model number 4 (100)
M0110 & M0120: ??? M0110A(M923): 0x0B 00001011 : model number 5 (101)
M0110AJ(M839): 0x0B 00001011 : model number 5 (101)
M0110AJ(A615): 0x0B 00001011 : model number 5 (101)
M0120(BCG9GRM0120): 0x11 00010001
M0120 & M0110(G536): 0x13 00010011
M0120 & M0110(G624): 0x19 00011001
M0120 & M0110A(M923): 0x1B 00011011
Scan Code Scan Code