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

This commit is contained in:
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
#include "config_common.h"
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6512
#define DEVICE_VER 0x0001

View file

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