diff --git a/libraries/CompleteHID/CompleteHID.cpp b/libraries/CompleteHID/CompleteHID.cpp new file mode 100644 index 000000000..7c427ad95 --- /dev/null +++ b/libraries/CompleteHID/CompleteHID.cpp @@ -0,0 +1,714 @@ +#if 1 //defined(USBCON) + +#include "CompleteHID.h" +#include "HIDTables.h" +#include "HID.h" + +#define HID_MOUSE_ABS_ENABLED + +Keyboard_ Keyboard; +Mouse_ Mouse; + +#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 + +#define HID_REPORTID_KEYBOARD (1) +#define HID_REPORTID_MOUSE (2) +#define HID_REPORTID_MOUSE_ABS (3) +#define HID_REPORTID_SYSTEMCONTROL (4) +#define HID_REPORTID_CONSUMERCONTROL (5) +#define HID_REPORTID_RAWHID (6) + +#define HID_REPORT_KEYBOARD /* Keyboard */ \ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) 47 */ \ + 0x09, 0x06, /* USAGE (Keyboard) */ \ + 0xa1, 0x01, /* COLLECTION (Application) */ \ + 0x85, HID_REPORTID_KEYBOARD, /* REPORT_ID */ \ + 0x05, 0x07, /* USAGE_PAGE (Keyboard) */ \ +\ + /* Keyboard Modifiers (shift, alt, ...) */ \ + 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) */ \ + 0x95, 0x01, /* REPORT_COUNT (1) */ \ + 0x75, 0x08, /* REPORT_SIZE (8) */ \ + 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ \ +\ + /* Keyboard keys */ \ + 0x95, 0x06, /* REPORT_COUNT (6) */ \ + 0x75, 0x08, /* REPORT_SIZE (8) */ \ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ + 0x26, 0xDF, 0x00, /* LOGICAL_MAXIMUM (239) */ \ + 0x05, 0x07, /* USAGE_PAGE (Keyboard) */ \ + 0x19, 0x00, /* USAGE_MINIMUM (Reserved (no event indicated)) */ \ + 0x29, 0xDF, /* USAGE_MAXIMUM (Left Control - 1) */ \ + 0x81, 0x00, /* INPUT (Data,Ary,Abs) */ \ + 0xc0 /* END_COLLECTION */ + +#define HID_REPORT_MOUSE_ABSOLUTE /* Mouse absolute */ \ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ + 0x09, 0x02, /* USAGE (Mouse) */ \ + 0xa1, 0x01, /* COLLECTION (Application) */ \ + 0x09, 0x01, /* USAGE (Pointer) */ \ + 0xa1, 0x00, /* COLLECTION (Physical) */ \ + 0x85, HID_REPORTID_MOUSE_ABS, /* REPORT_ID */ \ + 0x05, 0x09, /* USAGE_PAGE (Button) */ \ + 0x19, 0x01, /* USAGE_MINIMUM (Button 1) */ \ + 0x29, 0x03, /* USAGE_MAXIMUM (Button 3) */ \ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \ + 0x95, 0x03, /* REPORT_COUNT (3) */ \ + 0x75, 0x01, /* REPORT_SIZE (1) */ \ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ + 0x95, 0x01, /* REPORT_COUNT (1) */ \ + 0x75, 0x05, /* REPORT_SIZE (5) */ \ + 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ \ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ + 0x09, 0x30, /* USAGE (X) */ \ + 0x09, 0x31, /* USAGE (Y) */ \ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ + 0x26, 0xff, 0x7f, /* LOGICAL_MAXIMUM (32767) */ \ + 0x75, 0x10, /* REPORT_SIZE (16) */ \ + 0x95, 0x02, /* REPORT_COUNT (2) */ \ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ + 0xc0, /* END_COLLECTION */ \ + 0xc0 /* END_COLLECTION */ + +#define HID_REPORT_MOUSE_RELATIVE /* Mouse relative */ \ + 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_MOUSE, /* REPORT_ID */ \ + 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) */ \ + 0x95, 0x01, /* REPORT_COUNT (1) */ \ + 0x75, 0x03, /* REPORT_SIZE (3) */ \ + 0x81, 0x01, /* INPUT (Cnst,Var,Abs) */ \ + 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) */ \ + 0xc0, /* END_COLLECTION */ \ + 0xc0 /* END_COLLECTION */ + +#define HID_REPORT_SYSTEMCONTROL /* System Control (Power Down, Sleep, Wakeup, ...) */ \ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ \ + 0x09, 0x80, /* USAGE (System Control) */ \ + 0xa1, 0x01, /* COLLECTION (Application) */ \ + 0x85, HID_REPORTID_SYSTEMCONTROL, /* REPORT_ID */ \ + 0x09, 0x81, /* USAGE (System Power Down) */ \ + 0x09, 0x82, /* USAGE (System Sleep) */ \ + 0x09, 0x83, /* USAGE (System Wakeup) */ \ + 0x09, 0x8E, /* USAGE (System Cold Restart) */ \ + 0x09, 0x8F, /* USAGE (System Warm Restart) */ \ + 0x09, 0xA0, /* USAGE (System Dock) */ \ + 0x09, 0xA1, /* USAGE (System Undock) */ \ + 0x09, 0xA7, /* USAGE (System Speaker Mute) */ \ + 0x09, 0xA8, /* USAGE (System Hibernate) */ \ + /* although these display usages are not that important, they don't cost */ \ + /* much more than declaring the otherwise necessary constant fill bits */ \ + 0x09, 0xB0, /* USAGE (System Display Invert) */ \ + 0x09, 0xB1, /* USAGE (System Display Internal) */ \ + 0x09, 0xB2, /* USAGE (System Display External) */ \ + 0x09, 0xB3, /* USAGE (System Display Both) */ \ + 0x09, 0xB4, /* USAGE (System Display Dual) */ \ + 0x09, 0xB5, /* USAGE (System Display Toggle Intern/Extern) */ \ + 0x09, 0xB6, /* USAGE (System Display Swap) */ \ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \ + 0x75, 0x01, /* REPORT_SIZE (1) */ \ + 0x95, 0x10, /* REPORT_COUNT (16) */ \ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ + 0xc0 /* END_COLLECTION */ + +#define HID_REPORT_CONSUMERCONTROL /* Consumer Control (Sound/Media keys) */ \ + 0x05, 0x0c, /* USAGE_PAGE (Consumer Devices) */ \ + 0x09, 0x01, /* USAGE (Consumer Control) */ \ + 0xa1, 0x01, /* COLLECTION (Application) */ \ + 0x85, HID_REPORTID_CONSUMERCONTROL, /* REPORT_ID */ \ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ \ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ \ + 0x75, 0x01, /* REPORT_SIZE (1) */ \ + 0x95, 0x08, /* REPORT_COUNT (8) */ \ + 0x09, 0xe2, /* USAGE (Mute) 0x01 */ \ + 0x09, 0xe9, /* USAGE (Volume Up) 0x02 */ \ + 0x09, 0xea, /* USAGE (Volume Down) 0x03 */ \ + 0x09, 0xcd, /* USAGE (Play/Pause) 0x04 */ \ + 0x09, 0xb7, /* USAGE (Stop) 0x05 */ \ + 0x09, 0xb6, /* USAGE (Scan Previous Track) 0x06 */ \ + 0x09, 0xb5, /* USAGE (Scan Next Track) 0x07 */ \ + 0x09, 0xb8, /* USAGE (Eject) 0x08 */ \ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ \ + 0xc0 + +#define HID_REPORT_RAWHID /* RAW HID */ \ + 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), /* 30 */ \ + 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE), \ +\ + 0xA1, 0x01, /* Collection 0x01 */ \ + 0x85, HID_REPORTID_RAWHID, /* 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 */ + +extern const u8 _hidReportDescriptor[] PROGMEM; +const u8 _hidReportDescriptor[] = { + + HID_REPORT_KEYBOARD, + HID_REPORT_MOUSE_RELATIVE, +#ifdef HID_MOUSE_ABS_ENABLED + HID_REPORT_MOUSE_ABSOLUTE, +#endif + HID_REPORT_SYSTEMCONTROL, + HID_REPORT_CONSUMERCONTROL, +#if RAWHID_ENABLED + HID_REPORT_RAWHID +#endif +}; + +size_t getsizeof_hidReportDescriptor() { + return sizeof(_hidReportDescriptor); +} + +//================================================================================ +//================================================================================ +// Mouse + +Mouse_::Mouse_(void) : _buttons(0) +{ +} + +void Mouse_::begin(void) +{ +} + +void Mouse_::end(void) +{ +} + +void Mouse_::click(uint8_t b) +{ + _buttons = b; + move(0,0,0); + _buttons = 0; + move(0,0,0); +} + +void Mouse_::move(signed char x, signed char y, signed char wheel) +{ + u8 m[4]; + m[0] = _buttons; + m[1] = x; + m[2] = y; + m[3] = wheel; + HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m)); +} + +// X and Y have the range of 0 to 32767. +// The USB Host will convert them to pixels on the screen. +// +// x=0,y=0 is top-left corner of the screen +// x=32767,y=0 is the top right corner +// x=32767,y=32767 is the bottom right corner +// x=0,y=32767 is the bottom left corner +// +// When converting these coordinates to pixels on screen, Mac OS X's +// default HID driver maps the inner 85% of the coordinate space to +// the screen's physical dimensions. This means that any value between +// 0 and 2293 or 30474 and 32767 will move the mouse to the screen +// edge on a Mac +// +// For details, see: +// http://lists.apple.com/archives/usb/2011/Jun/msg00032.html + + +void Mouse_::moveAbsolute(uint16_t x, uint16_t y) +{ + u8 m[5]; + m[0] = _buttons; + m[1] = LSB(x); + m[2] = MSB(x); + m[3] = LSB(y); + m[4] = MSB(y); + HID_SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m)); +} + +void Mouse_::buttons(uint8_t b) +{ + if (b != _buttons) + { + _buttons = b; + move(0,0,0); + } +} + +void Mouse_::press(uint8_t b) +{ + buttons(_buttons | b); +} + +void Mouse_::release(uint8_t b) +{ + buttons(_buttons & ~b); +} + +bool Mouse_::isPressed(uint8_t b) +{ + if ((b & _buttons) > 0) + return true; + return false; +} + +//================================================================================ +//================================================================================ +// Keyboard + +Keyboard_::Keyboard_(void) +{ +} + +void Keyboard_::begin(void) +{ +} + +void Keyboard_::end(void) +{ +} + +void Keyboard_::sendReport(KeyReport* keys) +{ + HID_SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys)); +} + +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 +}; + +uint8_t USBPutChar(uint8_t c); + + + // pressKeycode() 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 releaseKeycode(), releaseAll(), or otherwise clear the report and resend. + size_t Keyboard_::pressKeycode(uint8_t k) + { + if (!addKeycodeToReport(k)) { + return 0; + } + sendReport(&_keyReport); + } + + size_t Keyboard_::addKeycodeToReport(uint8_t k) + { + uint8_t index = 0; + uint8_t done = 0; + + if ((k >= HID_KEYBOARD_LEFT_CONTROL) && (k <= HID_KEYBOARD_RIGHT_GUI)) { + // it's a modifier key + _keyReport.modifiers |= (0x01 << (k - HID_KEYBOARD_LEFT_CONTROL)); + } else { + // it's some other key: + // Add k to the key report only if it's not already present + // and if there is an empty slot. + for (index = 0; index < KEYREPORT_KEYCOUNT; index++) { + if (_keyReport.keys[index] != k) { // is k already in list? + if (0 == _keyReport.keys[index]) { // have we found an empty slot? + _keyReport.keys[index] = k; + done = 1; + break; + } + } else { + done = 1; + break; + } + + } + + // use separate variable to check if slot was found + // for style reasons - we do not know how the compiler + // handles the for() index when it leaves the loop + if (0 == done) { + setWriteError(); + return 0; + } + } + + return 1; + } + + // press() transforms the given key to the actual keycode and calls + // pressKeycode() to actually press this key. + // + size_t Keyboard_::press(uint8_t k) + { + if (k >= KEY_RIGHT_GUI + 1) { + // it's a non-printing key (not a modifier) + k = k - (KEY_RIGHT_GUI + 1); + } else { + if (k >= KEY_LEFT_CTRL) { + // it's a modifier key + k = k - KEY_LEFT_CTRL + HID_KEYBOARD_LEFT_CONTROL; + } else { + k = pgm_read_byte(_asciimap + k); + if (k) { + if (k & SHIFT) { + // it's a capital letter or other character reached with shift + // the left shift modifier + addKeycodeToReport(HID_KEYBOARD_LEFT_SHIFT); + k = k ^ SHIFT; + } + } else { + return 0; + } + } + } + + pressKeycode(k); + return 1; + } + +// System Control +// k is one of the SYSTEM_CONTROL defines which come from the HID usage table "Generic Desktop Page (0x01)" +// in "HID Usage Tables" (HUT1_12v2.pdf) +size_t Keyboard_::systemControl(uint8_t k) +{ + if(k <= 16) + { + u16 mask = 0; + u8 m[2]; + + if(k > 0) + { + mask = 1 << (k - 1); + } + + m[0] = LSB(mask); + m[1] = MSB(mask); + HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m)); + + // these are all OSCs, so send a clear to make it possible to send it again later + m[0] = 0; + m[1] = 0; + HID_SendReport(HID_REPORTID_SYSTEMCONTROL,m,sizeof(m)); + return 1; + } + else + { + setWriteError(); + return 0; + } +} + +// Consumer Control +// k is one of the CONSUMER_CONTROL defines which come from the HID usage table "Consumer Devices Page (0x0c)" +// in "HID Usage Tables" (HUT1_12v2.pdf) +size_t Keyboard_::consumerControl(uint8_t k) +{ + if(k <= 8) + { + u16 mask = 0; + u8 m[2]; + + if(k > 0) + { + mask = 1 << (k - 1); + } + + m[0] = LSB(mask); + m[1] = MSB(mask); + HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m)); + + // these are all OSCs, so send a clear to make it possible to send it again later + m[0] = 0; + m[1] = 0; + HID_SendReport(HID_REPORTID_CONSUMERCONTROL,m,sizeof(m)); + return 1; + } + else + { + setWriteError(); + return 0; + } +} + +// releaseKeycode() 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. +// When send is set to FALSE (= 0) no sendReport() is executed. This comes in +// handy when combining key releases (e.g. SHIFT+A). +size_t Keyboard_::releaseKeycode(uint8_t k) +{ + if (!removeKeycodeFromReport(k)) { + return 0; + } + sendReport(&_keyReport); +} + +size_t Keyboard_::removeKeycodeFromReport(uint8_t k) +{ + uint8_t indexA; + uint8_t indexB; + uint8_t count; + + if ((k >= HID_KEYBOARD_LEFT_CONTROL) && (k <= HID_KEYBOARD_RIGHT_GUI)) { + // it's a modifier key + _keyReport.modifiers = _keyReport.modifiers & (~(0x01 << (k - HID_KEYBOARD_LEFT_CONTROL))); + } else { + // it's some other key: + // 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 (indexA = 0; indexA < KEYREPORT_KEYCOUNT; indexA++) { + if (_keyReport.keys[indexA] == k) { + _keyReport.keys[indexA] = 0; + } + } + + // finally rearrange the keys list so that the free (= 0x00) are at the + // end of the keys list - some implementations stop for keys at the + // first occurence of an 0x00 in the keys list + // so (0x00)(0x01)(0x00)(0x03)(0x02)(0x00) becomes + // (0x01)(0x03)(0x02)(0x00)(0x00)(0x00) + count = 0; // holds the number of zeros we've found + indexA = 0; + while ((indexA + count) < KEYREPORT_KEYCOUNT) { + if (0 == _keyReport.keys[indexA]) { + count++; // one more zero + for (indexB = indexA; indexB < KEYREPORT_KEYCOUNT-count; indexB++) { + _keyReport.keys[indexB] = _keyReport.keys[indexB+1]; + } + _keyReport.keys[KEYREPORT_KEYCOUNT-count] = 0; + } else { + indexA++; // one more non-zero + } + } + } + + return 1; +} + +// release() transforms the given key to the actual keycode and calls +// releaseKeycode() to actually release this key. +// +size_t Keyboard_::release(uint8_t k) +{ + uint8_t i; + + if (k >= KEY_RIGHT_GUI + 1) { + // it's a non-printing key (not a modifier) + k = k - (KEY_RIGHT_GUI + 1); + } else { + if (k >= KEY_LEFT_CTRL) { + // it's a modifier key + k = k - KEY_LEFT_CTRL + HID_KEYBOARD_LEFT_CONTROL; + } else { + k = pgm_read_byte(_asciimap + k); + if (k) { + if ((k & SHIFT)) { + // it's a capital letter or other character reached with shift + // the left shift modifier + removeKeycodeFromReport(HID_KEYBOARD_LEFT_SHIFT); + k = k ^ SHIFT; + } + } else { + return 0; + } + } + } + + releaseKeycode(k); + return 1; +} + +void Keyboard_::releaseAll(void) +{ + _keyReport.keys[0] = 0; + _keyReport.keys[1] = 0; + _keyReport.keys[2] = 0; + _keyReport.keys[3] = 0; + _keyReport.keys[4] = 0; + _keyReport.keys[5] = 0; + _keyReport.modifiers = 0; + sendReport(&_keyReport); +} + +size_t Keyboard_::write(uint8_t c) +{ + uint8_t p = press(c); // Keydown + release(c); // Keyup + return p; // just return the result of press() since release() almost always returns 1 +} + +size_t Keyboard_::writeKeycode(uint8_t c) +{ + uint8_t p = pressKeycode(c); // Keydown + uint8_t r = releaseKeycode(c); // Keyup + return (p); // just return the result of pressKeycode() since release() almost always returns 1 +} + +#endif \ No newline at end of file diff --git a/libraries/CompleteHID/CompleteHID.h b/libraries/CompleteHID/CompleteHID.h new file mode 100644 index 000000000..bc6c94985 --- /dev/null +++ b/libraries/CompleteHID/CompleteHID.h @@ -0,0 +1,156 @@ +#ifndef MOUSEANDKEYBOARD_h + +#if defined(_USING_HID) + +#error "Can only attach one submodule to HID module" + +#else + +#define _USING_HID + +#include "HID.h" +#include "HIDTables.h" + +//================================================================================ +//================================================================================ +// Mouse + +#define MOUSE_LEFT 1 +#define MOUSE_RIGHT 2 +#define MOUSE_MIDDLE 4 +#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE) + +class Mouse_ +{ +private: + uint8_t _buttons; + void buttons(uint8_t b); +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 moveAbsolute(uint16_t x, uint16_t y); + void press(uint8_t b = MOUSE_LEFT); // press LEFT by default + void release(uint8_t b = MOUSE_LEFT); // release LEFT by default + bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default +}; +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 + +// Low level key report: up to 6 keys and shift, ctrl etc at once +#define KEYREPORT_KEYCOUNT 0x06 +typedef struct +{ + uint8_t modifiers; + uint8_t reserved; + uint8_t keys[KEYREPORT_KEYCOUNT]; +} KeyReport; + +class Keyboard_ : public Print +{ +private: + KeyReport _keyReport; + void sendReport(KeyReport* keys); +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 size_t writeKeycode(uint8_t k); + virtual size_t pressKeycode(uint8_t k); + virtual size_t releaseKeycode(uint8_t k); + virtual size_t addKeycodeToReport(uint8_t k); + virtual size_t removeKeycodeFromReport(uint8_t k); + virtual void releaseAll(void); + virtual size_t systemControl(uint8_t k); + virtual size_t consumerControl(uint8_t k); +}; +extern Keyboard_ Keyboard; + +// System Control values for Keyboard_::systemControl() +// these defines come from the HID usage table "Generic Desktop Page (0x01)" +// in the USB standard document "HID Usage Tables" (HUT1_12v2.pdf) +// Currently this list contains only OSC (one shot control) values, +// the implementation of systemControl will have to be changed when +// adding OOC or RTC values. +#define SYSTEM_CONTROL_POWER_DOWN 1 +#define SYSTEM_CONTROL_SLEEP 2 +#define SYSTEM_CONTROL_WAKEUP 3 +#define SYSTEM_CONTROL_COLD_RESTART 4 +#define SYSTEM_CONTROL_WARM_RESTART 5 +#define SYSTEM_CONTROL_DOCK 6 +#define SYSTEM_CONTROL_UNDOCK 7 +#define SYSTEM_CONTROL_SPEAKER_MUTE 8 +#define SYSTEM_CONTROL_HIBERNATE 9 +#define SYSTEM_CONTROL_DISPLAY_INVERT 10 +#define SYSTEM_CONTROL_DISPLAY_INTERNAL 11 +#define SYSTEM_CONTROL_DISPLAY_EXTERNAL 12 +#define SYSTEM_CONTROL_DISPLAY_BOTH 13 +#define SYSTEM_CONTROL_DISPLAY_DUAL 14 +#define SYSTEM_CONTROL_DISPLAY_TOGGLE_INT_EXT 15 +#define SYSTEM_CONTROL_DISPLAY_SWAP 16 + + + +// Consumer Control values for Keyboard_::systemControl() +// these defines come from the HID usage table "Consumer Device Page (0x0c)" +// in the USB standard document "HID Usage Tables" (HUT1_12v2.pdf) +// Currently this list contains only OSC (one shot control) values, +// the implementation of systemControl will have to be changed when +// adding OOC or RTC values. + +#define CONSUMER_CONTROL_VOLUME_MUTE 1 +#define CONSUMER_CONTROL_VOLUME_UP 2 +#define CONSUMER_CONTROL_VOLUME_DOWN 3 +#define CONSUMER_CONTROL_PLAY_PAUSE 4 +#define CONSUMER_CONTROL_STOP 5 +#define CONSUMER_CONTROL_PREV_TRACK 6 +#define CONSUMER_CONTROL_NEXT_TRACK 7 +#define CONSUMER_CONTROL_EJECT 8 + +#endif +#endif \ No newline at end of file diff --git a/libraries/CompleteHID/HIDTables.h b/libraries/CompleteHID/HIDTables.h new file mode 100644 index 000000000..a00de5faf --- /dev/null +++ b/libraries/CompleteHID/HIDTables.h @@ -0,0 +1,677 @@ +#ifndef __HIDTables__ +#define HID___HIDTables__ + + +// These mappings were extracted and transcribed from +// http://www.usb.org_SLASH_developers_SLASH_devclass_docs_SLASH_Hut1_12v2.pdf +// +// In most cases, I've preserved the "official" USB Implementers forum +// "Usage Name", though I've standardized some abbreviations and spacing +// that were inconsistent in the original specification. Non alpha-numeric +// characters in symbol names were converted into those characters' names. +// +// To match Arduino code style, all hid usage names are fully upper case. +// +// Not every HID usage listed in this file is currently supported by Arduino +// In particular, any System Control or Consumer Control entry that doesn't +// have a comment indicating that it's "HID type OSC" will require additional +// code in the Arduino core to work. +// +// Non-working usages are listed here in the interest of not having to manually +// convert more usage names each and every time our HID stack gets a little bit +// better. +// +// +// -- Jesse Vincent , January 2014 + + + +// System control mappings + +#define HID_SYSTEM_POWER_DOWN 0x81 // HID type OSC +#define HID_SYSTEM_SLEEP 0x82 // HID type OSC +#define HID_SYSTEM_WAKE_UP 0x83 // HID type OSC +#define HID_SYSTEM_CONTEXT_MENU 0x84 // HID type OSC +#define HID_SYSTEM_MAIN_MENU 0x85 // HID type OSC +#define HID_SYSTEM_APP_MENU 0x86 // HID type OSC +#define HID_SYSTEM_MENU_HELP 0x87 // HID type OSC +#define HID_SYSTEM_MENU_EXIT 0x88 // HID type OSC +#define HID_SYSTEM_MENU_SELECT 0x89 // HID type OSC +#define HID_SYSTEM_MENU_RIGHT 0x8A // HID type RTC +#define HID_SYSTEM_MENU_LEFT 0x8B // HID type RTC +#define HID_SYSTEM_MENU_UP 0x8C // HID type RTC +#define HID_SYSTEM_MENU_DOWN 0x8D // HID type RTC +#define HID_SYSTEM_COLD_RESTART 0x8E // HID type OSC +#define HID_SYSTEM_WARM_RESTART 0x8F // HID type OSC +#define HID_D_PAD_UP 0x90 // HID type OOC +#define HID_D_PAD_DOWN 0x91 // HID type OOC +#define HID_D_PAD_RIGHT 0x92 // HID type OOC +#define HID_D_PAD_LEFT 0x93 // HID type OOC +// 0x94-0x9F are reserved +#define HID_SYSTEM_DOCK 0xA0 // HID type OSC +#define HID_SYSTEM_UNDOCK 0xA1 // HID type OSC +#define HID_SYSTEM_SETUP 0xA2 // HID type OSC +#define HID_SYSTEM_BREAK 0xA3 // HID type OSC +#define HID_SYSTEM_DEBUGGER_BREAK 0xA4 // HID type OSC +#define HID_APPLICATION_BREAK 0xA5 // HID type OSC +#define HID_APPLICATION_DEBUGGER_BREAK 0xA6 // HID type OSC +#define HID_SYSTEM_SPEAKER_MUTE 0xA7 // HID type OSC +#define HID_SYSTEM_HIBERNATE 0xA8 // HID type OSC +// 0xA9-0xAF are reserved +#define HID_SYSTEM_DISPLAY_INVERT 0xB0 // HID type OSC +#define HID_SYSTEM_DISPLAY_INTERNAL 0xB1 // HID type OSC +#define HID_SYSTEM_DISPLAY_EXTERNAL 0xB2 // HID type OSC +#define HID_SYSTEM_DISPLAY_BOTH 0xB3 // HID type OSC +#define HID_SYSTEM_DISPLAY_DUAL 0xB4 // HID type OSC +#define HID_SYSTEM_DISPLAY_TOGGLE_INT_SLASH_EXT 0xB5 // HID type OSC +#define HID_SYSTEM_DISPLAY_SWAP_PRIMARY_SLASH_SECONDARY 0xB6 // HID type OSC +#define HID_SYSTEM_DISPLAY_LCD_AUTOSCALE 0xB7 // HID type OSC + +// Keyboard HID mappings + +// Reserved (no_event_indicated) 0x00 +#define HID_KEYBOARD_ERROR_ROLLOVER 0x01 +#define HID_KEYBOARD_POST_FAIL 0x02 +#define HID_KEYBOARD_ERROR_UNDEFINED 0x03 +#define HID_KEYBOARD_A_AND_A 0x04 +#define HID_KEYBOARD_B_AND_B 0x05 +#define HID_KEYBOARD_C_AND_C 0x06 +#define HID_KEYBOARD_D_AND_D 0x07 +#define HID_KEYBOARD_E_AND_E 0x08 +#define HID_KEYBOARD_F_AND_F 0x09 +#define HID_KEYBOARD_G_AND_G 0x0A +#define HID_KEYBOARD_H_AND_H 0x0B +#define HID_KEYBOARD_I_AND_I 0x0C +#define HID_KEYBOARD_J_AND_J 0x0D +#define HID_KEYBOARD_K_AND_K 0x0E +#define HID_KEYBOARD_L_AND_L 0x0F +#define HID_KEYBOARD_M_AND_M 0x10 +#define HID_KEYBOARD_N_AND_N 0x11 +#define HID_KEYBOARD_O_AND_O 0x12 +#define HID_KEYBOARD_P_AND_P 0x13 +#define HID_KEYBOARD_Q_AND_Q 0x14 +#define HID_KEYBOARD_R_AND_R 0x15 +#define HID_KEYBOARD_S_AND_S 0x16 +#define HID_KEYBOARD_T_AND_T 0x17 +#define HID_KEYBOARD_U_AND_U 0x18 +#define HID_KEYBOARD_V_AND_V 0x19 +#define HID_KEYBOARD_W_AND_W 0x1A +#define HID_KEYBOARD_X_AND_X 0x1B +#define HID_KEYBOARD_Y_AND_Y 0x1C +#define HID_KEYBOARD_Z_AND_Z 0x1D +#define HID_KEYBOARD_1_AND_EXCLAMATION_POINT 0x1E +#define HID_KEYBOARD_2_AND_AT 0x1F +#define HID_KEYBOARD_3_AND_POUND 0x20 +#define HID_KEYBOARD_4_AND_DOLLAR 0x21 +#define HID_KEYBOARD_5_AND_PERCENT 0x22 +#define HID_KEYBOARD_6_AND_CARAT 0x23 +#define HID_KEYBOARD_7_AND_AMPERSAND 0x24 +#define HID_KEYBOARD_8_AND_ASTERISK 0x25 +#define HID_KEYBOARD_9_AND_LEFT_PAREN 0x26 +#define HID_KEYBOARD_0_AND_RIGHT_PAREN 0x27 +#define HID_KEYBOARD_ENTER 0x28 // (MARKED AS ENTER_SLASH_RETURN) +#define HID_KEYBOARD_ESCAPE 0x29 +#define HID_KEYBOARD_DELETE 0x2A // (BACKSPACE) +#define HID_KEYBOARD_TAB 0x2B +#define HID_KEYBOARD_SPACEBAR 0x2C +#define HID_KEYBOARD_MINUS_AND_UNDERSCORE 0x2D // (UNDERSCORE) +#define HID_KEYBOARD_EQUALS_AND_PLUS 0x2E +#define HID_KEYBOARD_LEFT_BRACKET_AND_LEFT_CURLY_BRACE 0x2F +#define HID_KEYBOARD_RIGHT_BRACKET_AND_RIGHT_CURLY_BRACE 0x30 +#define HID_KEYBOARD_BACKSLASH_AND_PIPE 0x31 +#define HID_KEYBOARD_NON_US_POUND_AND_TILDE 0x32 +#define HID_KEYBOARD_SEMICOLON_AND_COLON 0x33 +#define HID_KEYBOARD_QUOTE_AND_DOUBLEQUOTE 0x34 +#define HID_KEYBOARD_GRAVE_ACCENT_AND_TILDE 0x35 +#define HID_KEYBOARD_COMMA_AND_LESS_THAN 0x36 +#define HID_KEYBOARD_PERIOD_AND_GREATER_THAN 0x37 +#define HID_KEYBOARD_SLASH_AND_QUESTION_MARK 0x38 +#define HID_KEYBOARD_CAPS_LOCK 0x39 +#define HID_KEYBOARD_F1 0x3A +#define HID_KEYBOARD_F2 0x3B +#define HID_KEYBOARD_F3 0x3C +#define HID_KEYBOARD_F4 0x3D +#define HID_KEYBOARD_F5 0x3E +#define HID_KEYBOARD_F6 0x3F +#define HID_KEYBOARD_F7 0x40 +#define HID_KEYBOARD_F8 0x41 +#define HID_KEYBOARD_F9 0x42 +#define HID_KEYBOARD_F10 0x43 +#define HID_KEYBOARD_F11 0x44 +#define HID_KEYBOARD_F12 0x45 +#define HID_KEYBOARD_PRINTSCREEN 0x46 +#define HID_KEYBOARD_SCROLL_LOCK 0x47 +#define HID_KEYBOARD_PAUSE 0x48 +#define HID_KEYBOARD_INSERT 0x49 +#define HID_KEYBOARD_HOME 0x4A +#define HID_KEYBOARD_PAGE_UP 0x4B +#define HID_KEYBOARD_DELETE_FORWARD 0x4C +#define HID_KEYBOARD_END 0x4D +#define HID_KEYBOARD_PAGE_DOWN 0x4E +#define HID_KEYBOARD_RIGHTARROW 0x4F +#define HID_KEYBOARD_LEFTARROW 0x50 +#define HID_KEYBOARD_DOWNARROW 0x51 +#define HID_KEYBOARD_UPARROW 0x52 +#define HID_KEYPAD_NUM_LOCK_AND_CLEAR 0x53 +#define HID_KEYPAD_DIVIDE 0x54 +#define HID_KEYPAD_MULTIPLY 0x55 +#define HID_KEYPAD_SUBTRACT 0x56 +#define HID_KEYPAD_ADD 0x57 +#define HID_KEYPAD_ENTER 0x58 +#define HID_KEYPAD_1_AND_END 0x59 +#define HID_KEYPAD_2_AND_DOWN_ARROW 0x5A +#define HID_KEYPAD_3_AND_PAGE_DOWN 0x5B +#define HID_KEYPAD_4_AND_LEFT_ARROW 0x5C +#define HID_KEYPAD_5 0x5D +#define HID_KEYPAD_6_AND_RIGHT_ARROW 0x5E +#define HID_KEYPAD_7_AND_HOME 0x5F +#define HID_KEYPAD_8_AND_UP_ARROW 0x60 +#define HID_KEYPAD_9_AND_PAGE_UP 0x61 +#define HID_KEYPAD_0_AND_INSERT 0x62 +#define HID_KEYPAD_PERIOD_AND_DELETE 0x63 +#define HID_KEYBOARD_NON_US_BACKSLASH_AND_PIPE 0x64 +#define HID_KEYBOARD_APPLICATION 0x65 +#define HID_KEYBOARD_POWER 0x66 +#define HID_KEYPAD_EQUALS 0x67 +#define HID_KEYBOARD_F13 0x68 +#define HID_KEYBOARD_F14 0x69 +#define HID_KEYBOARD_F15 0x6A +#define HID_KEYBOARD_F16 0x6B +#define HID_KEYBOARD_F17 0x6C +#define HID_KEYBOARD_F18 0x6D +#define HID_KEYBOARD_F19 0x6E +#define HID_KEYBOARD_F20 0x6F +#define HID_KEYBOARD_F21 0x70 +#define HID_KEYBOARD_F22 0x71 +#define HID_KEYBOARD_F23 0x72 +#define HID_KEYBOARD_F24 0x73 +#define HID_KEYBOARD_EXECUTE 0x74 +#define HID_KEYBOARD_HELP 0x75 +#define HID_KEYBOARD_MENU 0x76 +#define HID_KEYBOARD_SELECT 0x77 +#define HID_KEYBOARD_STOP 0x78 +#define HID_KEYBOARD_AGAIN 0x79 +#define HID_KEYBOARD_UNDO 0x7A +#define HID_KEYBOARD_CUT 0x7B +#define HID_KEYBOARD_COPY 0x7C +#define HID_KEYBOARD_PASTE 0x7D +#define HID_KEYBOARD_FIND 0x7E +#define HID_KEYBOARD_MUTE 0x7F +#define HID_KEYBOARD_VOLUME_UP 0x80 +#define HID_KEYBOARD_VOLUME_DOWN 0x81 +#define HID_KEYBOARD_LOCKING_CAPS_LOCK 0x82 +#define HID_KEYBOARD_LOCKING_NUM_LOCK 0x83 +#define HID_KEYBOARD_LOCKING_SCROLL_LOCK 0x84 +#define HID_KEYPAD_COMMA 0x85 +#define HID_KEYPAD_EQUAL_SIGN 0x86 +#define HID_KEYBOARD_INTERNATIONAL1 0x87 +#define HID_KEYBOARD_INTERNATIONAL2 0x88 +#define HID_KEYBOARD_INTERNATIONAL3 0x89 +#define HID_KEYBOARD_INTERNATIONAL4 0x8A +#define HID_KEYBOARD_INTERNATIONAL5 0x8B +#define HID_KEYBOARD_INTERNATIONAL6 0x8C +#define HID_KEYBOARD_INTERNATIONAL7 0x8D +#define HID_KEYBOARD_INTERNATIONAL8 0x8E +#define HID_KEYBOARD_INTERNATIONAL9 0x8F +#define HID_KEYBOARD_LANG1 0x90 +#define HID_KEYBOARD_LANG2 0x91 +#define HID_KEYBOARD_LANG3 0x92 +#define HID_KEYBOARD_LANG4 0x93 +#define HID_KEYBOARD_LANG5 0x94 +#define HID_KEYBOARD_LANG6 0x95 +#define HID_KEYBOARD_LANG7 0x96 +#define HID_KEYBOARD_LANG8 0x97 +#define HID_KEYBOARD_LANG9 0x98 +#define HID_KEYBOARD_ALTERNATE_ERASE 0x99 +#define HID_KEYBOARD_SYSREQ_SLASH_ATTENTION 0x9A +#define HID_KEYBOARD_CANCEL 0x9B +#define HID_KEYBOARD_CLEAR 0x9C +#define HID_KEYBOARD_PRIOR 0x9D +#define HID_KEYBOARD_RETURN 0x9E +#define HID_KEYBOARD_SEPARATOR 0x9F +#define HID_KEYBOARD_OUT 0xA0 +#define HID_KEYBOARD_OPER 0xA1 +#define HID_KEYBOARD_CLEAR_SLASH_AGAIN 0xA2 +#define HID_KEYBOARD_CRSEL_SLASH_PROPS 0xA3 +#define HID_KEYBOARD_EXSEL 0xA4 +// Reserved 0xA5-AF +#define HID_KEYPAD_00 0xB0 +#define HID_KEYPAD_000 0xB1 +#define HID_THOUSANDS_SEPARATOR 0xB2 +#define HID_DECIMAL_SEPARATOR 0xB3 +#define HID_CURRENCY_UNIT 0xB4 +#define HID_CURRENCY_SUBUNIT 0xB5 +#define HID_KEYPAD_LEFT_PAREN 0xB6 +#define HID_KEYPAD_RIGHT_PAREN 0xB7 +#define HID_KEYPAD_LEFT_CURLY_BRACE 0xB8 +#define HID_KEYPAD_RIGHT_CURLY_BRACE 0xB9 +#define HID_KEYPAD_TAB 0xBA +#define HID_KEYPAD_BACKSPACE 0xBB +#define HID_KEYPAD_A 0xBC +#define HID_KEYPAD_B 0xBD +#define HID_KEYPAD_C 0xBE +#define HID_KEYPAD_D 0xBF +#define HID_KEYPAD_E 0xC0 +#define HID_KEYPAD_F 0xC1 +#define HID_KEYPAD_XOR 0xC2 +#define HID_KEYPAD_CARAT 0xC3 +#define HID_KEYPAD_PERCENT 0xC4 +#define HID_KEYPAD_LESS_THAN 0xC5 +#define HID_KEYPAD_GREATER_THAN 0xC6 +#define HID_KEYPAD_AMPERSAND 0xC7 +#define HID_KEYPAD_DOUBLEAMPERSAND 0xC8 +#define HID_KEYPAD_PIPE 0xC9 +#define HID_KEYPAD_DOUBLEPIPE 0xCA +#define HID_KEYPAD_COLON 0xCB +#define HID_KEYPAD_POUND_SIGN 0xCC +#define HID_KEYPAD_SPACE 0xCD +#define HID_KEYPAD_AT_SIGN 0xCE +#define HID_KEYPAD_EXCLAMATION_POINT 0xCF +#define HID_KEYPAD_MEMORY_STORE 0xD0 +#define HID_KEYPAD_MEMORY_RECALL 0xD1 +#define HID_KEYPAD_MEMORY_CLEAR 0xD2 +#define HID_KEYPAD_MEMORY_ADD 0xD3 +#define HID_KEYPAD_MEMORY_SUBTRACT 0xD4 +#define HID_KEYPAD_MEMORY_MULTIPLY 0xD5 +#define HID_KEYPAD_MEMORY_DIVIDE 0xD6 +#define HID_KEYPAD_PLUS_SLASH_MINUS 0xD7 +#define HID_KEYPAD_CLEAR 0xD8 +#define HID_KEYPAD_CLEAR_ENTRY 0xD9 +#define HID_KEYPAD_BINARY 0xDA +#define HID_KEYPAD_OCTAL 0xDB +#define HID_KEYPAD_DECIMAL 0xDC +#define HID_KEYPAD_HEXADECIMAL 0xDD + +// 0xDE-0xDF - RESERVED +#define HID_KEYBOARD_LEFT_CONTROL 0xE0 +#define HID_KEYBOARD_LEFT_SHIFT 0xE1 +#define HID_KEYBOARD_LEFT_ALT 0xE2 +#define HID_KEYBOARD_LEFT_GUI 0xE3 +#define HID_KEYBOARD_RIGHT_CONTROL 0xE4 +#define HID_KEYBOARD_RIGHT_SHIFT 0xE5 +#define HID_KEYBOARD_RIGHT_ALT 0xE6 +#define HID_KEYBOARD_RIGHT_GUI 0xE7 + + +// Consumer_Page_(0x0C) 0x15 +#define HID_CONSUMER_NUMERIC_KEY_PAD 0x02 // HID type NARY +#define HID_CONSUMER_PROGRAMMABLE_BUTTONS 0x03 // HID type NARY +#define HID_CONSUMER_MICROPHONE_CA 0x04 +#define HID_CONSUMER_HEADPHONE_CA 0x05 +#define HID_CONSUMER_GRAPHIC_EQUALIZER_CA 0x06 +// Reserved 0x07-1F +#define HID_CONSUMER_PLUS_10 0x20 // HID type OSC +#define HID_CONSUMER_PLUS_100 0x21 // HID type OSC +#define HID_CONSUMER_AM_SLASH_PM 0x22 // HID type OSC +// Reserved 0x23-3F +#define HID_CONSUMER_POWER 0x30 // HID type OOC +#define HID_CONSUMER_RESET 0x31 // HID type OSC +#define HID_CONSUMER_SLEEP 0x32 // HID type OSC +#define HID_CONSUMER_SLEEP_AFTER 0x33 // HID type OSC +#define HID_CONSUMER_SLEEP_MODE 0x34 // HID type RTC +#define HID_CONSUMER_ILLUMINATION 0x35 // HID type OOC +#define HID_CONSUMER_FUNCTION_BUTTONS 0x36 // HID type NARY +// Reserved 0x37-3F +#define HID_CONSUMER_MENU 0x40 // HID type OOC +#define HID_CONSUMER_MENU_PICK 0x41 // HID type OSC +#define HID_CONSUMER_MENU_UP 0x42 // HID type OSC +#define HID_CONSUMER_MENU_DOWN 0x43 // HID type OSC +#define HID_CONSUMER_MENU_LEFT 0x44 // HID type OSC +#define HID_CONSUMER_MENU_RIGHT 0x45 // HID type OSC +#define HID_CONSUMER_MENU_ESCAPE 0x46 // HID type OSC +#define HID_CONSUMER_MENU_VALUE_INCREASE 0x47 // HID type OSC +#define HID_CONSUMER_MENU_VALUE_DECREASE 0x48 // HID type OSC +// Reserved 0x49-5F +#define HID_CONSUMER_DATA_ON_SCREEN 0x60 // HID type OOC +#define HID_CONSUMER_CLOSED_CAPTION 0x61 // HID type OOC +#define HID_CONSUMER_CLOSED_CAPTION_SELECT 0x62 // HID type OSC +#define HID_CONSUMER_VCR_SLASH_TV 0x63 // HID type OOC +#define HID_CONSUMER_BROADCAST_MODE 0x64 // HID type OSC +#define HID_CONSUMER_SNAPSHOT 0x65 // HID type OSC +#define HID_CONSUMER_STILL 0x66 // HID type OSC +// Reserved 0x67-7F +#define HID_CONSUMER_SELECTION 0x80 // HID type NARY +#define HID_CONSUMER_ASSIGN_SELECTION 0x81 // HID type OSC +#define HID_CONSUMER_MODE_STEP 0x82 // HID type OSC +#define HID_CONSUMER_RECALL_LAST 0x83 // HID type OSC +#define HID_CONSUMER_ENTER_CHANNEL 0x84 // HID type OSC +#define HID_CONSUMER_ORDER_MOVIE 0x85 // HID type OSC +#define HID_CONSUMER_CHANNEL 0x86 // HID type LC +#define HID_CONSUMER_MEDIA_SELECTION 0x87 // HID type NARY +#define HID_CONSUMER_MEDIA_SELECT_COMPUTER 0x88 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_TV 0x89 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_WWW 0x8A // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_DVD 0x8B // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_TELEPHONE 0x8C // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_PROGRAM_GUIDE 0x8D // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_VIDEO_PHONE 0x8E // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_GAMES 0x8F // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_MESSAGES 0x90 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_CD 0x91 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_VCR 0x92 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_TUNER 0x93 // HID type SEL +#define HID_CONSUMER_QUIT 0x94 // HID type OSC +#define HID_CONSUMER_HELP 0x95 // HID type OOC +#define HID_CONSUMER_MEDIA_SELECT_TAPE 0x96 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_CABLE 0x97 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_SATELLITE 0x98 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_SECURITY 0x99 // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_HOME 0x9A // HID type SEL +#define HID_CONSUMER_MEDIA_SELECT_CALL 0x9B // HID type SEL +#define HID_CONSUMER_CHANNEL_INCREMENT 0x9C // HID type OSC +#define HID_CONSUMER_CHANNEL_DECREMENT 0x9D // HID type OSC +#define HID_CONSUMER_MEDIA_SELECT_SAP 0x9E // HID type SEL +// Reserved 0x9F +#define HID_CONSUMER_VCR_PLUS 0xA0 // HID type OSC +#define HID_CONSUMER_ONCE 0xA1 // HID type OSC +#define HID_CONSUMER_DAILY 0xA2 // HID type OSC +#define HID_CONSUMER_WEEKLY 0xA3 // HID type OSC +#define HID_CONSUMER_MONTHLY 0xA4 // HID type OSC +// Reserved 0xA5-AF +#define HID_CONSUMER_PLAY 0xB0 // HID type OOC +#define HID_CONSUMER_PAUSE 0xB1 // HID type OOC +#define HID_CONSUMER_RECORD 0xB2 // HID type OOC +#define HID_CONSUMER_FAST_FORWARD 0xB3 // HID type OOC +#define HID_CONSUMER_REWIND 0xB4 // HID type OOC +#define HID_CONSUMER_SCAN_NEXT_TRACK 0xB5 // HID type OSC +#define HID_CONSUMER_SCAN_PREVIOUS_TRACK 0xB6 // HID type OSC +#define HID_CONSUMER_STOP 0xB7 // HID type OSC +#define HID_CONSUMER_EJECT 0xB8 // HID type OSC +#define HID_CONSUMER_RANDOM_PLAY 0xB9 // HID type OOC +#define HID_CONSUMER_SELECT_DISC 0xBA // HID type NARY +#define HID_CONSUMER_ENTER_DISC_MC 0xBB +#define HID_CONSUMER_REPEAT 0xBC // HID type OSC +#define HID_CONSUMER_TRACKING 0xBD // HID type LC +#define HID_CONSUMER_TRACK_NORMAL 0xBE // HID type OSC +#define HID_CONSUMER_SLOW_TRACKING 0xBF // HID type LC +#define HID_CONSUMER_FRAME_FORWARD 0xC0 // HID type RTC +#define HID_CONSUMER_FRAME_BACK 0xC1 // HID type RTC +#define HID_CONSUMER_MARK 0xC2 // HID type OSC +#define HID_CONSUMER_CLEAR_MARK 0xC3 // HID type OSC +#define HID_CONSUMER_REPEAT_FROM_MARK 0xC4 // HID type OOC +#define HID_CONSUMER_RETURN_TO_MARK 0xC5 // HID type OSC +#define HID_CONSUMER_SEARCH_MARK_FORWARD 0xC6 // HID type OSC +#define HID_CONSUMER_SEARCH_MARK_BACKWARDS 0xC7 // HID type OSC +#define HID_CONSUMER_COUNTER_RESET 0xC8 // HID type OSC +#define HID_CONSUMER_SHOW_COUNTER 0xC9 // HID type OSC +#define HID_CONSUMER_TRACKING_INCREMENT 0xCA // HID type RTC +#define HID_CONSUMER_TRACKING_DECREMENT 0xCB // HID type RTC +#define HID_CONSUMER_STOP_SLASH_EJECT 0xCC // HID type OSC +#define HID_CONSUMER_PLAY_SLASH_PAUSE 0xCD // HID type OSC +#define HID_CONSUMER_PLAY_SLASH_SKIP 0xCE // HID type OSC +// Reserved 0xCF-DF +#define HID_CONSUMER_VOLUME 0xE0 // HID type LC +#define HID_CONSUMER_BALANCE 0xE1 // HID type LC +#define HID_CONSUMER_MUTE 0xE2 // HID type OOC +#define HID_CONSUMER_BASS 0xE3 // HID type LC +#define HID_CONSUMER_TREBLE 0xE4 // HID type LC +#define HID_CONSUMER_BASS_BOOST 0xE5 // HID type OOC +#define HID_CONSUMER_SURROUND_MODE 0xE6 // HID type OSC +#define HID_CONSUMER_LOUDNESS 0xE7 // HID type OOC +#define HID_CONSUMER_MPX 0xE8 // HID type OOC +#define HID_CONSUMER_VOLUME_INCREMENT 0xE9 // HID type RTC +#define HID_CONSUMER_VOLUME_DECREMENT 0xEA // HID type RTC +// Reserved 0xEB-EF +#define HID_CONSUMER_SPEED_SELECT 0xF0 // HID type OSC +#define HID_CONSUMER_PLAYBACK_SPEED 0xF1 // HID type NARY +#define HID_CONSUMER_STANDARD_PLAY 0xF2 // HID type SEL +#define HID_CONSUMER_LONG_PLAY 0xF3 // HID type SEL +#define HID_CONSUMER_EXTENDED_PLAY 0xF4 // HID type SEL +#define HID_CONSUMER_SLOW 0xF5 // HID type OSC +// Reserved 0xF6-FF +#define HID_CONSUMER_FAN_ENABLE 0x100 // HID type OOC +#define HID_CONSUMER_FAN_SPEED 0x101 // HID type LC +#define HID_CONSUMER_LIGHT_ENABLE 0x102 // HID type OOC +#define HID_CONSUMER_LIGHT_ILLUMINATION_LEVEL 0x103 // HID type LC +#define HID_CONSUMER_CLIMATE_CONTROL_ENABLE 0x104 // HID type OOC +#define HID_CONSUMER_ROOM_TEMPERATURE 0x105 // HID type LC +#define HID_CONSUMER_SECURITY_ENABLE 0x106 // HID type OOC +#define HID_CONSUMER_FIRE_ALARM 0x107 // HID type OSC +#define HID_CONSUMER_POLICE_ALARM 0x108 // HID type OSC +#define HID_CONSUMER_PROXIMITY 0x109 // HID type LC +#define HID_CONSUMER_MOTION 0x10A // HID type OSC +#define HID_CONSUMER_DURESS_ALARM 0x10B // HID type OSC +#define HID_CONSUMER_HOLDUP_ALARM 0x10C // HID type OSC +#define HID_CONSUMER_MEDICAL_ALARM 0x10D // HID type OSC +// Reserved 0x10E-14F +#define HID_CONSUMER_BALANCE_RIGHT 0x150 // HID type RTC +#define HID_CONSUMER_BALANCE_LEFT 0x151 // HID type RTC +#define HID_CONSUMER_BASS_INCREMENT 0x152 // HID type RTC +#define HID_CONSUMER_BASS_DECREMENT 0x153 // HID type RTC +#define HID_CONSUMER_TREBLE_INCREMENT 0x154 // HID type RTC +#define HID_CONSUMER_TREBLE_DECREMENT 0x155 // HID type RTC +// Reserved 0x156-15F +#define HID_CONSUMER_SPEAKER_SYSTEM 0x160 // HID type CL +#define HID_CONSUMER_CHANNEL_LEFT 0x161 // HID type CL +#define HID_CONSUMER_CHANNEL_RIGHT 0x162 // HID type CL +#define HID_CONSUMER_CHANNEL_CENTER 0x163 // HID type CL +#define HID_CONSUMER_CHANNEL_FRONT 0x164 // HID type CL +#define HID_CONSUMER_CHANNEL_CENTER_FRONT 0x165 // HID type CL +#define HID_CONSUMER_CHANNEL_SIDE 0x166 // HID type CL +#define HID_CONSUMER_CHANNEL_SURROUND 0x167 // HID type CL +#define HID_CONSUMER_CHANNEL_LOW_FREQUENCY_ENHANCEMENT 0x168 // HID type CL +#define HID_CONSUMER_CHANNEL_TOP 0x169 // HID type CL +#define HID_CONSUMER_CHANNEL_UNKNOWN 0x16A // HID type CL +// Reserved 0x16B-16F +#define HID_CONSUMER_SUB-CHANNEL 0x170 // HID type LC +#define HID_CONSUMER_SUB-CHANNEL_INCREMENT 0x171 // HID type OSC +#define HID_CONSUMER_SUB-CHANNEL_DECREMENT 0x172 // HID type OSC +#define HID_CONSUMER_ALTERNATE_AUDIO_INCREMENT 0x173 // HID type OSC +#define HID_CONSUMER_ALTERNATE_AUDIO_DECREMENT 0x174 // HID type OSC +// Reserved 0x175-17F +#define HID_CONSUMER_APPLICATION_LAUNCH_BUTTONS 0x180 // HID type NARY +#define HID_CONSUMER_AL_LAUNCH_BUTTON_CONFIGURATION_TOOL 0x181 // HID type SEL +#define HID_CONSUMER_AL_PROGRAMMABLE_BUTTON_CONFIGURATION 0x182 // HID type SEL +#define HID_CONSUMER_AL_CONSUMER_CONTROL_CONFIGURATION 0x183 // HID type SEL +#define HID_CONSUMER_AL_WORD_PROCESSOR 0x184 // HID type SEL +#define HID_CONSUMER_AL_TEXT_EDITOR 0x185 // HID type SEL +#define HID_CONSUMER_AL_SPREADSHEET 0x186 // HID type SEL +#define HID_CONSUMER_AL_GRAPHICS_EDITOR 0x187 // HID type SEL +#define HID_CONSUMER_AL_PRESENTATION_APP 0x188 // HID type SEL +#define HID_CONSUMER_AL_DATABASE_APP 0x189 // HID type SEL +#define HID_CONSUMER_AL_EMAIL_READER 0x18A // HID type SEL +#define HID_CONSUMER_AL_NEWSREADER 0x18B // HID type SEL +#define HID_CONSUMER_AL_VOICEMAIL 0x18C // HID type SEL +#define HID_CONSUMER_AL_CONTACTS_SLASH_ADDRESS_BOOK 0x18D // HID type SEL +#define HID_CONSUMER_AL_CALENDAR_SLASH_SCHEDULE 0x18E // HID type SEL +#define HID_CONSUMER_AL_TASK_SLASH_PROJECT_MANAGER 0x18F // HID type SEL +#define HID_CONSUMER_AL_LOG_SLASH_JOURNAL_SLASH_TIMECARD 0x190 // HID type SEL +#define HID_CONSUMER_AL_CHECKBOOK_SLASH_FINANCE 0x191 // HID type SEL +#define HID_CONSUMER_AL_CALCULATOR 0x192 // HID type SEL +#define HID_CONSUMER_AL_A_SLASH_V_CAPTURE_SLASH_PLAYBACK 0x193 // HID type SEL +#define HID_CONSUMER_AL_LOCAL_MACHINE_BROWSER 0x194 // HID type SEL +#define HID_CONSUMER_AL_LAN_SLASH_WAN_BROWSER 0x195 // HID type SEL +#define HID_CONSUMER_AL_INTERNET_BROWSER 0x196 // HID type SEL +#define HID_CONSUMER_AL_REMOTE_NETWORKING_SLASH_ISP_CONNECT 0x197 // HID type SEL +#define HID_CONSUMER_AL_NETWORK_CONFERENCE 0x198 // HID type SEL +#define HID_CONSUMER_AL_NETWORK_CHAT 0x199 // HID type SEL +#define HID_CONSUMER_AL_TELEPHONY_SLASH_DIALER 0x19A // HID type SEL +#define HID_CONSUMER_AL_LOGON 0x19B // HID type SEL +#define HID_CONSUMER_AL_LOGOFF 0x19C // HID type SEL +#define HID_CONSUMER_AL_LOGON_SLASH_LOGOFF 0x19D // HID type SEL +#define HID_CONSUMER_AL_TERMINAL_LOCK_SLASH_SCREENSAVER 0x19E // HID type SEL +#define HID_CONSUMER_AL_CONTROL_PANEL 0x19F // HID type SEL +#define HID_CONSUMER_AL_COMMAND_LINE_PROCESSOR_SLASH_RUN 0x1A0 // HID type SEL +#define HID_CONSUMER_AL_PROCESS_SLASH_TASK_MANAGER 0x1A1 // HID type SEL +#define HID_CONSUMER_AL_SELECT_TASK_SLASH_APPLICATION 0x1A2 // HID type SEL +#define HID_CONSUMER_AL_NEXT_TASK_SLASH_APPLICATION 0x1A3 // HID type SEL +#define HID_CONSUMER_AL_PREVIOUS_TASK_SLASH_APPLICATION 0x1A4 // HID type SEL +#define HID_CONSUMER_AL_PREEMPTIVE_HALT_TASK_SLASH_APPLICATION 0x1A5 // HID type SEL +#define HID_CONSUMER_AL_INTEGRATED_HELP_CENTER 0x1A6 // HID type SEL +#define HID_CONSUMER_AL_DOCUMENTS 0x1A7 // HID type SEL +#define HID_CONSUMER_AL_THESAURUS 0x1A8 // HID type SEL +#define HID_CONSUMER_AL_DICTIONARY 0x1A9 // HID type SEL +#define HID_CONSUMER_AL_DESKTOP 0x1AA // HID type SEL +#define HID_CONSUMER_AL_SPELL_CHECK 0x1AB // HID type SEL +#define HID_CONSUMER_AL_GRAMMAR_CHECK 0x1AC // HID type SEL +#define HID_CONSUMER_AL_WIRELESS_STATUS 0x1AD // HID type SEL +#define HID_CONSUMER_AL_KEYBOARD_LAYOUT 0x1AE // HID type SEL +#define HID_CONSUMER_AL_VIRUS_PROTECTION 0x1AF // HID type SEL +#define HID_CONSUMER_AL_ENCRYPTION 0x1B0 // HID type SEL +#define HID_CONSUMER_AL_SCREEN_SAVER 0x1B1 // HID type SEL +#define HID_CONSUMER_AL_ALARMS 0x1B2 // HID type SEL +#define HID_CONSUMER_AL_CLOCK 0x1B3 // HID type SEL +#define HID_CONSUMER_AL_FILE_BROWSER 0x1B4 // HID type SEL +#define HID_CONSUMER_AL_POWER_STATUS 0x1B5 // HID type SEL +#define HID_CONSUMER_AL_IMAGE_BROWSER 0x1B6 // HID type SEL +#define HID_CONSUMER_AL_AUDIO_BROWSER 0x1B7 // HID type SEL +#define HID_CONSUMER_AL_MOVIE_BROWSER 0x1B8 // HID type SEL +#define HID_CONSUMER_AL_DIGITAL_RIGHTS_MANAGER 0x1B9 // HID type SEL +#define HID_CONSUMER_AL_DIGITAL_WALLET 0x1BA // HID type SEL +// _Reserved 0x1BB +#define HID_CONSUMER_AL_INSTANT_MESSAGING 0x1BC // HID type SEL +#define HID_CONSUMER_AL_OEM_FEATURES_SLASH__TIPS_SLASH_TUTORIAL_BROWSER 0x1BD // HID type SEL +#define HID_CONSUMER_AL_OEM_HELP 0x1BE // HID type SEL +#define HID_CONSUMER_AL_ONLINE_COMMUNITY 0x1BF // HID type SEL +#define HID_CONSUMER_AL_ENTERTAINMENT_CONTENT_BROWSER 0x1C0 // HID type SEL +#define HID_CONSUMER_AL_ONLINE_SHOPPING_BROWSER 0x1C1 // HID type SEL +#define HID_CONSUMER_AL_SMARTCARD_INFORMATION_SLASH_HELP 0x1C2 // HID type SEL +#define HID_CONSUMER_AL_MARKET_MONITOR_SLASH_FINANCE_BROWSER 0x1C3 // HID type SEL +#define HID_CONSUMER_AL_CUSTOMIZED_CORPORATE_NEWS_BROWSER 0x1C4 // HID type SEL +#define HID_CONSUMER_AL_ONLINE_ACTIVITY_BROWSER 0x1C5 // HID type SEL +#define HID_CONSUMER_AL_RESEARCH_SLASH_SEARCH_BROWSER 0x1C6 // HID type SEL +#define HID_CONSUMER_AL_AUDIO_PLAYER 0x1C7 // HID type SEL +// Reserved 0x1C8-1FF +#define HID_CONSUMER_GENERIC_GUI_APPLICATION_CONTROLS 0x200 // HID type NARY +#define HID_CONSUMER_AC_NEW 0x201 // HID type SEL +#define HID_CONSUMER_AC_OPEN 0x202 // HID type SEL +#define HID_CONSUMER_AC_CLOSE 0x203 // HID type SEL +#define HID_CONSUMER_AC_EXIT 0x204 // HID type SEL +#define HID_CONSUMER_AC_MAXIMIZE 0x205 // HID type SEL +#define HID_CONSUMER_AC_MINIMIZE 0x206 // HID type SEL +#define HID_CONSUMER_AC_SAVE 0x207 // HID type SEL +#define HID_CONSUMER_AC_PRINT 0x208 // HID type SEL +#define HID_CONSUMER_AC_PROPERTIES 0x209 // HID type SEL +#define HID_CONSUMER_AC_UNDO 0x21A // HID type SEL +#define HID_CONSUMER_AC_COPY 0x21B // HID type SEL +#define HID_CONSUMER_AC_CUT 0x21C // HID type SEL +#define HID_CONSUMER_AC_PASTE 0x21D // HID type SEL +#define HID_CONSUMER_AC_SELECT_ALL 0x21E // HID type SEL +#define HID_CONSUMER_AC_FIND 0x21F // HID type SEL +#define HID_CONSUMER_AC_FIND_AND_REPLACE 0x220 // HID type SEL +#define HID_CONSUMER_AC_SEARCH 0x221 // HID type SEL +#define HID_CONSUMER_AC_GO_TO 0x222 // HID type SEL +#define HID_CONSUMER_AC_HOME 0x223 // HID type SEL +#define HID_CONSUMER_AC_BACK 0x224 // HID type SEL +#define HID_CONSUMER_AC_FORWARD 0x225 // HID type SEL +#define HID_CONSUMER_AC_STOP 0x226 // HID type SEL +#define HID_CONSUMER_AC_REFRESH 0x227 // HID type SEL +#define HID_CONSUMER_AC_PREVIOUS_LINK 0x228 // HID type SEL +#define HID_CONSUMER_AC_NEXT_LINK 0x229 // HID type SEL +#define HID_CONSUMER_AC_BOOKMARKS 0x22A // HID type SEL +#define HID_CONSUMER_AC_HISTORY 0x22B // HID type SEL +#define HID_CONSUMER_AC_SUBSCRIPTIONS 0x22C // HID type SEL +#define HID_CONSUMER_AC_ZOOM_IN 0x22D // HID type SEL +#define HID_CONSUMER_AC_ZOOM_OUT 0x22E // HID type SEL +#define HID_CONSUMER_AC_ZOOM 0x22F // HID type LC +#define HID_CONSUMER_AC_FULL_SCREEN_VIEW 0x230 // HID type SEL +#define HID_CONSUMER_AC_NORMAL_VIEW 0x231 // HID type SEL +#define HID_CONSUMER_AC_VIEW_TOGGLE 0x232 // HID type SEL +#define HID_CONSUMER_AC_SCROLL_UP 0x233 // HID type SEL +#define HID_CONSUMER_AC_SCROLL_DOWN 0x234 // HID type SEL +#define HID_CONSUMER_AC_SCROLL 0x235 // HID type LC +#define HID_CONSUMER_AC_PAN_LEFT 0x236 // HID type SEL +#define HID_CONSUMER_AC_PAN_RIGHT 0x237 // HID type SEL +#define HID_CONSUMER_AC_PAN 0x238 // HID type LC +#define HID_CONSUMER_AC_NEW_WINDOW 0x239 // HID type SEL +#define HID_CONSUMER_AC_TILE_HORIZONTALLY 0x23A // HID type SEL +#define HID_CONSUMER_AC_TILE_VERTICALLY 0x23B // HID type SEL +#define HID_CONSUMER_AC_FORMAT 0x23C // HID type SEL +#define HID_CONSUMER_AC_EDIT 0x23D // HID type SEL +#define HID_CONSUMER_AC_BOLD 0x23E // HID type SEL +#define HID_CONSUMER_AC_ITALICS 0x23F // HID type SEL +#define HID_CONSUMER_AC_UNDERLINE 0x240 // HID type SEL +#define HID_CONSUMER_AC_STRIKETHROUGH 0x241 // HID type SEL +#define HID_CONSUMER_AC_SUBSCRIPT 0x242 // HID type SEL +#define HID_CONSUMER_AC_SUPERSCRIPT 0x243 // HID type SEL +#define HID_CONSUMER_AC_ALL_CAPS 0x244 // HID type SEL +#define HID_CONSUMER_AC_ROTATE 0x245 // HID type SEL +#define HID_CONSUMER_AC_RESIZE 0x246 // HID type SEL +#define HID_CONSUMER_AC_FLIP_HORIZONTAL 0x247 // HID type SEL +#define HID_CONSUMER_AC_FLIP_VERTICAL 0x248 // HID type SEL +#define HID_CONSUMER_AC_MIRROR_HORIZONTAL 0x249 // HID type SEL +#define HID_CONSUMER_AC_MIRROR_VERTICAL 0x24A // HID type SEL +#define HID_CONSUMER_AC_FONT_SELECT 0x24B // HID type SEL +#define HID_CONSUMER_AC_FONT_COLOR 0x24C // HID type SEL +#define HID_CONSUMER_AC_FONT_SIZE 0x24D // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_LEFT 0x24E // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_CENTER_H 0x24F // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_RIGHT 0x250 // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_BLOCK_H 0x251 // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_TOP 0x252 // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_CENTER_V 0x253 // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_BOTTOM 0x254 // HID type SEL +#define HID_CONSUMER_AC_JUSTIFY_BLOCK_V 0x255 // HID type SEL +#define HID_CONSUMER_AC_INDENT_DECREASE 0x256 // HID type SEL +#define HID_CONSUMER_AC_INDENT_INCREASE 0x257 // HID type SEL +#define HID_CONSUMER_AC_NUMBERED_LIST 0x258 // HID type SEL +#define HID_CONSUMER_AC_RESTART_NUMBERING 0x259 // HID type SEL +#define HID_CONSUMER_AC_BULLETED_LIST 0x25A // HID type SEL +#define HID_CONSUMER_AC_PROMOTE 0x25B // HID type SEL +#define HID_CONSUMER_AC_DEMOTE 0x25C // HID type SEL +#define HID_CONSUMER_AC_YES 0x25D // HID type SEL +#define HID_CONSUMER_AC_NO 0x25E // HID type SEL +#define HID_CONSUMER_AC_CANCEL 0x25F // HID type SEL +#define HID_CONSUMER_AC_CATALOG 0x260 // HID type SEL +#define HID_CONSUMER_AC_BUY_SLASH_CHECKOUT 0x261 // HID type SEL +#define HID_CONSUMER_AC_ADD_TO_CART 0x262 // HID type SEL +#define HID_CONSUMER_AC_EXPAND 0x263 // HID type SEL +#define HID_CONSUMER_AC_EXPAND_ALL 0x264 // HID type SEL +#define HID_CONSUMER_AC_COLLAPSE 0x265 // HID type SEL +#define HID_CONSUMER_AC_COLLAPSE_ALL 0x266 // HID type SEL +#define HID_CONSUMER_AC_PRINT_PREVIEW 0x267 // HID type SEL +#define HID_CONSUMER_AC_PASTE_SPECIAL 0x268 // HID type SEL +#define HID_CONSUMER_AC_INSERT_MODE 0x269 // HID type SEL +#define HID_CONSUMER_AC_DELETE 0x26A // HID type SEL +#define HID_CONSUMER_AC_LOCK 0x26B // HID type SEL +#define HID_CONSUMER_AC_UNLOCK 0x26C // HID type SEL +#define HID_CONSUMER_AC_PROTECT 0x26D // HID type SEL +#define HID_CONSUMER_AC_UNPROTECT 0x26E // HID type SEL +#define HID_CONSUMER_AC_ATTACH_COMMENT 0x26F // HID type SEL +#define HID_CONSUMER_AC_DELETE_COMMENT 0x270 // HID type SEL +#define HID_CONSUMER_AC_VIEW_COMMENT 0x271 // HID type SEL +#define HID_CONSUMER_AC_SELECT_WORD 0x272 // HID type SEL +#define HID_CONSUMER_AC_SELECT_SENTENCE 0x273 // HID type SEL +#define HID_CONSUMER_AC_SELECT_PARAGRAPH 0x274 // HID type SEL +#define HID_CONSUMER_AC_SELECT_COLUMN 0x275 // HID type SEL +#define HID_CONSUMER_AC_SELECT_ROW 0x276 // HID type SEL +#define HID_CONSUMER_AC_SELECT_TABLE 0x277 // HID type SEL +#define HID_CONSUMER_AC_SELECT_OBJECT 0x278 // HID type SEL +#define HID_CONSUMER_AC_REDO_SLASH_REPEAT 0x279 // HID type SEL +#define HID_CONSUMER_AC_SORT 0x27A // HID type SEL +#define HID_CONSUMER_AC_SORT_ASCENDING 0x27B // HID type SEL +#define HID_CONSUMER_AC_SORT_DESCENDING 0x27C // HID type SEL +#define HID_CONSUMER_AC_FILTER 0x27D // HID type SEL +#define HID_CONSUMER_AC_SET_CLOCK 0x27E // HID type SEL +#define HID_CONSUMER_AC_VIEW_CLOCK 0x27F // HID type SEL +#define HID_CONSUMER_AC_SELECT_TIME_ZONE 0x280 // HID type SEL +#define HID_CONSUMER_AC_EDIT_TIME_ZONES 0x281 // HID type SEL +#define HID_CONSUMER_AC_SET_ALARM 0x282 // HID type SEL +#define HID_CONSUMER_AC_CLEAR_ALARM 0x283 // HID type SEL +#define HID_CONSUMER_AC_SNOOZE_ALARM 0x284 // HID type SEL +#define HID_CONSUMER_AC_RESET_ALARM 0x285 // HID type SEL +#define HID_CONSUMER_AC_SYNCHRONIZE 0x286 // HID type SEL +#define HID_CONSUMER_AC_SEND_SLASH_RECEIVE 0x287 // HID type SEL +#define HID_CONSUMER_AC_SEND_TO 0x288 // HID type SEL +#define HID_CONSUMER_AC_REPLY 0x289 // HID type SEL +#define HID_CONSUMER_AC_REPLY_ALL 0x28A // HID type SEL +#define HID_CONSUMER_AC_FORWARD_MSG 0x28B // HID type SEL +#define HID_CONSUMER_AC_SEND 0x28C // HID type SEL +#define HID_CONSUMER_AC_ATTACH_FILE 0x28D // HID type SEL +#define HID_CONSUMER_AC_UPLOAD 0x28E // HID type SEL +#define HID_CONSUMER_AC_DOWNLOAD_(SAVE_TARGET_AS) 0x28F // HID type SEL +#define HID_CONSUMER_AC_SET_BORDERS 0x290 // HID type SEL +#define HID_CONSUMER_AC_INSERT_ROW 0x291 // HID type SEL +#define HID_CONSUMER_AC_INSERT_COLUMN 0x292 // HID type SEL +#define HID_CONSUMER_AC_INSERT_FILE 0x293 // HID type SEL +#define HID_CONSUMER_AC_INSERT_PICTURE 0x294 // HID type SEL +#define HID_CONSUMER_AC_INSERT_OBJECT 0x295 // HID type SEL +#define HID_CONSUMER_AC_INSERT_SYMBOL 0x296 // HID type SEL +#define HID_CONSUMER_AC_SAVE_AND_CLOSE 0x297 // HID type SEL +#define HID_CONSUMER_AC_RENAME 0x298 // HID type SEL +#define HID_CONSUMER_AC_MERGE 0x299 // HID type SEL +#define HID_CONSUMER_AC_SPLIT 0x29A // HID type SEL +#define HID_CONSUMER_AC_DISRIBUTE_HORIZONTALLY 0x29B // HID type SEL +#define HID_CONSUMER_AC_DISTRIBUTE_VERTICALLY 0x29C // HID type SEL + +#endif // __HIDTables__ \ No newline at end of file diff --git a/libraries/CompleteHID/examples/AbsoluteMouse/AbsoluteMouse.ino b/libraries/CompleteHID/examples/AbsoluteMouse/AbsoluteMouse.ino new file mode 100644 index 000000000..7eaafa1a4 --- /dev/null +++ b/libraries/CompleteHID/examples/AbsoluteMouse/AbsoluteMouse.ino @@ -0,0 +1,28 @@ +/* AbsoluteMouse.ino + + For ATmega32U4 based boards (like the Leonardo and Micro) + * This code is an API demo for the USB HID Absolute Mouse positioning API. + It does not require any circut external to your Arduino + Created 12 Jan 2014 + by Jesse Vincent + This sample code is in the public domain. +*/ + + +void setup() { + Mouse.begin(); +} + +void loop() { + + Mouse.moveAbsolute(16384,16384); // Jump to the center of the screen + delay(2500); + Mouse.moveAbsolute(0, 0); // X position, Y position + delay(2500); + Mouse.moveAbsolute(0, 32767); + delay(2500); + Mouse.moveAbsolute(32767, 32767); + delay(2500); + Mouse.moveAbsolute(32767,0); + delay(2500); +} diff --git a/libraries/CompleteHID/examples/ConsumerAndSystemControl/ConsumerAndSystemControl.ino b/libraries/CompleteHID/examples/ConsumerAndSystemControl/ConsumerAndSystemControl.ino new file mode 100644 index 000000000..8ea259ff9 --- /dev/null +++ b/libraries/CompleteHID/examples/ConsumerAndSystemControl/ConsumerAndSystemControl.ino @@ -0,0 +1,47 @@ +/* ConsumerAndSystemControl.ino + Turns the computer's volume up, then turns it down. + + For ATmega32U4 based boards (like the Leonardo and Micro) + * This code is an API demo for the USB HID ConsumerControl and + SystemControl APIS. + It does not require any circut external to your Arduino + Created 12 Jan 2014 + by Jesse Vincent + This sample code is in the public domain. +*/ + + +void setup() { + Keyboard.begin(); + + // It can take a moment for the USB interface to be ready + // after setup. Delay for a second so we don't lose the first + // keypress. + delay(1000); +} + +void loop() { + + Keyboard.consumerControl(CONSUMER_CONTROL_VOLUME_UP); + delay(1000); + Keyboard.consumerControl(CONSUMER_CONTROL_VOLUME_DOWN); + delay(1000); + + + // Some other things the consumer control API can do: + + // Keyboard.consumerControl(CONSUMER_CONTROL_VOLUME_MUTE); + // Keyboard.consumerControl(CONSUMER_CONTROL_PLAY_PAUSE); + // Keyboard.consumerControl(CONSUMER_CONTROL_STOP); + // Keyboard.consumerControl(CONSUMER_CONTROL_PREV_TRACK); + // Keyboard.consumerControl(CONSUMER_CONTROL_NEXT_TRACK); + + + // If you uncomment this code, the Arduino will try to put your + // computer to sleep after waiting for 30 seconds. + // delay(30000); Keyboard.systemControl(SYSTEM_CONTROL_SLEEP); + + // For a complete list, of the currently supported ConsumerControl + // and SystemControl usages, look in cores/arduino/USBAPI.h + +} \ No newline at end of file