[Keyboard] XT converter: add config_common.h include and fix E0 collision (#7341)

master
fauxpark 2019-11-13 19:38:37 +11:00 committed by James Young
parent 7e8f239c2e
commit 9dc5432a3e
2 changed files with 23 additions and 21 deletions

View File

@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
#include "config_common.h"
#define VENDOR_ID 0xFEED #define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6512 #define PRODUCT_ID 0x6512
#define DEVICE_VER 0x0001 #define DEVICE_VER 0x0001

View File

@ -99,25 +99,25 @@ static uint8_t move_e0code(uint8_t code) {
uint8_t matrix_scan(void) uint8_t matrix_scan(void)
{ {
static enum { static enum {
INIT, XT_STATE_INIT,
E0, XT_STATE_E0,
// Pause: E1 1D 45, E1 9D C5 // Pause: E1 1D 45, E1 9D C5
E1, XT_STATE_E1,
E1_1D, XT_STATE_E1_1D,
E1_9D, XT_STATE_E1_9D,
} state = INIT; } state = XT_STATE_INIT;
uint8_t code = xt_host_recv(); uint8_t code = xt_host_recv();
if (!code) return 0; if (!code) return 0;
xprintf("%02X ", code); xprintf("%02X ", code);
switch (state) { switch (state) {
case INIT: case XT_STATE_INIT:
switch (code) { switch (code) {
case 0xE0: case 0xE0:
state = E0; state = XT_STATE_E0;
break; break;
case 0xE1: case 0xE1:
state = E1; state = XT_STATE_E1;
break; break;
default: default:
if (code < 0x80) if (code < 0x80)
@ -127,59 +127,59 @@ uint8_t matrix_scan(void)
break; break;
} }
break; break;
case E0: case XT_STATE_E0:
switch (code) { switch (code) {
case 0x2A: case 0x2A:
case 0xAA: case 0xAA:
case 0x36: case 0x36:
case 0xB6: case 0xB6:
//ignore fake shift //ignore fake shift
state = INIT; state = XT_STATE_INIT;
break; break;
default: default:
if (code < 0x80) if (code < 0x80)
matrix_make(move_e0code(code)); matrix_make(move_e0code(code));
else else
matrix_break(move_e0code(code & 0x7F)); matrix_break(move_e0code(code & 0x7F));
state = INIT; state = XT_STATE_INIT;
break; break;
} }
break; break;
case E1: case XT_STATE_E1:
switch (code) { switch (code) {
case 0x1D: case 0x1D:
state = E1_1D; state = XT_STATE_E1_1D;
break; break;
case 0x9D: case 0x9D:
state = E1_9D; state = XT_STATE_E1_9D;
break; break;
default: default:
state = INIT; state = XT_STATE_INIT;
break; break;
} }
break; break;
case E1_1D: case XT_STATE_E1_1D:
switch (code) { switch (code) {
case 0x45: case 0x45:
matrix_make(0x55); matrix_make(0x55);
break; break;
default: default:
state = INIT; state = XT_STATE_INIT;
break; break;
} }
break; break;
case E1_9D: case XT_STATE_E1_9D:
switch (code) { switch (code) {
case 0x45: case 0x45:
matrix_break(0x55); matrix_break(0x55);
break; break;
default: default:
state = INIT; state = XT_STATE_INIT;
break; break;
} }
break; break;
default: default:
state = INIT; state = XT_STATE_INIT;
} }
matrix_scan_quantum(); matrix_scan_quantum();
return 1; return 1;