1
0

Add USB to USB converter. unmature.

This commit is contained in:
tmk 2012-08-27 15:18:01 +09:00
parent d9b9098b20
commit bf9888f854
3 changed files with 25 additions and 2 deletions

View File

@ -78,6 +78,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define REPORT_KEYS 6 # define REPORT_KEYS 6
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct { typedef struct {
uint8_t mods; uint8_t mods;
uint8_t rserved; uint8_t rserved;
@ -92,4 +97,8 @@ typedef struct {
int8_t h; int8_t h;
} __attribute__ ((packed)) report_mouse_t; } __attribute__ ((packed)) report_mouse_t;
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_ERROR(code) (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED) #define IS_ERROR(code) (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED)
#define IS_ANY(code) (KB_A <= (code))
#define IS_KEY(code) (KB_A <= (code) && (code) <= KB_EXSEL) #define IS_KEY(code) (KB_A <= (code) && (code) <= KB_EXSEL)
#define IS_MOD(code) (KB_LCTRL <= (code) && (code) <= KB_RGUI) #define IS_MOD(code) (KB_LCTRL <= (code) && (code) <= KB_RGUI)
#define IS_FN(code) (KB_FN0 <= (code) && (code) <= KB_FN7) #define IS_FN(code) (KB_FN0 <= (code) && (code) <= KB_FN7)

View File

@ -1,14 +1,27 @@
#include <cstring.h>
#include "parser.h" #include "parser.h"
#include "usb_hid.h"
#include "leonardo_led.h" #include "leonardo_led.h"
#include "debug.h" #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) void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
{ {
::memcpy(&usb_hid_keyboard_report, buf, sizeof(report_keyboard_t));
usb_hid_time_stamp = millis();
LED_TX_TOGGLE; LED_TX_TOGGLE;
debug("KBDReport: "); debug("KBDReport: ");
for (uint8_t i = 0; i < len; i++) { debug_hex(usb_hid_keyboard_report.mods);
debug_hex(buf[i]); for (uint8_t i = 0; i < 6; i++) {
debug(" "); debug(" ");
debug_hex(usb_hid_keyboard_report.keys[i]);
} }
debug("\r\n"); debug("\r\n");
} }