Update 1.2

This commit is contained in:
NicoHood 2014-06-22 00:32:31 +02:00
parent f75b2ddabd
commit 1c7e8ac4d7
546 changed files with 2464 additions and 25190 deletions

View file

@ -298,7 +298,7 @@ public:
void press(uint8_t b);
void release(uint8_t b);
void releaseAll(void);
inline void buttons(uint32_t b){ _report.whole32[0]=b; }
inline void buttons(uint32_t b){ _report.buttons=b; }
inline void xAxis(uint16_t a){ _report.xAxis=a; }
inline void yAxis(uint16_t a){ _report.yAxis=a; }
inline void zAxis(uint16_t a){ _report.zAxis=a; }
@ -327,6 +327,7 @@ public:
void press(uint8_t b);
void release(uint8_t b);
void releaseAll(void);
inline void buttons(uint8_t b){ _report.buttons=b; }
inline void xAxis(uint16_t a){ _report.xAxis=a; }
inline void yAxis(uint16_t a){ _report.yAxis=a; }

View file

@ -153,6 +153,7 @@ typedef union{
// 2 Buttons, 2 Axis
uint8_t whole8[3];
uint16_t whole16[3/2];
uint8_t buttons :2;
struct{
uint16_t button1 :1;

2
1.0.x/Readme.md Normal file
View file

@ -0,0 +1,2 @@
**Move and replace** these files to:
C:\Arduino\arduino-1.0.5-r2\hardware\arduino\cores\arduino

993
1.5.x/HID.cpp Normal file
View file

@ -0,0 +1,993 @@
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "HID.h"
//================================================================================
// HID Leonardo/Micro
//================================================================================
#if defined(USBCON)
HID_ HID;
HID_::HID_(void){
// empty
}
void HID_::begin(void){
// empty
}
void HID_::end(void){
// empty
}
void HID_::sendReport(uint8_t ReportID, const void* HIDReport, uint8_t length){
HID_SendReport(ReportID, HIDReport, length);
}
#ifdef HID_ENABLED
//================================================================================
//================================================================================
// HID report descriptor
#define LSB(_x) ((_x) & 0xFF)
#define MSB(_x) ((_x) >> 8)
#define RAWHID_USAGE_PAGE 0xFFC0
#define RAWHID_USAGE 0x0C00
#define RAWHID_TX_SIZE 64
#define RAWHID_RX_SIZE 64
extern const u8 _hidReportDescriptor[] PROGMEM;
const u8 _hidReportDescriptor[] = {
#ifdef HID_MOUSE_ENABLE
// Mouse
0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x85, HID_REPORTID_MouseReport,// REPORT_ID
// 5 buttons
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x05, // USAGE_MAXIMUM (Button 5)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x05, // REPORT_COUNT (5)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
// reserved
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x03, // REPORT_SIZE (3)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
// x, y, wheel
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x03, // REPORT_COUNT (3)
0x81, 0x06, // INPUT (Data,Var,Rel)
// end
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
#endif
#ifdef HID_KEYBOARD_ENABLE
// Keyboard
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x85, HID_REPORTID_KeyboardReport, // REPORT_ID
0x05, 0x07, // USAGE_PAGE (Keyboard)
// modifiers
0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x08, // REPORT_COUNT (8)
0x81, 0x02, // INPUT (Data,Var,Abs)
// reserved byte
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
// Key[6] Array
0x95, 0x06, // REPORT_COUNT (6)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x65, // LOGICAL_MAXIMUM (101)
0x05, 0x07, // USAGE_PAGE (Keyboard)
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
// LEDs for num lock etc
//0x05, 0x08, /* USAGE_PAGE (LEDs) */
//0x19, 0x01, /* USAGE_MINIMUM (Num Lock) */
//0x29, 0x05, /* USAGE_MAXIMUM (Kana) */
//0x95, 0x05, /* REPORT_COUNT (5) */
//0x75, 0x01, /* REPORT_SIZE (1) */
//0x91, 0x02, /* OUTPUT (Data,Var,Abs) */
// Reserved 3 bits
//0x95, 0x01, /* REPORT_COUNT (1) */
//0x75, 0x03, /* REPORT_SIZE (3) */
//0x91, 0x03, /* OUTPUT (Cnst,Var,Abs) */
// end
0xc0, // END_COLLECTION
#endif
#ifdef HID_RAWKEYBOARD_ENABLE
// RAW HID
0x06, 0xC0, 0xFF,
0x0A, 0x00, 0x0C,
0xA1, 0x01, // Collection 0x01
0x85, HID_REPORTID_RawKeyboardReport, // REPORT_ID
0x75, 0x08, // report size = 8 bits
0x15, 0x00, // logical minimum = 0
0x26, 0xFF, 0x00, // logical maximum = 255
0x95, 64, // report count TX
0x09, 0x01, // usage
0x81, 0x02, // Input (array)
0x95, 64, // report count RX
0x09, 0x02, // usage
0x91, 0x02, // Output (array)
0xC0, // end collection
#endif
#ifdef HID_MEDIA_ENABLE
// Media
0x05, 0x0C, // usage page (consumer device)
0x09, 0x01, // usage -- consumer control
0xA1, 0x01, // collection (application)
0x85, HID_REPORTID_MediaReport, // report id
// 4 media Keys
0x15, 0x00, //logical minimum
0x26, 0xFF, 0xFF, //logical maximum (3ff)
0x19, 0x00, // usage minimum (0)
0x2A, 0xFF, 0xFF, //usage maximum (3ff)
0x95, 0x04, //report count (4)
0x75, 0x10, //report size (16)
0x81, 0x00, //input
0xC0, //end collection
#endif
#ifdef HID_SYSTEM_ENABLE
// System
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x80, // USAGE (System Control)
0xa1, 0x01, // COLLECTION (Application)
0x85, HID_REPORTID_SystemReport, // REPORT_ID
// 1 system key
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x19, 0x00, // USAGE_MINIMUM (Undefined)
0x29, 0xff, // USAGE_MAXIMUM (System Menu Down)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0, // END_COLLECTION
#endif
#ifdef HID_GAMEPAD1_ENABLE
// Gamepad1
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Game Pad)
0xa1, 0x01, // COLLECTION (Application)
0x85, HID_REPORTID_Gamepad1Report, // REPORT_ID
// 32 Buttons
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x20, // USAGE_MAXIMUM (Button 32)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x20, // REPORT_COUNT (32)
0x81, 0x02, // INPUT (Data,Var,Abs)
// 6 16bit Axis
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x32, // USAGE (Z)
0x09, 0x33, // USAGE (Rx)
0x09, 0x34, // USAGE (Ry)
0x09, 0x35, // USAGE (Rz)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x27, 0xff, 0xff, 0x00, 0x00, // LOGICAL_MAXIMUM (65535)
0x75, 0x10, // REPORT_SIZE (16)
0x95, 0x06, // REPORT_COUNT (6)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
// 2 Hat Switches
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x39, // USAGE (Hat switch)
0x09, 0x39, // USAGE (Hat switch)
0x15, 0x01, // LOGICAL_MINIMUM (1)
0x25, 0x08, // LOGICAL_MAXIMUM (8)
0x95, 0x02, // REPORT_COUNT (2)
0x75, 0x04, // REPORT_SIZE (4)
0x81, 0x02, // INPUT (Data,Var,Abs)
// 8bit Throttle + Rudder
//0x05, 0x02, // USAGE_PAGE (Simulation Controls)
//0xa1, 0x00, // COLLECTION (Physical)
//0x15, 0x00, // LOGICAL_MINIMUM (0)
//0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
//0x09, 0xbb, // USAGE (Throttle)
//0x09, 0xba, // USAGE (Rudder)
//0x75, 0x08, // REPORT_SIZE (8)
//0x95, 0x02, // REPORT_COUNT (2)
//0x81, 0x02, // INPUT (Data,Var,Abs)
//0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
#endif
#ifdef HID_GAMEPAD2_ENABLE
// Gamepad2
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Game Pad)
0xa1, 0x01, // COLLECTION (Application)
0x85, HID_REPORTID_Gamepad2Report, // REPORT_ID
// 32 Buttons
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x20, // USAGE_MAXIMUM (Button 32)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x20, // REPORT_COUNT (32)
0x81, 0x02, // INPUT (Data,Var,Abs)
// 6 16bit Axis
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x09, 0x32, // USAGE (Z)
0x09, 0x33, // USAGE (Rx)
0x09, 0x34, // USAGE (Ry)
0x09, 0x35, // USAGE (Rz)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x27, 0xff, 0xff, 0x00, 0x00, // LOGICAL_MAXIMUM (65535)
0x75, 0x10, // REPORT_SIZE (16)
0x95, 0x06, // REPORT_COUNT (6)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
// 2 Hat Switches
0x09, 0x39, // USAGE (Hat switch)
0x09, 0x39, // USAGE (Hat switch)
0x15, 0x01, // LOGICAL_MINIMUM (1)
0x25, 0x08, // LOGICAL_MAXIMUM (8)
0x95, 0x02, // REPORT_COUNT (2)
0x75, 0x04, // REPORT_SIZE (4)
0x81, 0x02, // INPUT (Data,Var,Abs)
// 8bit Throttle + Rudder
//0x05, 0x02, // USAGE_PAGE (Simulation Controls)
//0xa1, 0x00, // COLLECTION (Physical)
//0x15, 0x00, // LOGICAL_MINIMUM (0)
//0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
//0x09, 0xbb, // USAGE (Throttle)
//0x09, 0xba, // USAGE (Rudder)
//0x75, 0x08, // REPORT_SIZE (8)
//0x95, 0x02, // REPORT_COUNT (2)
//0x81, 0x02, // INPUT (Data,Var,Abs)
//0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
#endif
#ifdef HID_JOYSTICK1_ENABLE
// Joystick1
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x85, HID_REPORTID_Joystick1Report, // REPORT_ID
0xa1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x02, // USAGE_MAXIMUM (Button 2)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x03, // LOGICAL_MAXIMUM (1023)
0x75, 0x0a, // REPORT_SIZE (10)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x02, // REPORT_SIZE (2)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
#endif
#ifdef HID_JOYSTICK2_ENABLE
// Joystick2
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x85, HID_REPORTID_Joystick2Report, // REPORT_ID
0xa1, 0x00, // COLLECTION (Physical)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x02, // USAGE_MAXIMUM (Button 2)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x03, // LOGICAL_MAXIMUM (1023)
0x75, 0x0a, // REPORT_SIZE (10)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x02, // REPORT_SIZE (2)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
#endif
};
extern const HIDDescriptor _hidInterface PROGMEM;
const HIDDescriptor _hidInterface =
{
D_INTERFACE(HID_INTERFACE,1,3,0,0),
D_HIDREPORT(sizeof(_hidReportDescriptor)),
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01)
};
//================================================================================
//================================================================================
// Driver
u8 _hid_protocol = 1;
u8 _hid_idle = 1;
#define WEAK __attribute__ ((weak))
int WEAK HID_GetInterface(u8* interfaceNum)
{
interfaceNum[0] += 1; // uses 1
return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
}
int WEAK HID_GetDescriptor(int /* i */)
{
return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor));
}
void WEAK HID_SendReport(u8 id, const void* data, int len)
{
USB_Send(HID_TX, &id, 1);
USB_Send(HID_TX | TRANSFER_RELEASE,data,len);
}
bool WEAK HID_Setup(Setup& setup)
{
u8 r = setup.bRequest;
u8 requestType = setup.bmRequestType;
if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
{
if (HID_GET_REPORT == r)
{
//HID_GetReport();
return true;
}
if (HID_GET_PROTOCOL == r)
{
//Send8(_hid_protocol); // TODO
return true;
}
}
if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
{
if (HID_SET_PROTOCOL == r)
{
_hid_protocol = setup.wValueL;
return true;
}
if (HID_SET_IDLE == r)
{
_hid_idle = setup.wValueL;
return true;
}
}
return false;
}
#endif
//================================================================================
// HID Uno/Mega
//================================================================================
#else /* if defined(USBCON) */
HID_ HID;
HID_::HID_(void){
// empty
}
void HID_::begin(void){
Serial.begin(115200);
}
void HID_::end(void){
Serial.end();
}
void HID_::sendReport(uint8_t ReportID, const void* HIDReport, uint8_t length){
// write the Report via Protocol and checksum. 16bit for each sending
// send control address
NHPwriteChecksum(NHP_ADDRESS_CONTROL, (NHP_USAGE_ARDUINOHID<<8)|ReportID);
const uint8_t* report = (const uint8_t*)HIDReport;
for(int i = 0; i<length;i++){
uint8_t data0=report[i++];
uint8_t data1=0;
if(i!=length)
data1=report[i];
// valid HID reports start at Address 2
NHPwriteChecksum(2+i/2,(data1<<8) | data0);
}
}
#endif /* if defined(USBCON) */
// simple copy/modification of the NicoHoodProtocol writechecksum function
void HID_::NHPwriteChecksum(uint8_t address, uint16_t indata){
// writes two bytes with its inverse
uint32_t temp=~indata;
uint32_t data=(temp<<16)|indata;
// buffer for write operation
uint8_t writebuffer[6];
// start with the maximum size of blocks
uint8_t blocks=7;
// check for the first 7 bit block that doesnt fit into the first 3 bits
while(blocks>2){
uint8_t nextvalue=(data>>(7*(blocks-3)));
if(nextvalue>NHP_MASK_DATA_3BIT){
// special case for the MSB
if(blocks==7) {
writebuffer[0] = nextvalue;
blocks--;
}
break;
}
else{
// write the possible first 3 bits and check again after
writebuffer[0] = nextvalue;
blocks--;
}
}
// write the rest of the data bits
uint8_t datablocks=blocks-2;
while(datablocks>0){
writebuffer[datablocks] = data & NHP_MASK_DATA_7BIT;
data>>=7;
datablocks--;
}
// write lead + length mask
writebuffer[0] |= NHP_MASK_LEAD | (blocks <<3);
// write end mask
writebuffer[blocks-1] = NHP_MASK_END | ((address-1) & NHP_MASK_ADDRESS);
// write the buffer
Serial.write(writebuffer, blocks);
}
//================================================================================
// Mouse
//================================================================================
Mouse_ Mouse;
Mouse_::Mouse_(void){
// empty
}
void Mouse_::begin(void){
memset(&_report, 0, sizeof(_report));
HID.sendReport(HID_REPORTID_MouseReport, &_report, sizeof(_report));
}
void Mouse_::end(void){
begin();
}
void Mouse_::click(uint8_t b){
_report.buttons = b;
move(0,0,0);
_report.buttons = 0;
move(0,0,0);
}
void Mouse_::move(signed char x, signed char y, signed char wheel){
_report.xAxis=x;
_report.yAxis=y;
_report.wheel=wheel;
HID.sendReport(HID_REPORTID_MouseReport, &_report, sizeof(HID_MouseReport_Data_t));
}
void Mouse_::buttons(uint8_t b){
if (b != _report.buttons) {
_report.buttons = b;
move(0,0,0);
}
}
void Mouse_::press(uint8_t b){
buttons(_report.buttons | b);
}
void Mouse_::release(uint8_t b){
buttons(_report.buttons & ~b);
}
void Mouse_::releaseAll(void){
begin();
}
bool Mouse_::isPressed(uint8_t b){
if ((b & _report.buttons) > 0)
return true;
return false;
}
//================================================================================
// Keyboard
//================================================================================
Keyboard_ Keyboard;
Keyboard_::Keyboard_(void){
// empty
}
void Keyboard_::begin(void){
memset(&_report, 0, sizeof(_report));
HID.sendReport(HID_REPORTID_KeyboardReport, &_report, sizeof(_report));
}
void Keyboard_::end(void){
begin();
}
extern
const uint8_t _asciimap[128] PROGMEM;
#define SHIFT 0x80
const uint8_t _asciimap[128] =
{
0x00, // NUL
0x00, // SOH
0x00, // STX
0x00, // ETX
0x00, // EOT
0x00, // ENQ
0x00, // ACK
0x00, // BEL
0x2a, // BS Backspace
0x2b, // TAB Tab
0x28, // LF Enter
0x00, // VT
0x00, // FF
0x00, // CR
0x00, // SO
0x00, // SI
0x00, // DEL
0x00, // DC1
0x00, // DC2
0x00, // DC3
0x00, // DC4
0x00, // NAK
0x00, // SYN
0x00, // ETB
0x00, // CAN
0x00, // EM
0x00, // SUB
0x00, // ESC
0x00, // FS
0x00, // GS
0x00, // RS
0x00, // US
0x2c, // ' '
0x1e|SHIFT, // !
0x34|SHIFT, // "
0x20|SHIFT, // #
0x21|SHIFT, // $
0x22|SHIFT, // %
0x24|SHIFT, // &
0x34, // '
0x26|SHIFT, // (
0x27|SHIFT, // )
0x25|SHIFT, // *
0x2e|SHIFT, // +
0x36, // ,
0x2d, // -
0x37, // .
0x38, // /
0x27, // 0
0x1e, // 1
0x1f, // 2
0x20, // 3
0x21, // 4
0x22, // 5
0x23, // 6
0x24, // 7
0x25, // 8
0x26, // 9
0x33|SHIFT, // :
0x33, // ;
0x36|SHIFT, // <
0x2e, // =
0x37|SHIFT, // >
0x38|SHIFT, // ?
0x1f|SHIFT, // @
0x04|SHIFT, // A
0x05|SHIFT, // B
0x06|SHIFT, // C
0x07|SHIFT, // D
0x08|SHIFT, // E
0x09|SHIFT, // F
0x0a|SHIFT, // G
0x0b|SHIFT, // H
0x0c|SHIFT, // I
0x0d|SHIFT, // J
0x0e|SHIFT, // K
0x0f|SHIFT, // L
0x10|SHIFT, // M
0x11|SHIFT, // N
0x12|SHIFT, // O
0x13|SHIFT, // P
0x14|SHIFT, // Q
0x15|SHIFT, // R
0x16|SHIFT, // S
0x17|SHIFT, // T
0x18|SHIFT, // U
0x19|SHIFT, // V
0x1a|SHIFT, // W
0x1b|SHIFT, // X
0x1c|SHIFT, // Y
0x1d|SHIFT, // Z
0x2f, // [
0x31, // bslash
0x30, // ]
0x23|SHIFT, // ^
0x2d|SHIFT, // _
0x35, // `
0x04, // a
0x05, // b
0x06, // c
0x07, // d
0x08, // e
0x09, // f
0x0a, // g
0x0b, // h
0x0c, // i
0x0d, // j
0x0e, // k
0x0f, // l
0x10, // m
0x11, // n
0x12, // o
0x13, // p
0x14, // q
0x15, // r
0x16, // s
0x17, // t
0x18, // u
0x19, // v
0x1a, // w
0x1b, // x
0x1c, // y
0x1d, // z
0x2f|SHIFT, //
0x31|SHIFT, // |
0x30|SHIFT, // }
0x35|SHIFT, // ~
0 // DEL
};
// removed <--
//uint8_t USBPutChar(uint8_t c);
size_t Keyboard_::write(uint8_t c)
{
uint8_t p = press(c); // Keydown
//uint8_t r =
release(c); // Keyup
return (p); // just return the result of press() since release() almost always returns 1
}
// press() adds the specified key (printing, non-printing, or modifier)
// to the persistent key report and sends the report. Because of the way
// USB HID works, the host acts like the key remains pressed until we
// call release(), releaseAll(), or otherwise clear the report and resend.
size_t Keyboard_::press(uint8_t k)
{
uint8_t i;
if (k >= 136) { // it's a non-printing key (not a modifier)
k = k - 136;
} else if (k >= 128) { // it's a modifier key
_report.modifiers |= (1<<(k-128));
k = 0;
} else { // it's a printing key
k = pgm_read_byte(_asciimap + k);
if (!k) {
setWriteError();
return 0;
}
if (k & 0x80) { // it's a capital letter or other character reached with shift
_report.modifiers |= 0x02; // the left shift modifier
k &= 0x7F;
}
}
// Add k to the key report only if it's not already present
// and if there is an empty slot.
if (_report.keys[0] != k && _report.keys[1] != k &&
_report.keys[2] != k && _report.keys[3] != k &&
_report.keys[4] != k && _report.keys[5] != k) {
for (i=0; i<6; i++) {
if (_report.keys[i] == 0x00) {
_report.keys[i] = k;
break;
}
}
if (i == 6) {
setWriteError();
return 0;
}
}
HID.sendReport(HID_REPORTID_KeyboardReport, &_report, sizeof(_report));
return 1;
}
// release() takes the specified key out of the persistent key report and
// sends the report. This tells the OS the key is no longer pressed and that
// it shouldn't be repeated any more.
size_t Keyboard_::release(uint8_t k)
{
uint8_t i;
if (k >= 136) { // it's a non-printing key (not a modifier)
k = k - 136;
} else if (k >= 128) { // it's a modifier key
_report.modifiers &= ~(1<<(k-128));
k = 0;
} else { // it's a printing key
k = pgm_read_byte(_asciimap + k);
if (!k) {
return 0;
}
if (k & 0x80) { // it's a capital letter or other character reached with shift
_report.modifiers &= ~(0x02); // the left shift modifier
k &= 0x7F;
}
}
// Test the key report to see if k is present. Clear it if it exists.
// Check all positions in case the key is present more than once (which it shouldn't be)
for (i=0; i<6; i++) {
if (0 != k && _report.keys[i] == k) {
_report.keys[i] = 0x00;
}
}
HID.sendReport(HID_REPORTID_KeyboardReport, &_report, sizeof(_report));
return 1;
}
void Keyboard_::releaseAll(void){
begin();
}
//================================================================================
// Media
//================================================================================
Media_ Media;
Media_::Media_(void){
// empty
}
void Media_::begin(void){
memset(&_report, 0, sizeof(_report));
HID.sendReport(HID_REPORTID_MediaReport, &_report, sizeof(_report));
}
void Media_::end(void){
begin();
}
void Media_::write(uint16_t m){
press(m);
release(m);
}
void Media_::press(uint16_t m){
// search for a free spot
for (int i=0; i<sizeof(HID_MediaReport_Data_t)/2; i++) {
if(_report.whole16[i] == 0x00) {
_report.whole16[i] = m;
break;
}
}
HID.sendReport(HID_REPORTID_MediaReport, &_report, sizeof(_report));
}
void Media_::release(uint16_t m){
// search and release the keypress
for (int i=0; i<sizeof(HID_MediaReport_Data_t)/2; i++) {
if (_report.whole16[i] == m) {
_report.whole16[i] = 0x00;
// no break to delete multiple keys
}
}
HID.sendReport(HID_REPORTID_MediaReport, &_report, sizeof(_report));
}
void Media_::releaseAll(void){
begin();
}
//================================================================================
// System
//================================================================================
System_ System;
System_::System_(void){
// empty
}
void System_::begin(void){
uint8_t _report = 0;
HID.sendReport(HID_REPORTID_SystemReport, &_report, sizeof(_report));
}
void System_::end(void){
begin();
}
void System_::write(uint8_t s){
press(s);
release();
}
void System_::press(uint8_t s){
HID.sendReport(HID_REPORTID_SystemReport, &s, sizeof(s));
}
void System_::release(void){
begin();
}
void System_::releaseAll(void){
begin();
}
//================================================================================
// Gamepad
//================================================================================
Gamepad_ Gamepad1(HID_REPORTID_Gamepad1Report);
Gamepad_ Gamepad2(HID_REPORTID_Gamepad2Report);
Gamepad_::Gamepad_(uint8_t reportID){
_reportID = reportID;
// empty
}
void Gamepad_::begin(void){
memset(&_report, 0, sizeof(_report));
HID.sendReport(_reportID, &_report, sizeof(_report));
}
void Gamepad_::end(void){
begin();
}
void Gamepad_::write(void){
HID.sendReport(_reportID, &_report, sizeof(_report));
}
void Gamepad_::press(uint8_t b){
_report.buttons|=(uint32_t)1<<(b-1);
}
void Gamepad_::release(uint8_t b){
_report.buttons&=~((uint32_t)1<<(b-1));
}
void Gamepad_::releaseAll(void){
_report.buttons=0;
}
//================================================================================
// Joystick
//================================================================================
Joystick_ Joystick1(HID_REPORTID_Joystick1Report);
Joystick_ Joystick2(HID_REPORTID_Joystick2Report);
Joystick_::Joystick_(uint8_t reportID){
_reportID = reportID;
// empty
}
void Joystick_::begin(void){
memset(&_report, 0, sizeof(_report));
HID.sendReport(_reportID, &_report, sizeof(_report));
}
void Joystick_::end(void){
begin();
}
void Joystick_::write(void){
HID.sendReport(_reportID, &_report, sizeof(_report));;
}
void Joystick_::press(uint8_t b){
if(b==1) _report.button1=1;
else if(b==2) _report.button2=1;
}
void Joystick_::release(uint8_t b){
if(b==1) _report.button1=0;
else if(b==2) _report.button2=0;
}
void Joystick_::releaseAll(void){
_report.button1=0;
_report.button2=0;
}

342
1.5.x/HID.h Normal file
View file

@ -0,0 +1,342 @@
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef HID_H
#define HID_H
#include <Arduino.h>
#include "HID_Reports.h"
#ifdef USBCON
#include "Platform.h"
#include "USBAPI.h"
#include "USBDesc.h"
//================================================================================
//Settings
//================================================================================
// deactive unnecessary stuff for Leonardo/Micro
// reports needs to be <=255 bytes for leonardo/micro!
#define HID_MOUSE_ENABLE 54
#define HID_KEYBOARD_ENABLE 65-18 //18 for missing led out report = 47
//#define HID_RAWKEYBOARD_ENABLE 30
#define HID_MEDIA_ENABLE 25
#define HID_SYSTEM_ENABLE 24
#define HID_GAMEPAD1_ENABLE 71
//#define HID_GAMEPAD2_ENABLE 71
//#define HID_JOYSTICK1_ENABLE 51
//#define HID_JOYSTICK2_ENABLE 51
//#define HID_MIDI_ENABLE
#endif
//================================================================================
// HID
//================================================================================
//NHP Definitions
// Start Mask
#define NHP_MASK_START 0xC0 //B11|000000 the two MSB bits
#define NHP_MASK_LEAD 0xC0 //B11|000000
#define NHP_MASK_DATA 0x00 //B0|0000000 only the first MSB is important
#define NHP_MASK_END 0x80 //B10|000000
// Content Mask
#define NHP_MASK_LENGTH 0x38 //B00|111|000
#define NHP_MASK_COMMAND 0x0F //B0000|1111
#define NHP_MASK_DATA_7BIT 0x7F //B0|1111111
#define NHP_MASK_DATA_4BIT 0x0F //B0000|1111
#define NHP_MASK_DATA_3BIT 0x07 //B00000|111
#define NHP_MASK_ADDRESS 0x3F //B00|111111
// Reserved Addresses
#define NHP_ADDRESS_CONTROL 0x01
// Reserved Usages
#define NHP_USAGE_ARDUINOHID 0x01
class HID_{
public:
HID_(void);
void begin(void);
void end(void);
// everything public for your own modifications
void sendReport(uint8_t ReportID, const void* HIDReport, uint8_t length);
private:
// simple copy/modification of the NicoHoodProtocol writechecksum function
void NHPwriteChecksum(uint8_t address, uint16_t indata);
};
extern HID_ HID;
//================================================================================
// Mouse
//================================================================================
#define MOUSE_LEFT 0x01
#define MOUSE_RIGHT 0x02
#define MOUSE_MIDDLE 0x04
#define MOUSE_PREV 0x08
#define MOUSE_NEXT 0x10
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE | MOUSE_PREV | MOUSE_NEXT)
class Mouse_{
public:
Mouse_(void);
void begin(void);
void end(void);
void click(uint8_t b = MOUSE_LEFT);
void move(signed char x, signed char y, signed char wheel = 0);
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
void releaseAll(void);
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
private:
void buttons(uint8_t b);
HID_MouseReport_Data_t _report;
};
extern Mouse_ Mouse;
//================================================================================
// Keyboard
//================================================================================
#define KEY_LEFT_CTRL 0x80
#define KEY_LEFT_SHIFT 0x81
#define KEY_LEFT_ALT 0x82
#define KEY_LEFT_GUI 0x83
#define KEY_RIGHT_CTRL 0x84
#define KEY_RIGHT_SHIFT 0x85
#define KEY_RIGHT_ALT 0x86
#define KEY_RIGHT_GUI 0x87
#define KEY_UP_ARROW 0xDA
#define KEY_DOWN_ARROW 0xD9
#define KEY_LEFT_ARROW 0xD8
#define KEY_RIGHT_ARROW 0xD7
#define KEY_BACKSPACE 0xB2
#define KEY_TAB 0xB3
#define KEY_RETURN 0xB0
#define KEY_ESC 0xB1
#define KEY_INSERT 0xD1
#define KEY_DELETE 0xD4
#define KEY_PAGE_UP 0xD3
#define KEY_PAGE_DOWN 0xD6
#define KEY_HOME 0xD2
#define KEY_END 0xD5
#define KEY_CAPS_LOCK 0xC1
#define KEY_F1 0xC2
#define KEY_F2 0xC3
#define KEY_F3 0xC4
#define KEY_F4 0xC5
#define KEY_F5 0xC6
#define KEY_F6 0xC7
#define KEY_F7 0xC8
#define KEY_F8 0xC9
#define KEY_F9 0xCA
#define KEY_F10 0xCB
#define KEY_F11 0xCC
#define KEY_F12 0xCD
//Keyboard fixed/added missing Keys
#define KEY_PRINT 0xCE
#define KEY_SCROLL_LOCK 0xCF
#define KEY_PAUSE 0xD0
//Raw Keyboard definitions
#define RAW_KEYBOARD_LEFT_CTRL B00000001
#define RAW_KEYBOARD_LEFT_SHIFT B00000010
#define RAW_KEYBOARD_LEFT_ALT B00000100
#define RAW_KEYBOARD_LEFT_GUI B00001000
#define RAW_KEYBOARD_RIGHT_CTRL B00010000
#define RAW_KEYBOARD_RIGHT_SHIFT B00100000
#define RAW_KEYBOARD_RIGHT_ALT B01000000
#define RAW_KEYBOARD_RIGHT_GUI B10000000
#define RAW_KEYBOARD_UP_ARROW 0x52
#define RAW_KEYBOARD_DOWN_ARROW 0x51
#define RAW_KEYBOARD_LEFT_ARROW 0x50
#define RAW_KEYBOARD_RIGHT_ARROW 0x4F
#define RAW_KEYBOARD_SPACEBAR 0x2C
#define RAW_KEYBOARD_BACKSPACE 0x2A
#define RAW_KEYBOARD_TAB 0x2B
#define RAW_KEYBOARD_RETURN 0x28
#define RAW_KEYBOARD_ESC 0x29
#define RAW_KEYBOARD_INSERT 0x49
#define RAW_KEYBOARD_DELETE 0x4C
#define RAW_KEYBOARD_PAGE_UP 0x4B
#define RAW_KEYBOARD_PAGE_DOWN 0x4E
#define RAW_KEYBOARD_HOME 0x4A
#define RAW_KEYBOARD_END 0x4D
#define RAW_KEYBOARD_CAPS_LOCK 0x39
#define RAW_KEYBOARD_F1 0x3A
#define RAW_KEYBOARD_F2 0x3B
#define RAW_KEYBOARD_F3 0x3C
#define RAW_KEYBOARD_F4 0x3D
#define RAW_KEYBOARD_F5 0x3E
#define RAW_KEYBOARD_F6 0x3F
#define RAW_KEYBOARD_F7 0x40
#define RAW_KEYBOARD_F8 0x41
#define RAW_KEYBOARD_F9 0x42
#define RAW_KEYBOARD_F10 0x43
#define RAW_KEYBOARD_F11 0x44
#define RAW_KEYBOARD_F12 0x45
#define RAW_KEYBOARD_PRINT 0x46
#define RAW_KEYBOARD_SCROLL_LOCK 0x47
#define RAW_KEYBOARD_PAUSE 0x48
//Keyboard fixed/added missing Keys
#define KEY_PRINT 0xCE
#define KEY_SCROLL_LOCK 0xCF
#define KEY_PAUSE 0xD0
class Keyboard_ : public Print{
public:
Keyboard_(void);
void begin(void);
void end(void);
virtual size_t write(uint8_t k);
virtual size_t press(uint8_t k);
virtual size_t release(uint8_t k);
virtual void releaseAll(void);
private:
HID_KeyboardReport_Data_t _report;
};
extern Keyboard_ Keyboard;
//================================================================================
// Media
//================================================================================
#define MEDIA_FAST_FORWARD 0xB3
#define MEDIA_REWIND 0xB4
#define MEDIA_NEXT 0xB5
#define MEDIA_PREVIOUS 0xB6
#define MEDIA_STOP 0xB7
#define MEDIA_PLAY_PAUSE 0xCD
#define MEDIA_VOLUME_MUTE 0xE2
#define MEDIA_VOLUME_UP 0xE9
#define MEDIA_VOLUME_DOWN 0xEA
#define MEDIA_EMAIL_READER 0x18A
#define MEDIA_CALCULATOR 0x192
#define MEDIA_EXPLORER 0x194
#define MEDIA_BROWSER_HOME 0x223
#define MEDIA_BROWSER_BACK 0x224
#define MEDIA_BROWSER_FORWARD 0x225
#define MEDIA_BROWSER_REFRESH 0x227
#define MEDIA_BROWSER_BOOKMARKS 0x22A
class Media_{
public:
Media_(void);
void begin(void);
void end(void);
void write(uint16_t m);
void press(uint16_t m);
void release(uint16_t m);
void releaseAll(void);
private:
HID_MediaReport_Data_t _report;
};
extern Media_ Media;
//================================================================================
// System
//================================================================================
#define SYSTEM_POWER_DOWN 0x81
#define SYSTEM_SLEEP 0x82
#define SYSTEM_WAKE_UP 0x83
class System_{
public:
System_(void);
void begin(void);
void end(void);
void write(uint8_t s);
void press(uint8_t s);
void release(void);
void releaseAll(void);
};
extern System_ System;
//================================================================================
// Gamepad
//================================================================================
class Gamepad_{
public:
Gamepad_(uint8_t reportID);
void begin(void);
void end(void);
void write(void);
void press(uint8_t b);
void release(uint8_t b);
void releaseAll(void);
inline void buttons(uint32_t b){ _report.buttons=b; }
inline void xAxis(uint16_t a){ _report.xAxis=a; }
inline void yAxis(uint16_t a){ _report.yAxis=a; }
inline void zAxis(uint16_t a){ _report.zAxis=a; }
inline void rxAxis(uint16_t a){ _report.rxAxis=a; }
inline void ryAxis(uint16_t a){ _report.ryAxis=a; }
inline void rzAxis(uint16_t a){ _report.rzAxis=a; }
inline void dPad1(uint8_t d){ _report.dPad1=d; }
inline void dPad2(uint8_t d){ _report.dPad2=d; }
private:
HID_GamepadReport_Data_t _report;
uint8_t _reportID;
};
extern Gamepad_ Gamepad1;
extern Gamepad_ Gamepad2;
//================================================================================
// Joystick
//================================================================================
class Joystick_{
public:
Joystick_(uint8_t reportID);
void begin(void);
void end(void);
void write(void);
void press(uint8_t b);
void release(uint8_t b);
void releaseAll(void);
inline void buttons(uint8_t b){ _report.buttons=b; }
inline void xAxis(uint16_t a){ _report.xAxis=a; }
inline void yAxis(uint16_t a){ _report.yAxis=a; }
private:
HID_JoystickReport_Data_t _report;
uint8_t _reportID;
};
extern Joystick_ Joystick1;
extern Joystick_ Joystick2;
#endif

192
1.5.x/HID_Reports.h Normal file
View file

@ -0,0 +1,192 @@
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef HID_REPORTS_H
#define HID_REPORTS_H
//================================================================================
//Definitions
//================================================================================
// empty
//================================================================================
//Report Typedefinitions
//================================================================================
typedef union{
// mouse report: 5 buttons, position, wheel
uint8_t whole8[4];
uint16_t whole16[4/2];
uint32_t whole32[4/4];
struct{
uint8_t buttons:5;
uint8_t reserved:3;
int8_t xAxis;
int8_t yAxis;
int8_t wheel;
};
} HID_MouseReport_Data_t;
typedef union{
// Low level key report: up to 6 keys and shift, ctrl etc at once
uint8_t whole8[8];
uint16_t whole16[8/2];
uint32_t whole32[8/4];
struct{
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
};
} HID_KeyboardReport_Data_t;
typedef union{
// every usable media key possible. Only one at the same time.
uint8_t whole8[8];
uint16_t whole16[8/2];
uint32_t whole32[8/4];
struct{
uint16_t key1;
uint16_t key2;
uint16_t key3;
uint16_t key4;
};
} HID_MediaReport_Data_t;
typedef union{
// every usable system control key possible. Only one at the same time.
uint8_t whole8[1];
uint8_t key;
} HID_SystemReport_Data_t;
typedef union {
// 32 Buttons, 6 Axis, 2 D-Pads
uint8_t whole8[17];
uint16_t whole16[17/2];
uint32_t whole32[17/4];
uint32_t buttons;
struct{
uint8_t button1 :1;
uint8_t button2 :1;
uint8_t button3 :1;
uint8_t button4 :1;
uint8_t button5 :1;
uint8_t button6 :1;
uint8_t button7 :1;
uint8_t button8 :1;
uint8_t button9 :1;
uint8_t button10 :1;
uint8_t button11 :1;
uint8_t button12 :1;
uint8_t button13 :1;
uint8_t button14 :1;
uint8_t button15 :1;
uint8_t button16 :1;
uint8_t button17 :1;
uint8_t button18 :1;
uint8_t button19 :1;
uint8_t button20 :1;
uint8_t button21 :1;
uint8_t button22 :1;
uint8_t button23 :1;
uint8_t button24 :1;
uint8_t button25 :1;
uint8_t button26 :1;
uint8_t button27 :1;
uint8_t button28 :1;
uint8_t button29 :1;
uint8_t button30 :1;
uint8_t button31 :1;
uint8_t button32 :1;
uint16_t xAxis;
uint16_t yAxis;
uint16_t zAxis;
uint16_t rxAxis;
uint16_t ryAxis;
uint16_t rzAxis;
uint8_t dPad1: 4;
uint8_t dPad2: 4;
// deactivated because windows only supports 7 axis. should be enough.
//uint8_t throttle;
//uint8_t rudder;
};
} HID_GamepadReport_Data_t;
typedef union{
// 2 Buttons, 2 Axis
uint8_t whole8[3];
uint16_t whole16[3/2];
uint8_t buttons :2;
struct{
uint16_t button1 :1;
uint16_t button2 :1;
uint16_t xAxis :10;
uint16_t yAxis :10;
uint16_t reserved :2;
};
} HID_JoystickReport_Data_t;
typedef union{
HID_MouseReport_Data_t Mouse;
HID_KeyboardReport_Data_t Keyboard;
HID_MediaReport_Data_t Media;
HID_GamepadReport_Data_t Gamepad1;
HID_GamepadReport_Data_t Gamepad2;
HID_JoystickReport_Data_t Joystick1;
HID_JoystickReport_Data_t Joystick2;
} HID_HIDReport_Data_t;
/** Enum for the HID report IDs used in the device. */
typedef enum{
HID_REPORTID_MouseReport = 0x01, /**< Report ID for the Mouse report within the device. */
HID_REPORTID_KeyboardReport = 0x02, /**< Report ID for the Keyboard report within the device. */
HID_REPORTID_RawKeyboardReport=0x03, /**< Report ID for the Raw Keyboard report within the device. */
HID_REPORTID_MediaReport = 0x04, /**< Report ID for the Media report within the device. */
HID_REPORTID_SystemReport = 0x05, /**< Report ID for the Power report within the device. */
HID_REPORTID_Gamepad1Report = 0x06, /**< Report ID for the Gamepad1 report within the device. */
HID_REPORTID_Gamepad2Report = 0x07, /**< Report ID for the Gamepad2 report within the device. */
HID_REPORTID_Joystick1Report = 0x08, /**< Report ID for the Joystick1 report within the device. */
HID_REPORTID_Joystick2Report = 0x09, /**< Report ID for the Joystick2 report within the device. */
} HID_Report_IDs;
#endif

2
1.5.x/Readme.md Normal file
View file

@ -0,0 +1,2 @@
**Move and replace** these files to:
C:\Arduino\arduino-1.5.6-r2\hardware\arduino\avr\cores\arduino

141
1.5.x/USBAPI.h Normal file
View file

@ -0,0 +1,141 @@
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef __USBAPI__
#define __USBAPI__
#if defined(USBCON)
//================================================================================
//================================================================================
// USB
class USBDevice_
{
public:
USBDevice_();
bool configured();
void attach();
void detach(); // Serial port goes down too...
void poll();
};
extern USBDevice_ USBDevice;
//================================================================================
//================================================================================
// Serial over CDC (Serial1 is the physical port)
struct ring_buffer;
#if (RAMEND < 1000)
#define SERIAL_BUFFER_SIZE 16
#else
#define SERIAL_BUFFER_SIZE 64
#endif
class Serial_ : public Stream
{
public:
void begin(unsigned long);
void begin(unsigned long, uint8_t);
void end(void);
virtual int available(void);
virtual void accept(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
operator bool();
volatile uint8_t _rx_buffer_head;
volatile uint8_t _rx_buffer_tail;
unsigned char _rx_buffer[SERIAL_BUFFER_SIZE];
};
extern Serial_ Serial;
#define HAVE_CDCSERIAL
//================================================================================
//================================================================================
// Low level API
typedef struct
{
uint8_t bmRequestType;
uint8_t bRequest;
uint8_t wValueL;
uint8_t wValueH;
uint16_t wIndex;
uint16_t wLength;
} Setup;
//================================================================================
//================================================================================
// HID 'Driver'
#include "HID.h"
int HID_GetInterface(uint8_t* interfaceNum);
int HID_GetDescriptor(int i);
bool HID_Setup(Setup& setup);
void HID_SendReport(uint8_t id, const void* data, int len);
//================================================================================
//================================================================================
// MSC 'Driver'
int MSC_GetInterface(uint8_t* interfaceNum);
int MSC_GetDescriptor(int i);
bool MSC_Setup(Setup& setup);
bool MSC_Data(uint8_t rx,uint8_t tx);
//================================================================================
//================================================================================
// CSC 'Driver'
int CDC_GetInterface(uint8_t* interfaceNum);
int CDC_GetDescriptor(int i);
bool CDC_Setup(Setup& setup);
//================================================================================
//================================================================================
#define TRANSFER_PGM 0x80
#define TRANSFER_RELEASE 0x40
#define TRANSFER_ZERO 0x20
int USB_SendControl(uint8_t flags, const void* d, int len);
int USB_RecvControl(void* d, int len);
uint8_t USB_Available(uint8_t ep);
int USB_Send(uint8_t ep, const void* data, int len); // blocking
int USB_Recv(uint8_t ep, void* data, int len); // non-blocking
int USB_Recv(uint8_t ep); // non-blocking
void USB_Flush(uint8_t ep);
#endif
#endif /* if defined(USBCON) */

View file

@ -1,9 +1,9 @@
:1000000073C100008DC100008BC1000089C10000D8
:1000100087C1000085C1000083C1000081C10000CC
:100020007FC100007DC100007BC100000C948508E9
:100030000C942E0975C1000073C1000071C100004D
:100020007FC100007DC100007BC100000C948408EA
:100030000C942D0975C1000073C1000071C100004E
:100040006FC100006DC100006BC1000069C10000FC
:1000500067C1000065C1000063C10000C4C30000A7
:1000500067C1000065C1000063C10000C3C30000A8
:100060005FC100005DC100005BC1000059C100001C
:1000700057C1000030034100720064007500690040
:100080006E006F00200048006F006F0064006C007D
@ -16,7 +16,7 @@
:1000F00000020A0000000705040240000107058312
:10010000024000010904020001030000000921115E
:1001100001000122B801070581032000011201102E
:1001200001EF020108EB03684E11000102DC01053A
:1001200001EF020108EB03684E12000102DC010539
:10013000010902A1010901A100850105091901298F
:10014000051500250195057501810295017503814D
:100150000305010930093109381581257F75089596
@ -45,430 +45,430 @@
:1002C0001901290215002501750195028102050118
:1002D00009300931150026FF03750A950281027560
:1002E0000295018103C0C00011241FBECFEFD2E0F0
:1002F000DEBFCDBF11E0A0E0B1E0ECE5FDE102C062
:1002F000DEBFCDBF11E0A0E0B1E0EAE5FDE102C064
:1003000005900D92AE32B107D9F712E0AEE2B1E03E
:1003100001C01D92A738B107E1F70CD10C94AC0EC7
:1003100001C01D92AF34B107E1F70DD10C94AB0EC3
:100320006FCECF93DF9384B7877F84BF28E10FB66A
:10033000F89420936000109260000FBE80E190E07E
:100340009093CD008093CC00CAECD0E096E09883E7
:10035000A8ECB0E082E08C93E9ECF0E02083539AC3
:100360005A9A5B9A10821C92188298838C9388E91F
:1003700080835B988AB180638AB98BB180638BB9C3
:10038000B5D684E085BD5F9A579A22982A9ADF9164
:10039000CF9108950F931F93CF93DF93C9E6D2E0D7
:10038000B4D684E085BD5F9A579A22982A9ADF9165
:10039000CF9108950F931F93CF93DF93C1E3D2E0E2
:1003A000082F10E00AC08091200180FF05C06881FD
:1003B00080E191E00E94140B2196CE018956924073
:1003B00080E191E00E94130B2196CE01815392407F
:1003C0008017910784F3DF91CF911F910F910895CA
:1003D000CF93DF9380913D02882319F010923B0266
:1003E0001DC060913B0270E0716081E01CD4C2E6E8
:1003D000CF93DF9380910502882319F010920302D6
:1003E0001DC06091030270E0716081E01BD4CAE21D
:1003F000D2E00AC08091200180FF05C0688180E1C1
:1004000091E00E94140B21969E0122563240809169
:10041000610290E0281739076CF3E0CFDF91CF91AC
:1004200008951F93CF93DF938BD3882309F47EC065
:100430001A9B7CC0A7D2813009F03BC0B2D280FFAA
:1004400038C080913B028111C3DFA8D280933B0268
:1004500010923D0291E1EFE3F2E0DF01292F1D92BE
:100460002A95E9F78530A9F038F4823081F084309C
:1004700071F08130C9F405C0883088F08A30A0F46A
:1004800011C094E090933C0280933E020EC088E03D
:1004900001C081E080933C0210923E0206C090931E
:1004A0003C02FACF83E0F6CF93DFDF91CF911F912B
:1004B00065C280913B028823C9F164D210913D024C
:1004C000C12FD0E090E09E012E5F3F4F35952795DC
:1004D0002F5F3F4F8217930729F560D2C15CDD4F34
:1004E0008883C12FCF5FC0933D0280913C028C175F
:1004F00049F057D2EC2FF0E0E15CFD4F80831E5FA6
:1005000010933D0290913C0280913D029813CDCF13
:1005100004C080E091E00E94A90D80913B0281110E
:10052000F8CFC3CFDF91CF911F9152CFDF91CF9101
:100530001F910895F6DE2FB7F89481E391E0909330
:10054000B2018093B1019093B4018093B3012FBFA6
:100550002FB7F89486EB91E09093370280933602A0
:1005600090933902809338022FBF789410923D0205
:1005700010923B02239A219AC1E3D1E08C0153E00F
:10058000E52E9FB7F8948091B5019FBF803819F18F
:1005900080E191E00E947C0B97FD1DC0E091B101CC
:1005A000F091B20180838091B1019091B2010196E6
:1005B0009093B2018093B101815B914021F4D0937B
:1005C000B201C093B1019FB7F8948091B5018F5FDC
:1005D0008093B5019FBF8FB7F894F0903A028FBF18
:1005E000A89904C080E68F1508F056C0A89A80919B
:1005F0003A02882341F15D98E0922E0124C0D4D1C3
:10060000877F39F080913B028111E2DE80916802A0
:10061000C1DEE0913802F09139028191F093390204
:10062000E0933802E653F24021F41093390200932C
:1006300038022FB7F89490913A02915090933A0271
:100640002FBFEFDEFA94F110DACF80912E018823CC
:10065000B9F080912E01815080932E01811110C03C
:1006600080913B028111B4DE9FD183FD07C0F090E1
:1006700068029AD187FDF3948F2D8CDE7FD15D9A2D
:1006800080912F01882341F080912F018150809328
:100690002F01811101C05C9A9FB7F8948091B50138
:1006A0009FBF882309F1E091B301F091B4019191CA
:1006B000F093B401E093B301E15BF14021F4D093F6
:1006C000B401C093B3012FB7F8948091B501815064
:1006D0008093B5012FBF8091C80085FFFCCF909318
:1006E000CE005C98E0922F0180E191E0EFD75BD7DC
:1006F00048CF08950895CF9380E091E00E94940D33
:10070000C82F80E191E06BD79091E20094609093C4
:10071000E200882321F0CC2311F080E001C080E3C7
:100720009BB18095906389238BB9CF9108951F93D6
:10073000CF93DF93EC01E98DE150E23028F4F0E053
:10074000E45DFE4F108101C010E0888D823009F415
:1007500018608A8D873031F0883031F0863029F486
:10076000126003C0146001C016605B9A1092C90049
:100770001092C8001092CA002C893D894E895F8969
:10078000211581EE38074105510579F0CA01B901FB
:10079000969587957795679560587B47814E9F4FD3
:1007A0000E946D0E2150310902C020E130E03093EB
:1007B000CD002093CC001093CA008C899D89AE890E
:1007C000BF898115914EA105B10511F480E001C0EA
:1007D00082E08093C80088E98093C9005B98DF912C
:1007E000CF911F9108951F920F920FB60F9211246F
:1007F0002F938F939F93EF93FF938091CE009091CF
:100800007E029430F1F4E0913602F0913702808359
:10081000E0913602F0913702CF01019690933702B2
:10082000809336028653924021F486EB91E09283C6
:1008300081839FB7F89480913A028F5F80933A0248
:100840009FBFFF91EF919F918F912F910F900FBEBE
:100850000F901F901895FC01208920FF02C05F981F
:1008600008955F9A8BB180638BB9089580E191E020
:1008700071D780E091E00C945D0C80910E01909115
:100880000F01009729F0019790930F0180930E01BB
:100890000895EF92FF920F931F93CF93DF937B0105
:1008A000C901E80110913C02EFE3F2E0412F50E072
:1008B000BF010E949C0EEBE3F2E08081D7018C9394
:1008C00018831982108280913E02DF91CF911F918F
:1008D0000F91FF90EF9008950895292F332723302B
:1008E0003105B1F04CF42130310509F439C0223022
:1008F000310509F03AC007C02132310539F1223201
:10090000310549F132C0EFE5F0E08EEB90E031C007
:1009100099278130910561F08230910581F0892B12
:1009200021F5EAEBF0E0E491F0E08AEB90E021C001
:10093000E6EAF0E0E491F0E086EA90E01AC0E4E74D
:10094000F0E0E491F0E084E790E013C0E9E0F0E04B
:100950008DE091E00EC0E8EBF1E08FE291E009C09C
:10096000E2E1F0E08DE191E004C0E0E0F0E080E061
:1009700090E0DA018D939C93CF01089588E08093F5
:100980002B01089580917002089560917102709119
:1009900072028091730290917402089580917102A5
:1009A000089580917202089580912B010895982FE7
:1009B00080912B018823E9F083FF0AC01092750211
:1009C00010927602109277021092780210927902B9
:1009D00087FF0DC040916802E42FF0E0E759FD4F1A
:1009E00080818093690281E08093680202C0109246
:1009F000680210926F0210927002109271021092AF
:100A00007202109273021092740210922B012091C4
:100A10006802E22FF0E0E759FD4F9083822F8F5F4D
:100A200080936802392F307C80917502303809F448
:100A300040C0303C09F05EC0882329F080E98093F3
:100A40002B0120936802292F287326952695269539
:100A5000223018F02730E1F40AC09F709F5F909316
:100A60006F021092750280912B0185603DC0492F65
:100A70004F7050E060E070E0409376025093770250
:100A8000609378027093790285E08093750256C076
:100A9000892F877090E0A0E0B0E080937602909379
:100AA0007702A0937802B0937902215020937502C7
:100AB00045C0282F2150209375028130C9F49F73BF
:100AC0009F5F909370028091760290917702A0913F
:100AD0007802B09179028093710290937202A09390
:100AE0007302B093740283E080932B0181E0089538
:100AF00080E507C0282F215020937502823030F402
:100B000080E380932B011092750218C04091760209
:100B100050917702609178027091790287E0440FDA
:100B2000551F661F771F8A95D1F7492B4093760290
:100B300050937702609378027093790280E0089571
:100B40000F931F9334DF8823A9F01CDF882391F0D3
:100B50001CDF8C0122273327DC01CB01AA27BB270E
:100B6000082719272A273B2781E00F3F1F4F210520
:100B7000310509F080E01F910F9108950F931F93A5
:100B8000A0916202ECE1F0E097E08A019B010E2E59
:100B900004C036952795179507950A94D2F7083023
:100BA00040F0A0936202973059F40093620296E0FD
:100BB00007C091503797A02F923039F70093620207
:100BC000A92FA25013C0EA2FF0E0EE59FD4F8A0181
:100BD0009B010F771127222733270083E7E07695C3
:100BE000679557954795EA95D1F7A150A111EBCF9D
:100BF000492F50E09A0163E0220F331F6A95E1F715
:100C0000206C3F6F30916202322B30936202FA0106
:100C1000EF59FD4F81508F738068808390936102FC
:100C20001F910F9108950F931F938B01AB01409576
:100C3000509560E070E0BA015527442720E030E08D
:100C4000402B512B622B732B1F910F9197CFBF928B
:100C5000CF92DF92EF92FF920F931F93CF93DF9388
:100C60007C018B01EA01D7D1B82E811132C02097C7
:100C700031F028813981021B130BE20EF31EC12CC7
:100C8000D12C22C08091E80085FD14C08091E8003D
:100C90008E778093E800209749F0888199818C0DA8
:100CA0009D1D9983888325E0B22E13C0B4D188237B
:100CB00059F00EC0F70181917F018093F10001503E
:100CC0001109FFEFCF1ADF0A01151105D9F601C08E
:100CD000B82E8B2DDF91CF911F910F91FF90EF9048
:100CE000DF90CF90BF9008952091850230918602C9
:100CF0002617370748F06115710539F42091E8008F
:100D00002E772093E80001C0B9019C0180E034C037
:100D100090917E02992309F443C0953009F442C0B2
:100D20009091E80093FD3AC09091E80092FD30C0A8
:100D30009091E80090FF20C08091F20090E0F901CE
:100D4000821B930B05C021912093F1006150710922
:100D50009F01280F391F6115710519F028303105E1
:100D600090F381E02830310509F080E09091E800AF
:100D70009E779093E8009F016115710549F68111F6
:100D8000C7CF06C080917E02882351F0853051F094
:100D90008091E80082FFF6CF80E0089581E0089519
:100DA00082E0089583E008956115710529F420918A
:100DB000E8002B772093E8009C0121C080917E02FF
:100DC000882381F1853041F18091E80083FD26C0C0
:100DD0008091E80082FFF2CFF90107C08091F10015
:100DE00081939F016150710929F09F018091F20068
:100DF0008111F4CF8091E8008B778093E800611532
:100E00007105E1F68091E80080FD0AC080917E02C4
:100E1000882341F08530B1F783E0089581E008959B
:100E200080E0089582E00895209185023091860245
:100E30002617370748F06115710539F42091E8004D
:100E40002E772093E80001C0B9019C0180E035C0F5
:100E500090917E02992309F444C0953009F443C06F
:100E60009091E80093FD3BC09091E80092FD31C065
:100E70009091E80090FF21C08091F20090E0F9018C
:100E8000821B930B06C024912093F1003196615090
:100E900071099C012E0F3F1F6115710519F0283053
:100EA000310588F381E02830310509F080E0909128
:100EB000E8009E779093E8009F016115710541F667
:100EC0008111C6CF06C080917E02882351F0853003
:100ED00051F08091E80082FFF6CF80E0089581E034
:100EE000089582E0089583E00895982F2CC0909390
:100EF000E900981739F07091EC002091ED005091C5
:100F0000F00003C0242F762F50E021FD02C09F5F28
:100F10001AC03091EB003E7F3093EB003091ED0032
:100F20003D7F3093ED003091EB0031603093EB006A
:100F30007093EC002093ED005093F0002091EE00B0
:100F400027FDE5CF07C0953090F28F708093E900C0
:100F500081E0089580E008950F931F93CF93DF936E
:100F6000062FEC0110E02EC09881911103C01F5F85
:100F7000259628C02C81E981FA816B81892F8F7099
:100F8000853010F080E021C0223010F056E001C022
:100F900052E028E030E040E003C04F5F220F331FF3
:100FA0002E173F07D0F34295407F452B991F992775
:100FB000991F6295660F660F607C692B96DF811121
:100FC000D6CFE0CF1013D0CF81E0DF91CF911F912A
:100FD0000F91089580917F0287FD05C08091E80000
:100FE00080FF0EC012C08091E80082FD05C0809194
:100FF0007E028111F8CF08958091E8008B7708C0B8
:1010000080917E028111EACF08958091E8008E7769
:101010008093E80008958091E4009091E50045E612
:101020002091EC0020FD1FC023C020917E022223CE
:1010300091F0253091F02091EB0025FD10C020911A
:10104000E4003091E5002817390751F34150C901F8
:1010500039F784E0089582E0089583E0089581E0FF
:10106000089580E008952091E80020FFDECFF9CFB9
:101070002091E80022FFD9CFF4CF41D043D0809116
:10108000D8008F778093D8008091D80080688093B3
:10109000D8008091D8008F7D8093D80084E089BDEE
:1010A00086E089BD09B400FEFDCF10927E02109249
:1010B0007A0210927C0210927B0242E060E080E0B3
:1010C00014DF8091E1008E7F8093E1008091E20047
:1010D00081608093E2008091E20088608093E2006A
:1010E0008091E0008E7F8093E0000895E3E6F0E0D9
:1010F00080818E7F808381E080937D02BECF1092BD
:10110000E20008951092E10008951F920F920FB629
:101110000F9211242F933F934F935F936F937F937D
:101120008F939F93AF93BF93EF93FF938091E100D1
:1011300082FF0AC08091E20082FF06C08091E10038
:101140008B7F8093E10099DB8091E10080FF17C0E5
:101150008091E20080FF13C08091E2008E7F809337
:10116000E2008091E20080618093E2008091D800EB
:1011700080628093D80019BC10927E02BBDA809105
:10118000E10084FF2FC08091E20084FF2BC084E047
:1011900089BD86E089BD09B400FEFDCF8091D800ED
:1011A0008F7D8093D8008091E1008F7E8093E10055
:1011B0008091E2008F7E8093E2008091E200816066
:1011C0008093E20080917A02882311F084E007C0C6
:1011D0008091E30087FF02C083E001C081E080933B
:1011E0007E0287DA8091E10083FF27C08091E200D0
:1011F00083FF23C08091E100877F8093E10082E03C
:1012000080937E0210927A028091E1008E7F80931B
:10121000E1008091E2008E7F8093E2008091E20005
:1012200080618093E20042E060E080E05EDE8091D9
:10123000F00088608093F000B5D1FF91EF91BF91ED
:10124000AF919F918F917F916F915F914F913F915E
:101250002F910F900FBE0F901F9018951F920F9215
:101260000FB60F9211242F933F934F935F936F9379
:101270007F938F939F93AF93BF93CF93EF93FF93FE
:101280008091E9008F709091EC0090FF02C090E88F
:1012900001C090E0C92FC82B1092E9008091F000A6
:1012A000877F8093F00078941CD01092E9008091A1
:1012B000F00088608093F000CF70C093E900FF9148
:1012C000EF91CF91BF91AF919F918F917F916F914E
:1012D0005F914F913F912F910F900FBE0F901F90F4
:1012E00018951F93CF93DF93CDB7DEB7AC970FB6AA
:1012F000F894DEBF0FBECDBFEFE7F2E08091F100C2
:10130000819322E0E738F207C9F7B0DA8091E8006C
:1013100083FF30C180917F0290918002953009F463
:1013200087C038F49130B1F170F0933009F022C1E8
:1013300031C0983009F4F3C0993009F4FFC09630F9
:1013400009F018C19BC0803821F0823809F012C121
:1013500008C080917B0290917C02992389F0826081
:101360000FC080918302909184028F70992780939F
:10137000E9008091EB0085FB882780F91092E90055
:101380009091E800977F9093E8008093F10010928D
:10139000F100D0C0882319F0823009F0EBC08F71C2
:1013A00021F0823009F0E6C00BC0809181028130CB
:1013B00009F0E0C0933009F080E080937C022FC0F8
:1013C0008091810281112BC08091830290918402CF
:1013D0008F709927009709F4CDC08093E900209180
:1013E000EB0020FF1CC020918002233021F480916B
:1013F000EB00806212C09091EB0090619093EB0043
:1014000021E030E001C0220F8A95EAF72093EA003C
:101410001092EA008091EB0088608093EB001092BC
:10142000E9008091E800877F8093E800D3DDA2C0C7
:101430008111A0C080918102909182028F779927BB
:10144000182F9091E3009078982B9093E30080916F
:10145000E800877F8093E800BDDD8091E80080FF91
:10146000FCCF8091E30080688093E300112311F0AA
:1014700083E001C082E080937E027CC0805882308D
:1014800008F078C080918102909182028C3D23E027
:10149000920771F583E08A838AE289834FB7F894D3
:1014A000DE01139620E03EE051E2E32FF0E050939E
:1014B0005700E49120FF03C0E295EF703F5FEF70AB
:1014C0008E2F90E0EA3010F0C79601C0C0968D9341
:1014D0009D932F5F243149F74FBF8091E800877FAC
:1014E0008093E8006AE270E0CE010196FDDB11C056
:1014F000AE01455D5F4F60918302EFD90097D1F156
:101500002091E800277F2093E800BC018BA59CA5D3
:101510008BDC8091E8008B778093E8002BC08038CB
:1015200049F58091E800877F8093E80080917A02F6
:101530008093F1008091E8008E7776CF81111AC0F8
:10154000909181029230B0F48091E800877F80937F
:10155000E80090937A023EDD80917A02811104C006
:101560008091E30087FF02C084E001C081E08093A6
:101570007E02C1D88091E80083FF0AC08091E80014
:10158000877F8093E8008091EB0080628093EB007E
:10159000AC960FB6F894DEBF0FBECDBFDF91CF91F2
:1015A0001F9108950895CF9380917E028823A9F01A
:1015B0008091E9008F709091EC0090FF02C090E85C
:1015C00001C090E0C92FC82B1092E9008091E8007B
:1015D00083FD87DECF70C093E900CF910895CF934C
:1015E000DF93EC014096FC018BE0DF011D928A95B0
:1015F000E9F782E08C83898783E08E8761E0CE0102
:101600000196AADC882361F061E0CE010696A4DC95
:10161000882331F061E0CE010B96DF91CF919CCC15
:1016200080E0DF91CF910895CF93C62F20917E0265
:101630002430F1F4FC014489558966897789452B6A
:10164000462B472BA9F081818F708093E900809110
:10165000E80085FF04C0C093F10080E00AC08091DB
:10166000E8008E778093E800D6DC8823A1F301C0E0
:1016700082E0CF91089520917E02243029F5FC016B
:101680004489558966897789452B462B472BE1F09C
:1016900081818F708093E9008091F200811102C0F6
:1016A00080E008959091E8008091E8008E77809323
:1016B000E80095FDF5CFAFDC811107C09091E800FF
:1016C0009E779093E800089582E0089520917E022D
:1016D000243089F4FC014489558966897789452B32
:1016E000462B472B41F021812F702093E900209158
:1016F000E80020FDC0CF089520917E02243019F02B
:101700002FEF3FEF24C0FC01448955896689778912
:10171000452B462B472BA1F386818F708093E900E0
:101720008091E80082FFECCF8091F200882321F0C5
:101730002091F10030E002C02FEF3FEF8091F200E6
:10174000811105C08091E8008B778093E800C90182
:1017500008950895CF93DF93EC018091E80083FF13
:10176000A9C0888190E020918302309184022817DB
:10177000390709F09FC080918002813261F020F426
:10178000803209F097C03DC0823209F46EC08332C6
:1017900009F090C07FC080917F02813A09F08AC031
:1017A0008091E800877F8093E8008091E80080FFC7
:1017B000FCCF4C895D896E897F894093F100BB27FE
:1017C000A72F962F852F8093F100CB01AA27BB2747
:1017D0008093F100472F5527662777274093F10024
:1017E000888D8093F100898D8093F1008A8D80939C
:1017F000F1008091E8008E778093E800DF91CF912F
:10180000E9CB80917F02813209F054C08091E800D9
:10181000877F8093E80005C080917E02882309F4C9
:1018200049C08091E80082FFF7CF3091F10020910C
:10183000F1009091F1008091F1003C8B2D8B9E8BFB
:101840008F8B8091F100888F8091F100898F80913A
:10185000F1008A8F8091E8008B778093E800BADBF3
:10186000CE01DF91CF910C94970380917F0281325A
:1018700009F58091E800877F8093E800ABDB8091D9
:10188000810290918202998B888BCE01DF91CF915A
:101890000C942B0480917F02813261F48091E800E6
:1018A000877F8093E80096DB60918102CE01DF9113
:1018B000CF914FCFDF91CF9108956F927F928F920A
:1018C0009F92AF92BF92CF92DF92EF92FF920F93CF
:1018D0001F93CF93DF9300D01F92CDB7DEB77C016B
:1018E000ADB6BEB68091E80083FF07C1F7018081E5
:1018F00090E020918302309184022817390709F083
:10190000FCC080918002833009F49EC030F48130A5
:1019100071F0823009F0F1C0D4C08A3009F4B9C046
:101920008B3009F4A2C0893009F0E7C04CC0809127
:101930007F02813A09F0E1C08DB69EB61A82198203
:1019400080918102109182028B83F70140858DB7CF
:101950009EB7841B91090FB6F8949EBF0FBE8DBF32
:10196000CDB6DEB6EFEFCE1ADE0A360150E060E00B
:1019700070E0C601EAD1412F41508E010F5F1F4F29
:101980009601BE016D5F7F4FC7010E944904F701B8
:10199000268137812115310529F0408550E0B601B7
:1019A000C901CAD11092E9008091E800877F809335
:1019B000E80069817A81C30197D98091E8008B772B
:1019C0008093E80039C080917F02813209F095C090
:1019D0008DB69EB6009185021091860270908102AC
:1019E000609082028DB79EB7801B910B0FB6F89462
:1019F0009EBF0FBE8DBFCDB6DEB6EFEFCE1ADE0AAC
:101A00008091E800877F8093E800B801C601CCD9B7
:101A10008091E8008E778093E80021E0711001C08A
:101A200020E030E0021B130B2C0D3D1D462D4150D4
:101A3000672DC7010E946C04882D992D0FB6F8946C
:101A40009EBF0FBE8DBF59C080917F02813A09F0C1
:101A500054C08091E800877F8093E8008091E8007F
:101A600080FFFCCFF701818540C080917F028132E9
:101A700009F043C08091E800877F8093E800AADAEC
:101A80009091810281E0911101C080E0F70181878E
:101A900034C080917F02813281F58091E800877F98
:101AA0008093E80097DA80918102909182028827E2
:101AB00036E0969587953A95E1F7F7019587848703
:101AC0001CC080917F02813AC1F48091E800877F39
:101AD0008093E8008091E80080FFFCCFF7018485C7
:101AE000958596958795969587958093F100809139
:101AF000E8008E778093E8006DDA0FB6F894BEBEEA
:101B00000FBEADBE0F900F900F90DF91CF911F9140
:101B10000F91FF90EF90DF90CF90BF90AF909F908C
:101B20008F907F906F9008959C01275F3F4FF90140
:101B300027E0DF011D922A95E9F721E0FC012187CA
:101B400024EF31E03587248723E0248361E0019688
:101B500003CA4F925F926F927F928F929F92AF9241
:101B6000BF92CF92DF92EF92FF920F931F93CF938A
:101B7000DF9300D01F92CDB7DEB77C01ADB6BEB605
:101B800080917E02843009F08FC08091E4009091B2
:101B9000E500F701228533852817390709F484C049
:101BA00081818F708093E9008091E80085FF7CC07F
:101BB0006DB67EB640858DB79EB7841B91090FB672
:101BC000F8949EBF0FBE8DBFCDB6DEB6EFEFCE1A36
:101BD000DE0A1B821A821982460150E060E070E042
:101BE000C601B3D08E010F5F1F4F960140E0BE01CA
:101BF0006D5F7F4FC7010E944904582EF70184850D
:101C00009585892B31F001E010E086859785892B39
:101C100011F000E010E0F701C680D780C114D104B4
:101C200089F049815A81B601C40179D04424439492
:101C3000009709F4412CF701408550E0B401C6013A
:101C40007BD001C0412C89819A81892BF9F05110F8
:101C500004C0411002C000FF19C0F70184859585BA
:101C60009787868781818F708093E9008B818111AE
:101C70008093F10069817A8140E050E0C4010E94C4
:101C800027068091E8008E778093E8008091E40039
:101C90009091E500F70193878287862D972D0FB6E7
:101CA000F8949EBF0FBE8DBF0FB6F894BEBE0FBE98
:101CB000ADBE0F900F900F90DF91CF911F910F91BC
:101CC000FF90EF90DF90CF90BF90AF909F908F905C
:101CD0007F906F905F904F900895A1E21A2EAA1BFB
:101CE000BB1BFD010DC0AA1FBB1FEE1FFF1FA217CC
:101CF000B307E407F50720F0A21BB30BE40BF50BC9
:101D0000661F771F881F991F1A9469F76095709551
:101D1000809590959B01AC01BD01CF010895FB0119
:101D2000DC0104C08D910190801921F44150504094
:101D3000C8F7881B990B0895FB01DC0102C00190D4
:101D40000D9241505040D8F70895DC0101C06D93C9
:0C1D500041505040E0F70895F894FFCF98
:101D5C000281200000015002110000000000000070
:101D6C0000834000000104400000018208000001D3
:0E1D7C00000000000000000000000008302001
:1004000091E00E94130B21969E012A523240809166
:10041000290290E0281739076CF3E0CFDF91CF91E4
:1004200008951F93CF93DF938AD3882309F47FC065
:100430001A9B7DC0A6D2813009F03CC0B1D280FFAA
:1004400039C0809103028111C3DFA7D280930302D8
:100450001092050291E1E7E0F2E0DF01292F1D9201
:100460002A95E9F78530C1F038F4823071F0843094
:1004700061F08130D1F405C0883090F08A30A8F462
:1004800012C094E09093040204C088E080930402B8
:1004900081E0809306020AC081E080930402F9CFD4
:1004A00090930402F5CF83E0F1CF92DFDF91CF91FB
:1004B0001F9163C2809103028823C9F162D2109117
:1004C0000502C12FD0E090E09E012E5F3F4F359591
:1004D00027952F5F3F4F8217930729F55ED2C95F9B
:1004E000DD4F8883C12FCF5FC09305028091040246
:1004F0008C1749F055D2EC2FF0E0E95FFD4F808377
:100500001E5F1093050290910402809105029813DA
:10051000CDCF04C080E091E00E94A80D809103023D
:100520008111F8CFC3CFDF91CF911F9151CFDF91D0
:10053000CF911F910895F5DE2FB7F89481E391E0F4
:1005400090939601809395019093980180939701E1
:100550002FBF2FB7F8948AE991E09093FF01809321
:10056000FE0190930102809300022FBF78941092B5
:10057000050210920302C1E3D1E08C0153E0E52EA5
:100580009FB7F894809199019FBF843619F180E15B
:1005900091E00E947B0B97FD1DC0E0919501F091C9
:1005A0009601808380919501909196010196909398
:1005B0009601809395018559914021F4D09396013D
:1005C000C09395019FB7F894809199018F5F8093B4
:1005D00099019FBF8FB7F894F09002028FBFA8993E
:1005E00004C084E48F1508F056C0A89A80910202D6
:1005F000882341F15D98E0922E0124C0D4D1877FF9
:1006000039F0809103028111E3DE80913002C2DE75
:10061000E0910002F09101028191F0930102E093D8
:100620000002EE5FF14021F41093010200930002FA
:100630002FB7F894909102029150909302022FBF2D
:10064000F0DEFA94F110DACF80912E018823B9F010
:1006500080912E01815080932E01811110C08091D4
:1006600003028111B5DE9FD183FD07C0F0903002F7
:100670009AD187FDF3948F2D8DDE7FD15D9A809185
:100680002F01882341F080912F01815080932F0109
:10069000811101C05C9A9FB7F894809199019FBF26
:1006A000882309F1E0919701F09198019191F093DD
:1006B0009801E0939701E559F14021F4D093980116
:1006C000C09397012FB7F89480919901815080933E
:1006D00099012FBF8091C80085FFFCCF9093CE0079
:1006E0005C98E0922F0180E191E0EFD75BD748CF93
:1006F00008950895CF9380E091E00E94930DC82F54
:1007000080E191E06BD79091E20094609093E200D9
:10071000882321F0CC2311F080E001C080E39BB15D
:100720008095906389238BB9CF9108951F93CF93C0
:10073000DF93EC01E98DE150E23028F4F0E0E45D74
:10074000FE4F108101C010E0888D823009F41860DE
:100750008A8D873031F0883031F0863029F412608C
:1007600003C0146001C016605B9A1092C900109219
:10077000C8001092CA002C893D894E895F892115D5
:1007800081EE38074105510579F0CA01B901969506
:1007900087957795679560587B47814E9F4F0E945C
:1007A0006C0E2150310902C020E130E03093CD00C1
:1007B0002093CC001093CA008C899D89AE89BF8993
:1007C0008115914EA105B10511F480E001C082E0D0
:1007D0008093C80088E98093C9005B98DF91CF912E
:1007E0001F9108951F920F920FB60F9211242F930D
:1007F0008F939F93EF93FF938091CE009091460249
:100800009430F1F4E091FE01F091FF018083E091DA
:10081000FE01F091FF01CF0101969093FF018093BB
:10082000FE018E5F914021F48AE991E092838183F9
:100830009FB7F894809102028F5F809302029FBF5E
:10084000FF91EF919F918F912F910F900FBE0F907D
:100850001F901895FC01208920FF02C05F98089521
:100860005F9A8BB180638BB9089580E191E071D775
:1008700080E091E00C945C0C80910E0190910F014E
:10088000009729F0019790930F0180930E0108952E
:10089000EF92FF920F931F93CF93DF937B01C901D8
:1008A000E80110910402E7E0F2E0412F50E0BF01BF
:1008B0000E949B0EE3E0F2E08081D7018C931883C5
:1008C0001982108280910602DF91CF911F910F91C2
:1008D000FF90EF9008950895292F33272330310595
:1008E000B1F04CF42130310509F439C02230310522
:1008F00009F03AC007C02132310539F12232310501
:1009000049F132C0EFE5F0E08EEB90E031C099277D
:100910008130910561F08230910581F0892B21F5BC
:10092000EAEBF0E0E491F0E08AEB90E021C0E6EA47
:10093000F0E0E491F0E086EA90E01AC0E4E7F0E04D
:10094000E491F0E084E790E013C0E9E0F0E08DE0AE
:1009500091E00EC0E8EBF1E08FE291E009C0E2E146
:10096000F0E08DE191E004C0E0E0F0E080E090E0B4
:10097000DA018D939C93CF01089588E080932B0139
:1009800008958091380208956091390270913A0279
:1009900080913B0290913C02089580913902089524
:1009A00080913A02089580912B010895982F8091AB
:1009B0002B018823E9F083FF0AC010923D021092B8
:1009C0003E0210923F02109240021092410287FFB5
:1009D0000DC040913002E42FF0E0EF5CFD4F8081CC
:1009E0008093310281E08093300202C01092300285
:1009F00010923702109238021092390210923A0285
:100A000010923B0210923C0210922B012091300276
:100A1000E22FF0E0EF5CFD4F9083822F8F5F809399
:100A20003002392F307C80913D02303809F440C0CB
:100A3000303C09F05EC0882329F080E980932B01C7
:100A400020933002292F287326952695269522304B
:100A500018F02730E1F40AC09F709F5F909337022F
:100A600010923D0280912B0185603DC0492F4F704F
:100A700050E060E070E040933E0250933F0260938C
:100A800040027093410285E080933D0256C0892F59
:100A9000877090E0A0E0B0E080933E0290933F0228
:100AA000A0934002B0934102215020933D0245C0E3
:100AB000282F215020933D028130C9F49F739F5FFE
:100AC0009093380280913E0290913F02A0914002A3
:100AD000B09141028093390290933A02A0933B0275
:100AE000B0933C0283E080932B0181E0089580E580
:100AF00007C0282F215020933D02823030F480E33C
:100B000080932B0110923D0218C040913E025091FB
:100B10003F02609140027091410287E0440F551FEF
:100B2000661F771F8A95D1F7492B40933E02509359
:100B30003F02609340027093410280E008950F935A
:100B40001F9334DF8823A9F01CDF882391F01CDF7A
:100B50008C0122273327DC01CB01AA27BB270827DA
:100B600019272A273B2781E00F3F1F4F2105310519
:100B700009F080E01F910F9108950F931F93A091AA
:100B80002A02ECE1F0E097E08A019B010E2E04C0FE
:100B900036952795179507950A94D2F7083040F0B7
:100BA000A0932A02973059F400932A0296E007C0D6
:100BB00091503797A02F923039F700932A02A92F2E
:100BC000A25013C0EA2FF0E0E65DFD4F8A019B01C1
:100BD0000F771127222733270083E7E07695679563
:100BE00057954795EA95D1F7A150A111EBCF492F21
:100BF00050E09A0163E0220F331F6A95E1F7206C01
:100C00003F6F30912A02322B30932A02FA01E75DBE
:100C1000FD4F81508F7380688083909329021F91CC
:100C20000F9108950F931F938B01AB014095509541
:100C300060E070E0BA015527442720E030E0402B07
:100C4000512B622B732B1F910F9197CFBF92CF9295
:100C5000DF92EF92FF920F931F93CF93DF937C016C
:100C60008B01EA01D7D1B82E811132C0209731F023
:100C700028813981021B130BE20EF31EC12CD12CEB
:100C800022C08091E80085FD14C08091E8008E7735
:100C90008093E800209749F0888199818C0D9D1DF3
:100CA0009983888325E0B22E13C0B4D1882359F0EC
:100CB0000EC0F70181917F018093F100015011096D
:100CC000FFEFCF1ADF0A01151105D9F601C0B82EC2
:100CD0008B2DDF91CF911F910F91FF90EF90DF90BF
:100CE000CF90BF90089520914D0230914E0226176B
:100CF000370748F06115710539F42091E8002E7727
:100D00002093E80001C0B9019C0180E034C09091BB
:100D10004602992309F443C0953009F442C09091EA
:100D2000E80093FD3AC09091E80092FD30C09091A8
:100D3000E80090FF20C08091F20090E0F901821B52
:100D4000930B05C021912093F100615071099F011F
:100D5000280F391F6115710519F02830310590F3FE
:100D600081E02830310509F080E09091E8009E771D
:100D70009093E8009F016115710549F68111C7CF75
:100D800006C080914602882351F0853051F0809151
:100D9000E80082FFF6CF80E0089581E0089582E0C8
:100DA000089583E008956115710529F42091E80004
:100DB0002B772093E8009C0121C080914602882374
:100DC00081F1853041F18091E80083FD26C080915A
:100DD000E80082FFF2CFF90107C08091F100819312
:100DE0009F016150710929F09F018091F2008111EA
:100DF000F4CF8091E8008B778093E800611571054E
:100E0000E1F68091E80080FD0AC0809146028823C7
:100E100041F08530B1F783E0089581E0089580E0E6
:100E2000089582E0089520914D0230914E022617D8
:100E3000370748F06115710539F42091E8002E77E5
:100E40002093E80001C0B9019C0180E035C0909179
:100E50004602992309F444C0953009F443C09091A7
:100E6000E80093FD3BC09091E80092FD31C0909165
:100E7000E80090FF21C08091F20090E0F901821B10
:100E8000930B06C024912093F100319661507109B3
:100E90009C012E0F3F1F6115710519F02830310597
:100EA00088F381E02830310509F080E09091E80076
:100EB0009E779093E8009F016115710541F68111BD
:100EC000C6CF06C080914602882351F0853051F08C
:100ED0008091E80082FFF6CF80E0089581E00895D8
:100EE00082E0089583E00895982F2CC09093E90044
:100EF000981739F07091EC002091ED005091F000BE
:100F000003C0242F762F50E021FD02C09F5F1AC03E
:100F10003091EB003E7F3093EB003091ED003D7F50
:100F20003093ED003091EB0031603093EB00709323
:100F3000EC002093ED005093F0002091EE0027FD8F
:100F4000E5CF07C0953090F28F708093E90081E083
:100F5000089580E008950F931F93CF93DF93062F9A
:100F6000EC0110E02EC09881911103C01F5F2596FF
:100F700028C02C81E981FA816B81892F8F7085309F
:100F800010F080E021C0223010F056E001C052E0A5
:100F900028E030E040E003C04F5F220F331F2E17E0
:100FA0003F07D0F34295407F452B991F9927991F02
:100FB0006295660F660F607C692B96DF8111D6CF34
:100FC000E0CF1013D0CF81E0DF91CF911F910F912F
:100FD00008958091470287FD05C08091E80080FF59
:100FE0000EC012C08091E80082FD05C080914602CB
:100FF0008111F8CF08958091E8008B7708C0809127
:1010000046028111EACF08958091E8008E7780939F
:10101000E80008958091E4009091E50045E6209174
:10102000EC0020FD1FC023C020914602222391F036
:10103000253091F02091EB0025FD10C02091E400B7
:101040003091E5002817390751F34150C90139F7AC
:1010500084E0089582E0089583E0089581E0089592
:1010600080E008952091E80020FFDECFF9CF2091A5
:10107000E80022FFD9CFF4CF41D043D08091D800EF
:101080008F778093D8008091D80080688093D800B3
:101090008091D8008F7D8093D80084E089BD86E060
:1010A00089BD09B400FEFDCF1092460210924202A3
:1010B000109244021092430242E060E080E014DFAC
:1010C0008091E1008E7F8093E1008091E200816059
:1010D0008093E2008091E20088608093E20080913A
:1010E000E0008E7F8093E0000895E3E6F0E08081E9
:1010F0008E7F808381E080934502BECF1092E20014
:1011000008951092E10008951F920F920FB60F926A
:1011100011242F933F934F935F936F937F938F93FC
:101120009F93AF93BF93EF93FF938091E10082FF72
:101130000AC08091E20082FF06C08091E1008B7FAF
:101140008093E10099DB8091E10080FF17C08091DE
:10115000E20080FF13C08091E2008E7F8093E20066
:101160008091E20080618093E2008091D8008062EB
:101170008093D80019BC10924602BBDA8091E1003E
:1011800084FF2FC08091E20084FF2BC084E089BDE2
:1011900086E089BD09B400FEFDCF8091D8008F7D27
:1011A0008093D8008091E1008F7E8093E100809150
:1011B000E2008F7E8093E2008091E2008160809364
:1011C000E20080914202882311F084E007C0809100
:1011D000E30087FF02C083E001C081E08093460204
:1011E00087DA8091E10083FF27C08091E20083FFCE
:1011F00023C08091E100877F8093E10082E08093AB
:101200004602109242028091E1008E7F8093E100BD
:101210008091E2008E7F8093E2008091E200806105
:101220008093E20042E060E080E05EDE8091F000CA
:1012300088608093F000B5D1FF91EF91BF91AF919D
:101240009F918F917F916F915F914F913F912F91DE
:101250000F900FBE0F901F9018951F920F920FB610
:101260000F9211242F933F934F935F936F937F932C
:101270008F939F93AF93BF93CF93EF93FF938091FF
:10128000E9008F709091EC0090FF02C090E801C0DF
:1012900090E0C92FC82B1092E9008091F000877F61
:1012A0008093F00078941CD01092E9008091F000B7
:1012B00088608093F000CF70C093E900FF91EF91B8
:1012C000CF91BF91AF919F918F917F916F915F91DE
:1012D0004F913F912F910F900FBE0F901F90189537
:1012E0001F93CF93DF93CDB7DEB7AC970FB6F894CB
:1012F000DEBF0FBECDBFE7E4F2E08091F100819345
:1013000022E0EF34F207C9F7B0DA8091E80083FFFA
:1013100030C18091470290914802953009F487C00E
:1013200038F49130B1F170F0933009F022C131C03E
:10133000983009F4F3C0993009F4FFC0963009F0F1
:1013400018C19BC0803821F0823809F012C108C052
:101350008091430290914402992389F082600FC0EA
:1013600080914B0290914C028F7099278093E900F5
:101370008091EB0085FB882780F91092E90090911D
:10138000E800977F9093E8008093F1001092F100BD
:10139000D0C0882319F0823009F0EBC08F7121F0A2
:1013A000823009F0E6C00BC080914902813009F01B
:1013B000E0C0933009F080E0809344022FC0809118
:1013C000490281112BC080914B0290914C028F7089
:1013D0009927009709F4CDC08093E9002091EB0094
:1013E00020FF1CC020914802233021F48091EB00A3
:1013F000806212C09091EB0090619093EB0021E02D
:1014000030E001C0220F8A95EAF72093EA0010929B
:10141000EA008091EB0088608093EB001092E90075
:101420008091E800877F8093E800D3DDA2C081111E
:10143000A0C08091490290914A028F779927182F76
:101440009091E3009078982B9093E3008091E800CE
:10145000877F8093E800BDDD8091E80080FFFCCFAE
:101460008091E30080688093E300112311F083E012
:1014700001C082E0809346027CC08058823008F030
:1014800078C08091490290914A028C3D23E09207F6
:1014900071F583E08A838AE289834FB7F894DE018D
:1014A000139620E03EE051E2E32FF0E05093570026
:1014B000E49120FF03C0E295EF703F5FEF708E2F45
:1014C00090E0EA3010F0C79601C0C0968D939D93CE
:1014D0002F5F243149F74FBF8091E800877F8093C9
:1014E000E8006AE270E0CE010196FDDB11C0AE01BA
:1014F000455D5F4F60914B02EFD90097D1F120918C
:10150000E800277F2093E800BC018BA59CA58BDC1D
:101510008091E8008B778093E8002BC0803849F5F4
:101520008091E800877F8093E80080914202809359
:10153000F1008091E8008E7776CF81111AC09091EA
:1015400049029230B0F48091E800877F8093E800F0
:10155000909342023EDD80914202811104C080914D
:10156000E30087FF02C084E001C081E0809346026F
:10157000C1D88091E80083FF0AC08091E800877F8E
:101580008093E8008091EB0080628093EB00AC9642
:101590000FB6F894DEBF0FBECDBFDF91CF911F9184
:1015A00008950895CF93809146028823A9F08091F1
:1015B000E9008F709091EC0090FF02C090E801C0AC
:1015C00090E0C92FC82B1092E9008091E80083FDBC
:1015D00087DECF70C093E900CF910895CF93DF935A
:1015E000EC014096FC018BE0DF011D928A95E9F742
:1015F00082E08C83898783E08E8761E0CE0101964B
:10160000AADC882361F061E0CE010696A4DC882381
:1016100031F061E0CE010B96DF91CF919CCC80E060
:10162000DF91CF910895CF93C62F209146022430A9
:10163000F1F4FC014489558966897789452B462B4D
:10164000472BA9F081818F708093E9008091E80099
:1016500085FF04C0C093F10080E00AC08091E800DB
:101660008E778093E800D6DC8823A1F301C082E066
:10167000CF91089520914602243029F5FC01448938
:10168000558966897789452B462B472BE1F0818167
:101690008F708093E9008091F200811102C080E098
:1016A00008959091E8008091E8008E778093E8009B
:1016B00095FDF5CFAFDC811107C09091E8009E77D2
:1016C0009093E800089582E0089520914602243026
:1016D00089F4FC014489558966897789452B462B15
:1016E000472B41F021812F702093E9002091E800E1
:1016F00020FDC0CF089520914602243019F02FEF2D
:101700003FEF24C0FC014489558966897789452BC0
:10171000462B472BA1F386818F708093E90080913F
:10172000E80082FFECCF8091F200882321F0209125
:10173000F10030E002C02FEF3FEF8091F200811105
:1017400005C08091E8008B778093E800C901089577
:101750000895CF93DF93EC018091E80083FFA9C047
:10176000888190E020914B0230914C022817390774
:1017700009F09FC080914802813261F020F48032EC
:1017800009F097C03DC0823209F46EC0833209F07F
:1017900090C07FC080914702813A09F08AC0809151
:1017A000E800877F8093E8008091E80080FFFCCF0D
:1017B0004C895D896E897F894093F100BB27A72FF3
:1017C000962F852F8093F100CB01AA27BB2780930A
:1017D000F100472F5527662777274093F100888D22
:1017E0008093F100898D8093F1008A8D8093F100C0
:1017F0008091E8008E778093E800DF91CF91E9CB6C
:1018000080914702813209F054C08091E800877FBF
:101810008093E80005C080914602882309F449C0FE
:101820008091E80082FFF7CF3091F1002091F10024
:101830009091F1008091F1003C8B2D8B9E8B8F8BD2
:101840008091F100888F8091F100898F8091F10063
:101850008A8F8091E8008B778093E800BADBCE0115
:10186000DF91CF910C94960380914702813209F564
:101870008091E800877F8093E800ABDB809149028C
:1018800090914A02998B888BCE01DF91CF910C9475
:101890002A0480914702813261F48091E800877FB9
:1018A0008093E80096DB60914902CE01DF91CF91F1
:1018B0004FCFDF91CF9108956F927F928F929F9239
:1018C000AF92BF92CF92DF92EF92FF920F931F934E
:1018D000CF93DF9300D01F92CDB7DEB77C01ADB6BA
:1018E000BEB68091E80083FF07C1F701808190E0D8
:1018F00020914B0230914C022817390709F0FCC0A7
:1019000080914802833009F49EC030F4813071F038
:10191000823009F0F1C0D4C08A3009F4B9C08B30EC
:1019200009F4A2C0893009F0E7C04CC08091470299
:10193000813A09F0E1C08DB69EB61A821982809173
:10194000490210914A028B83F70140858DB79EB7FB
:10195000841B91090FB6F8949EBF0FBE8DBFCDB604
:10196000DEB6EFEFCE1ADE0A360150E060E070E03E
:10197000C601EAD1412F41508E010F5F1F4F9601E2
:10198000BE016D5F7F4FC7010E944804F7012681A9
:1019900037812115310529F0408550E0B601C90194
:1019A000CAD11092E9008091E800877F8093E80017
:1019B00069817A81C30197D98091E8008B77809300
:1019C000E80039C080914702813209F095C08DB698
:1019D0009EB600914D0210914E02709049026090A7
:1019E0004A028DB79EB7801B910B0FB6F8949EBF2D
:1019F0000FBE8DBFCDB6DEB6EFEFCE1ADE0A8091F8
:101A0000E800877F8093E800B801C601CCD98091B7
:101A1000E8008E778093E80021E0711001C020E09B
:101A200030E0021B130B2C0D3D1D462D4150672D40
:101A3000C7010E946B04882D992D0FB6F8949EBFA4
:101A40000FBE8DBF59C080914702813A09F054C042
:101A50008091E800877F8093E8008091E80080FF14
:101A6000FCCFF701818540C080914702813209F0A7
:101A700043C08091E800877F8093E800AADA9091C4
:101A8000490281E0911101C080E0F701818734C0F3
:101A900080914702813281F58091E800877F8093B1
:101AA000E80097DA8091490290914A02882736E04F
:101AB000969587953A95E1F7F701958784871CC03D
:101AC00080914702813AC1F48091E800877F80933A
:101AD000E8008091E80080FFFCCFF70184859585C0
:101AE00096958795969587958093F1008091E8006B
:101AF0008E778093E8006DDA0FB6F894BEBE0FBE05
:101B0000ADBE0F900F900F90DF91CF911F910F916D
:101B1000FF90EF90DF90CF90BF90AF909F908F900D
:101B20007F906F9008959C01275F3F4FF90127E058
:101B3000DF011D922A95E9F721E0FC01218724EFBE
:101B400031E03587248723E0248361E0019603CACE
:101B50004F925F926F927F928F929F92AF92BF92BD
:101B6000CF92DF92EF92FF920F931F93CF93DF9369
:101B700000D01F92CDB7DEB77C01ADB6BEB6809166
:101B80004602843009F08FC08091E4009091E50016
:101B9000F701228533852817390709F484C081812C
:101BA0008F708093E9008091E80085FF7CC06DB65E
:101BB0007EB640858DB79EB7841B91090FB6F89409
:101BC0009EBF0FBE8DBFCDB6DEB6EFEFCE1ADE0ADA
:101BD0001B821A821982460150E060E070E0C60163
:101BE000B3D08E010F5F1F4F960140E0BE016D5FC5
:101BF0007F4FC7010E944804582EF70184859585C0
:101C0000892B31F001E010E086859785892B11F052
:101C100000E010E0F701C680D780C114D10489F03C
:101C200049815A81B601C40179D044244394009774
:101C300009F4412CF701408550E0B401C6017BD086
:101C400001C0412C89819A81892BF9F0511004C07F
:101C5000411002C000FF19C0F70184859585978760
:101C6000868781818F708093E9008B8181118093B9
:101C7000F10069817A8140E050E0C4010E942606AB
:101C80008091E8008E778093E8008091E400909145
:101C9000E500F70193878287862D972D0FB6F8947C
:101CA0009EBF0FBE8DBF0FB6F894BEBE0FBEADBEB9
:101CB0000F900F900F90DF91CF911F910F91FF9098
:101CC000EF90DF90CF90BF90AF909F908F907F90DC
:101CD0006F905F904F900895A1E21A2EAA1BBB1B34
:101CE000FD010DC0AA1FBB1FEE1FFF1FA217B307E8
:101CF000E407F50720F0A21BB30BE40BF50B661FFE
:101D0000771F881F991F1A9469F7609570958095C1
:101D100090959B01AC01BD01CF010895FB01DC0151
:101D200004C08D910190801921F441505040C8F7B2
:101D3000881B990B0895FB01DC0102C001900D92F4
:101D400041505040D8F70895DC0101C06D934150D7
:0A1D50005040E0F70895F894FFCF2B
:101D5A0002812000000118021100000000000000AA
:101D6A0000834000000104400000018208000001D5
:0E1D7A00000000000000000000000008302003
:00000001FF

View file

@ -376,7 +376,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
//.VendorID = 0x2341, // Arduino
//.ProductID = 0x0043, // Arduino Uno
.ReleaseNumber = VERSION_BCD(0,1,1),
.ReleaseNumber = VERSION_BCD(0,1,2),
.ManufacturerStrIndex = STRING_ID_Manufacturer,
.ProductStrIndex = STRING_ID_Product,

View file

@ -32,7 +32,7 @@ THE SOFTWARE.
/* Includes: */
#include <avr/pgmspace.h>
#include <LUFA/Drivers/USB/USB.h>
#include <../HID_Reports.h>
#include <Lib/HID_Reports.h>
/* Macros: */
/** Endpoint address of the CDC device-to-host notification IN endpoint. */

View file

@ -124,27 +124,30 @@ int main(void)
GlobalInterruptEnable();
// Protocolsetup
// HID Setup
HIDReportState.recvlength=0;
HIDReportState.ID=0;
// Debug
DDRB |= 0x08; //led out
DDRB |= 0x02; //led out
//DDRB |= 0x08; //led out
//DDRB |= 0x02; //led out
//DDRB |= 0x80; // DEBUG <--
//DDRB &=~0x40;
//PORTB |= 0x40;
for (;;)
{
/* Only try to read in bytes from the CDC interface if the transmit buffer is not full */
// Only try to read in bytes from the CDC interface if the transmit buffer is not full
if (!(RingBuffer_IsFull(&USBtoUSART_Buffer)))
{
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
/* Read bytes from the USB OUT endpoint into the USART transmit buffer */
// Read bytes from the USB OUT endpoint into the USART transmit buffer
if (!(ReceivedByte < 0))
RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte);
}
/* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */
// Check if the UART receive buffer flush timer has expired or the buffer is nearly full
RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
if ((TIFR0 & (1 << TOV0)) || (BufferCount > BUFFER_NEARLY_FULL))
{
@ -155,8 +158,9 @@ int main(void)
PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS;
}
/* Read bytes from the USART receive buffer*/
// Read bytes from the USART receive buffer
while (BufferCount--){
//new Protocol check<--
// if a reading finished succesfull without valid checksum or an error occured (ignore a reset)
if(NHPgetErrorLevel()&(~NHP_INPUT_RESET)){
@ -172,6 +176,7 @@ int main(void)
//read newest byte and check for Protocol
RingBuff_Data_t b = RingBuffer_Remove(&USARTtoUSB_Buffer);
checkNHPProtocol(b);
}
// if reading has timed out write the buffers down the serial and turn off the led
@ -192,16 +197,16 @@ int main(void)
// do not write again in the while loop above anyways
NHPreset();
/* Turn off TX LED(s) once the TX pulse period has elapsed */
// Turn off TX LED(s) once the TX pulse period has elapsed
LEDs_TurnOffLEDs(LEDMASK_TX);
}
/* Turn off RX LED(s) once the RX pulse period has elapsed */
// Turn off RX LED(s) once the RX pulse period has elapsed
if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse))
LEDs_TurnOffLEDs(LEDMASK_RX);
}
/* Load the next byte from the USART transmit buffer into the USART */
// Load the next byte from the USART transmit buffer into the USART
if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer))) {
Serial_SendByte(RingBuffer_Remove(&USBtoUSART_Buffer)); //<--new syntax
@ -212,6 +217,7 @@ int main(void)
//new Send reports <--
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
USB_USBTask();
}
}
@ -291,29 +297,29 @@ void checkNHPProtocol(RingBuff_Data_t input){
case HID_REPORTID_KeyboardReport:
HIDReportState.length=sizeof(HID_KeyboardReport_Data_t);
HIDReportState.forcewrite=false;
HIDReportState.forcewrite=true; // set to true because of some bugs with joystick 1+2
break;
case HID_REPORTID_MediaReport:
HIDReportState.length=sizeof(HID_MediaReport_Data_t);
HIDReportState.forcewrite=false;
HIDReportState.forcewrite=true;
break;
case HID_REPORTID_SystemReport:
HIDReportState.length=sizeof(HID_SystemReport_Data_t);
HIDReportState.forcewrite=false;
HIDReportState.forcewrite=true;
break;
case HID_REPORTID_Gamepad1Report:
case HID_REPORTID_Gamepad2Report:
HIDReportState.length=sizeof(HID_GamepadReport_Data_t);
HIDReportState.forcewrite=false;
HIDReportState.forcewrite=true;
break;
case HID_REPORTID_Joystick1Report:
case HID_REPORTID_Joystick2Report:
HIDReportState.length=sizeof(HID_JoystickReport_Data_t);
HIDReportState.forcewrite=false;
HIDReportState.forcewrite=true;
break;
// not supported yet <--

View file

@ -0,0 +1,192 @@
/*
Copyright (c) 2014 NicoHood
See the readme for credit to other people.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef HID_REPORTS_H
#define HID_REPORTS_H
//================================================================================
//Definitions
//================================================================================
// empty
//================================================================================
//Report Typedefinitions
//================================================================================
typedef union{
// mouse report: 5 buttons, position, wheel
uint8_t whole8[4];
uint16_t whole16[4/2];
uint32_t whole32[4/4];
struct{
uint8_t buttons:5;
uint8_t reserved:3;
int8_t xAxis;
int8_t yAxis;
int8_t wheel;
};
} HID_MouseReport_Data_t;
typedef union{
// Low level key report: up to 6 keys and shift, ctrl etc at once
uint8_t whole8[8];
uint16_t whole16[8/2];
uint32_t whole32[8/4];
struct{
uint8_t modifiers;
uint8_t reserved;
uint8_t keys[6];
};
} HID_KeyboardReport_Data_t;
typedef union{
// every usable media key possible. Only one at the same time.
uint8_t whole8[8];
uint16_t whole16[8/2];
uint32_t whole32[8/4];
struct{
uint16_t key1;
uint16_t key2;
uint16_t key3;
uint16_t key4;
};
} HID_MediaReport_Data_t;
typedef union{
// every usable system control key possible. Only one at the same time.
uint8_t whole8[1];
uint8_t key;
} HID_SystemReport_Data_t;
typedef union {
// 32 Buttons, 6 Axis, 2 D-Pads
uint8_t whole8[17];
uint16_t whole16[17/2];
uint32_t whole32[17/4];
uint32_t buttons;
struct{
uint8_t button1 :1;
uint8_t button2 :1;
uint8_t button3 :1;
uint8_t button4 :1;
uint8_t button5 :1;
uint8_t button6 :1;
uint8_t button7 :1;
uint8_t button8 :1;
uint8_t button9 :1;
uint8_t button10 :1;
uint8_t button11 :1;
uint8_t button12 :1;
uint8_t button13 :1;
uint8_t button14 :1;
uint8_t button15 :1;
uint8_t button16 :1;
uint8_t button17 :1;
uint8_t button18 :1;
uint8_t button19 :1;
uint8_t button20 :1;
uint8_t button21 :1;
uint8_t button22 :1;
uint8_t button23 :1;
uint8_t button24 :1;
uint8_t button25 :1;
uint8_t button26 :1;
uint8_t button27 :1;
uint8_t button28 :1;
uint8_t button29 :1;
uint8_t button30 :1;
uint8_t button31 :1;
uint8_t button32 :1;
uint16_t xAxis;
uint16_t yAxis;
uint16_t zAxis;
uint16_t rxAxis;
uint16_t ryAxis;
uint16_t rzAxis;
uint8_t dPad1: 4;
uint8_t dPad2: 4;
// deactivated because windows only supports 7 axis. should be enough.
//uint8_t throttle;
//uint8_t rudder;
};
} HID_GamepadReport_Data_t;
typedef union{
// 2 Buttons, 2 Axis
uint8_t whole8[3];
uint16_t whole16[3/2];
uint8_t buttons :2;
struct{
uint16_t button1 :1;
uint16_t button2 :1;
uint16_t xAxis :10;
uint16_t yAxis :10;
uint16_t reserved :2;
};
} HID_JoystickReport_Data_t;
typedef union{
HID_MouseReport_Data_t Mouse;
HID_KeyboardReport_Data_t Keyboard;
HID_MediaReport_Data_t Media;
HID_GamepadReport_Data_t Gamepad1;
HID_GamepadReport_Data_t Gamepad2;
HID_JoystickReport_Data_t Joystick1;
HID_JoystickReport_Data_t Joystick2;
} HID_HIDReport_Data_t;
/** Enum for the HID report IDs used in the device. */
typedef enum{
HID_REPORTID_MouseReport = 0x01, /**< Report ID for the Mouse report within the device. */
HID_REPORTID_KeyboardReport = 0x02, /**< Report ID for the Keyboard report within the device. */
HID_REPORTID_RawKeyboardReport=0x03, /**< Report ID for the Raw Keyboard report within the device. */
HID_REPORTID_MediaReport = 0x04, /**< Report ID for the Media report within the device. */
HID_REPORTID_SystemReport = 0x05, /**< Report ID for the Power report within the device. */
HID_REPORTID_Gamepad1Report = 0x06, /**< Report ID for the Gamepad1 report within the device. */
HID_REPORTID_Gamepad2Report = 0x07, /**< Report ID for the Gamepad2 report within the device. */
HID_REPORTID_Joystick1Report = 0x08, /**< Report ID for the Joystick1 report within the device. */
HID_REPORTID_Joystick2Report = 0x09, /**< Report ID for the Joystick2 report within the device. */
} HID_Report_IDs;
#endif

View file

@ -44,12 +44,12 @@
/* Defines: */
/** Size of each ring buffer, in data elements - must be between 1 and 255. */
#define BUFFER_SIZE 128
#define BUFFER_SIZE (128-28) //reduced, needed some ram
/** Maximum number of data elements to buffer before forcing a flush.
* Must be less than BUFFER_SIZE
*/
#define BUFFER_NEARLY_FULL 96
#define BUFFER_NEARLY_FULL (96-28)
/** Type of data to store into the buffer. */
#define RingBuff_Data_t uint8_t

7
Hoodloader/Readme.md Normal file
View file

@ -0,0 +1,7 @@
This folder is only interesting for developers.
You need to install the gcc-avr toolchain and compile with:
``` bash
$ sudo apt-get install avr-gcc
$ sudo make clean
$ sudo make
```

View file

@ -14,3 +14,7 @@ LUFA/StudioIntegration/ProjectGenerator/*
LUFA/StudioIntegration/DocBook/*
Demos/*
Projects/*
Maintenance/*
BuildTests/*
Bootloaders/*

View file

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Some files were not shown because too many files have changed in this diff Show more