~ruther/qmk_firmware

9dc5432a3e16ca4ee42d84cacbcfa7aeee97d2f9 — fauxpark 5 years ago 7e8f239
[Keyboard] XT converter: add config_common.h include and fix E0 collision (#7341)

2 files changed, 23 insertions(+), 21 deletions(-)

M keyboards/converter/xt_usb/config.h
M keyboards/converter/xt_usb/matrix.c
M keyboards/converter/xt_usb/config.h => keyboards/converter/xt_usb/config.h +2 -0
@@ 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

M keyboards/converter/xt_usb/matrix.c => keyboards/converter/xt_usb/matrix.c +21 -21
@@ 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;