some major steps toward making the usb-usb converter work

This commit is contained in:
Balz Guenat 2017-08-12 18:24:15 +02:00 committed by Jack Humbert
parent 42f895a4bc
commit 2aa5e44640
9 changed files with 59 additions and 24 deletions

View File

@ -31,6 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_ROWS 16
#define MATRIX_COLS 16
#define DIODE_DIRECTION CUSTOM_MATRIX
/* key combination for command */
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))

View File

@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "usb_usb.h"
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
/* 0: plain Qwerty without layer switching
* ,---------------. ,---------------. ,---------------.
* |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24|

View File

@ -146,7 +146,7 @@ SRC = matrix.cpp
# include $(TMK_DIR)/protocol/usb_hid.mk
include $(TMK_DIR)/protocol/usb_hid.mk
# include $(TMK_DIR)/protocol/lufa.mk
# include $(TMK_DIR)/common.mk
# include $(TMK_DIR)/rules.mk

View File

@ -94,6 +94,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_JYEN KC_INT3
#define KC_HENK KC_INT4
#define KC_MHEN KC_INT5
/* Korean specific */
#define KC_HAEN KC_LANG1
#define KC_HANJ KC_LANG2
/* Keypad */
#define KC_P1 KC_KP_1
#define KC_P2 KC_KP_2
@ -113,6 +116,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_PPLS KC_KP_PLUS
#define KC_PEQL KC_KP_EQUAL
#define KC_PENT KC_KP_ENTER
/* Unix function key */
#define KC_EXEC KC_EXECUTE
#define KC_SLCT KC_SELECT
#define KC_AGIN KC_AGAIN
#define KC_PSTE KC_PASTE
/* Mousekey */
#define KC_MS_U KC_MS_UP
#define KC_MS_D KC_MS_DOWN

View File

@ -4,30 +4,14 @@
#include "debug.h"
report_keyboard_t usb_hid_keyboard_report;
uint16_t usb_hid_time_stamp;
void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
{
bool is_error = false;
report_keyboard_t *report = (report_keyboard_t *)buf;
::memcpy(&report, buf, sizeof(report_keyboard_t));
time_stamp = millis();
dprintf("KBDReport: %02X %02X", report->mods, report->reserved);
dprintf("input %d: %02X %02X", hid->GetAddress(), report.mods, report.reserved);
for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
if (IS_ERROR(report->keys[i])) {
is_error = true;
}
dprintf(" %02X", report->keys[i]);
dprintf(" %02X", report.keys[i]);
}
dprint("\r\n");
// ignore error and not send report to computer
if (is_error) {
dprint("Error usage! \r\n");
return;
}
::memcpy(&usb_hid_keyboard_report, buf, sizeof(report_keyboard_t));
usb_hid_time_stamp = millis();
}

View File

@ -2,11 +2,14 @@
#define PARSER_H
#include "hid.h"
#include "report.h"
class KBDReportParser : public HIDReportParser
{
public:
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
report_keyboard_t report;
uint16_t time_stamp;
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
};
#endif

View File

@ -1,4 +1,42 @@
#----------------------------------------------------------------------------
# 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 = usb_hid_test