From d7b654b590b642f507a3c041baa7c40e8654ae3d Mon Sep 17 00:00:00 2001 From: Kenneth Newwood Date: Wed, 8 Jan 2014 13:39:35 -0500 Subject: [PATCH 01/27] Break out the size of a USB keyboard HID packet into a macro. Originally from https://github.com/arduino/Arduino/pull/1391 --- hardware/arduino/avr/cores/arduino/USBAPI.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 2fab957f930..c7b717463ad 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -160,11 +160,12 @@ extern Mouse_ Mouse; #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[6]; + uint8_t keys[KEYREPORT_KEYCOUNT]; } KeyReport; class Keyboard_ : public Print From f27857d2b7d76aec0fa49ac93c7ba3799e88f56e Mon Sep 17 00:00:00 2001 From: Michael Dreher Date: Wed, 8 Jan 2014 13:50:00 -0500 Subject: [PATCH 02/27] A comment on an endif pointed to the wrong if From https://github.com/arduino/Arduino/pull/1488 --- hardware/arduino/avr/cores/arduino/USBAPI.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index c7b717463ad..1f1dccd74fc 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -240,6 +240,7 @@ 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) */ + +#endif From 60e6c3429386462ec6c35c87ed5e0d74af800487 Mon Sep 17 00:00:00 2001 From: Michael Dreher Date: Wed, 8 Jan 2014 13:55:41 -0500 Subject: [PATCH 03/27] Use defines to identify the USB HID pages we support, instead of integers --- hardware/arduino/avr/cores/arduino/HID.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 75c37b24b2f..d6aa8fd2a6b 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -41,6 +41,9 @@ Keyboard_ Keyboard; #define RAWHID_TX_SIZE 64 #define RAWHID_RX_SIZE 64 +#define HID_REPORTID_MOUSE (1) +#define HID_REPORTID_KEYBOARD (2) +#define HID_REPORTID_RAWHID (3) extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { @@ -50,7 +53,7 @@ const u8 _hidReportDescriptor[] = { 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) - 0x85, 0x01, // REPORT_ID (1) + 0x85, HID_REPORTID_MOUSE, // REPORT_ID (1) 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x03, // USAGE_MAXIMUM (Button 3) @@ -78,7 +81,7 @@ const u8 _hidReportDescriptor[] = { 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47 0x09, 0x06, // USAGE (Keyboard) 0xa1, 0x01, // COLLECTION (Application) - 0x85, 0x02, // REPORT_ID (2) + 0x85, HID_REPORTID_KEYBOARD, // REPORT_ID (2) 0x05, 0x07, // USAGE_PAGE (Keyboard) 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) @@ -110,7 +113,7 @@ const u8 _hidReportDescriptor[] = { 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE), 0xA1, 0x01, // Collection 0x01 - 0x85, 0x03, // REPORT_ID (3) + 0x85, HID_REPORTID_RAWHID, // REPORT_ID (3) 0x75, 0x08, // report size = 8 bits 0x15, 0x00, // logical minimum = 0 0x26, 0xFF, 0x00, // logical maximum = 255 @@ -226,7 +229,7 @@ void Mouse_::move(signed char x, signed char y, signed char wheel) m[1] = x; m[2] = y; m[3] = wheel; - HID_SendReport(1,m,4); + HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m)); } void Mouse_::buttons(uint8_t b) @@ -273,7 +276,7 @@ void Keyboard_::end(void) void Keyboard_::sendReport(KeyReport* keys) { - HID_SendReport(2,keys,sizeof(KeyReport)); + HID_SendReport(HID_REPORTID_KEYBOARD,keys,sizeof(*keys)); } extern From 4388bed67d5ae37e23ac10f8d38bddbfaf0af002 Mon Sep 17 00:00:00 2001 From: Michael Dreher Date: Wed, 8 Jan 2014 14:04:29 -0500 Subject: [PATCH 04/27] Add support for the USB HID SystemControl page --- hardware/arduino/avr/cores/arduino/HID.cpp | 66 ++++++++++++++++++++- hardware/arduino/avr/cores/arduino/USBAPI.h | 25 ++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index d6aa8fd2a6b..06c8847b049 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -44,6 +44,8 @@ Keyboard_ Keyboard; #define HID_REPORTID_MOUSE (1) #define HID_REPORTID_KEYBOARD (2) #define HID_REPORTID_RAWHID (3) +#define HID_REPORTID_SYSTEMCONTROL (4) + extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { @@ -107,7 +109,37 @@ const u8 _hidReportDescriptor[] = { 0x81, 0x00, // INPUT (Data,Ary,Abs) 0xc0, // END_COLLECTION -#ifdef RAWHID_ENABLED + // 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 (4) + 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 + +#if RAWHID_ENABLED // RAW HID 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE), @@ -463,6 +495,38 @@ size_t Keyboard_::press(uint8_t 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; + } +} + // 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. diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 1f1dccd74fc..673ca292339 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -159,6 +159,30 @@ extern Mouse_ Mouse; #define KEY_F11 0xCC #define KEY_F12 0xCD + +// 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 + // Low level key report: up to 6 keys and shift, ctrl etc at once #define KEYREPORT_KEYCOUNT 0x06 typedef struct @@ -181,6 +205,7 @@ class Keyboard_ : public Print virtual size_t press(uint8_t k); virtual size_t release(uint8_t k); virtual void releaseAll(void); + virtual size_t systemControl(uint8_t k); }; extern Keyboard_ Keyboard; From fbcf94801b8bba7f1c8c79cc7ae402b6b9dbb2d3 Mon Sep 17 00:00:00 2001 From: Michael Dreher Date: Wed, 8 Jan 2014 14:10:06 -0500 Subject: [PATCH 05/27] Add support for waking up a host via USB HID. This functionality originated in pull request: https://github.com/arduino/Arduino/pull/1488/ Jesse can attest to the functionality (tested on OS X 10.8, 10.9, and Windows 7 but doesn't have the background to verify the implementation --- hardware/arduino/avr/cores/arduino/HID.cpp | 2 + hardware/arduino/avr/cores/arduino/USBAPI.h | 1 + .../arduino/avr/cores/arduino/USBCore.cpp | 179 +++++++++++++++--- hardware/arduino/avr/cores/arduino/USBCore.h | 11 +- 4 files changed, 163 insertions(+), 30 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 06c8847b049..963228ff61d 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -2,6 +2,8 @@ /* Copyright (c) 2011, Peter Barrett ** +** Sleep/Wakeup/SystemControl support added by Michael Dreher +** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 673ca292339..4d35b6ec730 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -50,6 +50,7 @@ class USBDevice_ void attach(); void detach(); // Serial port goes down too... void poll(); + bool wakeupHost(); // returns false, when wakeup cannot be processed }; extern USBDevice_ USBDevice; diff --git a/hardware/arduino/avr/cores/arduino/USBCore.cpp b/hardware/arduino/avr/cores/arduino/USBCore.cpp index b4f7bed7e86..ab845127802 100644 --- a/hardware/arduino/avr/cores/arduino/USBCore.cpp +++ b/hardware/arduino/avr/cores/arduino/USBCore.cpp @@ -2,6 +2,8 @@ /* Copyright (c) 2010, Peter Barrett ** +** Sleep/Wakeup/SystemControl support added by Michael Dreher +** ** Permission to use, copy, modify, and/or distribute this software for ** any purpose with or without fee is hereby granted, provided that the ** above copyright notice and this permission notice appear in all copies. @@ -20,13 +22,13 @@ #if defined(USBCON) -#define EP_TYPE_CONTROL 0x00 -#define EP_TYPE_BULK_IN 0x81 -#define EP_TYPE_BULK_OUT 0x80 -#define EP_TYPE_INTERRUPT_IN 0xC1 -#define EP_TYPE_INTERRUPT_OUT 0xC0 -#define EP_TYPE_ISOCHRONOUS_IN 0x41 -#define EP_TYPE_ISOCHRONOUS_OUT 0x40 +#define EP_TYPE_CONTROL (0x00) +#define EP_TYPE_BULK_IN ((1< Date: Wed, 8 Jan 2014 14:15:34 -0500 Subject: [PATCH 06/27] Updates to the keyboard usage page for HID to extend the range of available keys & add comments Originally from https://github.com/arduino/Arduino/pull/1488/ --- hardware/arduino/avr/cores/arduino/HID.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 963228ff61d..c4686a19dab 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -88,7 +88,8 @@ const u8 _hidReportDescriptor[] = { 0x85, HID_REPORTID_KEYBOARD, // REPORT_ID (2) 0x05, 0x07, // USAGE_PAGE (Keyboard) - 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) + // 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) @@ -99,15 +100,15 @@ const u8 _hidReportDescriptor[] = { 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x03, // INPUT (Cnst,Var,Abs) - - 0x95, 0x06, // REPORT_COUNT (6) + + // Keyboard keys + 0x95, 0x06, // REPORT_COUNT (6) 0x75, 0x08, // REPORT_SIZE (8) 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0x65, // LOGICAL_MAXIMUM (101) + 0x26, 0xDF, 0x00, // LOGICAL_MAXIMUM (239) 0x05, 0x07, // USAGE_PAGE (Keyboard) - - 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) - 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) + 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) + 0x29, 0xDF, // USAGE_MAXIMUM (Left Control - 1) 0x81, 0x00, // INPUT (Data,Ary,Abs) 0xc0, // END_COLLECTION From 387d55b4c1c8f3c850d92367260f5ab7f81641c4 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 9 Jan 2014 18:32:06 -0500 Subject: [PATCH 07/27] Add an inital pass at complete HID tables for Keyboard, ConsumerControl and SystemControl --- .../arduino/avr/cores/arduino/HIDTables.h | 677 ++++++++++++++++++ 1 file changed, 677 insertions(+) create mode 100644 hardware/arduino/avr/cores/arduino/HIDTables.h diff --git a/hardware/arduino/avr/cores/arduino/HIDTables.h b/hardware/arduino/avr/cores/arduino/HIDTables.h new file mode 100644 index 00000000000..8092e1fbf83 --- /dev/null +++ b/hardware/arduino/avr/cores/arduino/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__ From a520873aba7f2c99eda6c9b1979df170939d9f68 Mon Sep 17 00:00:00 2001 From: Michael Dreher Date: Sat, 11 Jan 2014 17:40:50 -0500 Subject: [PATCH 08/27] Addeed Mouse.moveAbs() to USB HID for absolute mouse positioning. as requested in issue #1417. All parameters have the range of -32768 to 32767 and must be scaled to screen pixels some examples: x=0, y=0 is the middle of the screen x=-32768, y=-32768 is the top left corner x=32767, y=-32768 is the top right corner x=32767, y=32767 is the bottom right corner x=-32768, y=32767 is the bottom left corner. Based on commit 7b77d1e84d7b80819f049e5fd6e7bafa0d06521f from https://github.com/arduino/Arduino/pull/1488 Code slightly massaged by Jesse Vincent to remove overzealous #ifdefs --- hardware/arduino/avr/cores/arduino/HID.cpp | 59 +++++++++++++++++++-- hardware/arduino/avr/cores/arduino/USBAPI.h | 1 + 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index c4686a19dab..9c0c5ed2628 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -22,7 +22,7 @@ #if defined(USBCON) #ifdef HID_ENABLED - +//#define MOUSE_ABS_ENABLED //#define RAWHID_ENABLED // Singletons for mouse and keyboard @@ -47,11 +47,12 @@ Keyboard_ Keyboard; #define HID_REPORTID_KEYBOARD (2) #define HID_REPORTID_RAWHID (3) #define HID_REPORTID_SYSTEMCONTROL (4) +#define HID_REPORTID_MOUSE_ABS (5) extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { - // Mouse + // Mouse relative 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x01, // COLLECTION (Application) @@ -81,7 +82,39 @@ const u8 _hidReportDescriptor[] = { 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION - // Keyboard +#ifdef HID_MOUSE_ABS_ENABLED + // 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 (5) + 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) + 0x09, 0x38, // USAGE (Wheel) + 0x16, 0x00, 0x80, // LOGICAL_MINIMUM (-32768) + 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767) + 0x75, 0x10, // REPORT_SIZE (16) + 0x95, 0x03, // REPORT_COUNT (3) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0xc0, // END_COLLECTION + 0xc0, // END_COLLECTION +#endif + + // Keyboard 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47 0x09, 0x06, // USAGE (Keyboard) 0xa1, 0x01, // COLLECTION (Application) @@ -267,6 +300,26 @@ void Mouse_::move(signed char x, signed char y, signed char wheel) HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m)); } +// all parameters have the range of -32768 to 32767 and must be scaled to screen pixels +// some examples: +// x=0,y=0 is the middle of the screen +// x=-32768,y=-32768 is the top left corner +// x=32767,y=-32768 is the top right corner +// x=32767,y=32767 is the bottom right corner +// x=-32768,y=32767 is the bottom left corner +void Mouse_::moveAbs(int16_t x, int16_t y, int16_t wheel) +{ + u8 m[7]; + m[0] = _buttons; // TODO: is it a good idea to take over the _buttons from relative report here or should it be left out? + m[1] = LSB(x); + m[2] = MSB(x); + m[3] = LSB(y); + m[4] = MSB(y); + m[5] = LSB(wheel); + m[6] = MSB(wheel); + HID_SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m)); +} + void Mouse_::buttons(uint8_t b) { if (b != _buttons) diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 4d35b6ec730..d068ebb5b37 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -113,6 +113,7 @@ class Mouse_ void end(void); void click(uint8_t b = MOUSE_LEFT); void move(signed char x, signed char y, signed char wheel = 0); + void moveAbs(int16_t x, int16_t y, int16_t wheel); // all parameters have the range of -32768 to 32767 and must be scaled to screen pixels 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 From 648d59693f7b7520916d756609bfbb6366fbe6bf Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 11 Jan 2014 17:59:56 -0500 Subject: [PATCH 09/27] A first cut of USB "Consumer Control" support --- hardware/arduino/avr/cores/arduino/HID.cpp | 53 +++++++++++++++++++++ hardware/arduino/avr/cores/arduino/USBAPI.h | 20 ++++++++ 2 files changed, 73 insertions(+) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 9c0c5ed2628..dec781d2a87 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -48,6 +48,7 @@ Keyboard_ Keyboard; #define HID_REPORTID_RAWHID (3) #define HID_REPORTID_SYSTEMCONTROL (4) #define HID_REPORTID_MOUSE_ABS (5) +#define HID_REPORTID_CONSUMERCONTROL (6) extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { @@ -195,6 +196,25 @@ const u8 _hidReportDescriptor[] = { 0x91, 0x02, // Output (array) 0xC0 // end collection #endif + 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) + 0x09, 0x01, // USAGE (Consumer Control) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, HID_REPORTID_CONSUMERCONTROL, // REPORT_ID (6) + 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 + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x0f, // REPORT_COUNT (8) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0xc0, + }; extern const HIDDescriptor _hidInterface PROGMEM; @@ -583,6 +603,39 @@ size_t Keyboard_::systemControl(uint8_t k) } } +// 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; + } +} + + // 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. diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index d068ebb5b37..84d74af8ba7 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -185,6 +185,25 @@ extern Mouse_ Mouse; #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 + + // Low level key report: up to 6 keys and shift, ctrl etc at once #define KEYREPORT_KEYCOUNT 0x06 typedef struct @@ -208,6 +227,7 @@ class Keyboard_ : public Print virtual size_t release(uint8_t k); virtual void releaseAll(void); virtual size_t systemControl(uint8_t k); + virtual size_t consumerControl(uint8_t k); }; extern Keyboard_ Keyboard; From 9a601863d3782446cca3616f9b0550979cdc00ef Mon Sep 17 00:00:00 2001 From: Kenneth Newwood Date: Sun, 12 Jan 2014 16:04:02 -0500 Subject: [PATCH 10/27] Add USB HID keyboard press and release variants that work with USB HID Keyboard Keycodes. This makes it possible to send HID key events for keys that don't appear on a traditional US 104 key keyboard. This patch is a somewhat rototilled version of the patch linked below. In particular, i dropped whitespacechanges from the original patch and changed 0x01 and 0x00 in the code to 1 and 0 to better match the style of the surrounding code. Based on patch https://github.com/weizenspreu/Arduino/commit/1ede2b8abd7c3b74ffc75f28da38b4acdc4817f2.patch from Pull request 1391. --- hardware/arduino/avr/cores/arduino/HID.cpp | 216 ++++++++++++++------ hardware/arduino/avr/cores/arduino/USBAPI.h | 95 ++++++++- 2 files changed, 243 insertions(+), 68 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index dec781d2a87..1a02fbefff7 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -526,51 +526,85 @@ const uint8_t _asciimap[128] = uint8_t USBPutChar(uint8_t c); -// 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 - _keyReport.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 - _keyReport.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 (_keyReport.keys[0] != k && _keyReport.keys[1] != k && - _keyReport.keys[2] != k && _keyReport.keys[3] != k && - _keyReport.keys[4] != k && _keyReport.keys[5] != k) { - - for (i=0; i<6; i++) { - if (_keyReport.keys[i] == 0x00) { - _keyReport.keys[i] = k; - break; - } - } - if (i == 6) { - setWriteError(); - return 0; - } - } - sendReport(&_keyReport); - return 1; -} + // 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. + // When send is set to FALSE (= 0x00) no sendReport() is executed. This comes in + // handy when combining key presses (e.g. SHIFT+A). + size_t Keyboard_::pressKeycode(uint8_t k, uint8_t send) + { + uint8_t index = 0; + uint8_t done = 0; + + if ((k >= KEYCODE_LEFT_CTRL) && (k <= KEYCODE_RIGHT_GUI)) { + // it's a modifier key + _keyReport.modifiers |= (0x01 << (k - KEYCODE_LEFT_CTRL)); + } 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; + } + } + + if (0 != send) { + sendReport(&_keyReport); + } + 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 + KEYCODE_LEFT_CTRL; + } 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 + pressKeycode(KEYCODE_LEFT_SHIFT, 0); + k = k ^ SHIFT; + } + } else { + return 0; + } + } + } + + pressKeycode(k, 1); + 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) @@ -635,38 +669,86 @@ size_t Keyboard_::consumerControl(uint8_t k) } } - -// release() takes the specified key out of the persistent key report and +// 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. -size_t Keyboard_::release(uint8_t k) +// 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, uint8_t send) { - 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 - _keyReport.modifiers &= ~(1<<(k-128)); - k = 0; - } else { // it's a printing key - k = pgm_read_byte(_asciimap + k); - if (!k) { - return 0; + uint8_t indexA; + uint8_t indexB; + uint8_t count; + + if ((k >= KEYCODE_LEFT_CTRL) && (k <= KEYCODE_RIGHT_GUI)) { + // it's a modifier key + _keyReport.modifiers = _keyReport.modifiers & (~(0x01 << (k - KEYCODE_LEFT_CTRL))); + } 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; + } } - if (k & 0x80) { // it's a capital letter or other character reached with shift - _keyReport.modifiers &= ~(0x02); // the left shift modifier - k &= 0x7F; + + // 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 + } } + } + + if (send) { + sendReport(&_keyReport); } + 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; - // 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 && _keyReport.keys[i] == k) { - _keyReport.keys[i] = 0x00; + 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 + KEYCODE_LEFT_CTRL; + } 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 + releaseKeycode(KEYCODE_LEFT_SHIFT, 0); + k = k ^ SHIFT; + } + } else { + return 0; + } } } - - sendReport(&_keyReport); + + releaseKeycode(k, 1); return 1; } diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 84d74af8ba7..318664d2516 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -124,6 +124,98 @@ extern Mouse_ Mouse; //================================================================================ // Keyboard +// USB HID based keycodes +// as taken from: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf +#define KEYCODE_LEFT_CTRL 0xE0 +#define KEYCODE_LEFT_SHIFT 0xE1 +#define KEYCODE_LEFT_ALT 0xE2 +#define KEYCODE_LEFT_GUI 0xE3 +#define KEYCODE_RIGHT_CTRL 0xE4 +#define KEYCODE_RIGHT_SHIFT 0xE5 +#define KEYCODE_RIGHT_ALT 0xE6 +#define KEYCODE_RIGHT_GUI 0xE7 + +#define KEYCODE_UP_ARROW 0x52 +#define KEYCODE_DOWN_ARROW 0x51 +#define KEYCODE_LEFT_ARROW 0x50 +#define KEYCODE_RIGHT_ARROW 0x4F +#define KEYCODE_BACKSPACE 0x2A +#define KEYCODE_TAB 0x2B +#define KEYCODE_RETURN 0x28 +#define KEYCODE_ESC 0x29 +#define KEYCODE_INSERT 0x49 +#define KEYCODE_DELETE 0xD4 +#define KEYCODE_PAGE_UP 0x4B +#define KEYCODE_PAGE_DOWN 0x4E +#define KEYCODE_HOME 0x4A +#define KEYCODE_END 0x4D +#define KEYCODE_CAPS_LOCK 0x39 +#define KEYCODE_F1 0x3A +#define KEYCODE_F2 0x3B +#define KEYCODE_F3 0x3C +#define KEYCODE_F4 0x3D +#define KEYCODE_F5 0x3E +#define KEYCODE_F6 0x3F +#define KEYCODE_F7 0x40 +#define KEYCODE_F8 0x41 +#define KEYCODE_F9 0x42 +#define KEYCODE_F10 0x43 +#define KEYCODE_F11 0x44 +#define KEYCODE_F12 0x45 + +#define KEYCODE_ENTER KEYCODE_RETURN +#define KEYCODE_SPACEBAR 0x2C +#define KEYCODE_PRINT_SCREEN 0x46 +#define KEYCODE_SCROLL_LOCK 0x47 +#define KEYCODE_PAUSE 0x48 +#define KEYCODE_KEYPAD_NUM_LOCK 0x53 +#define KEYCODE_KEYPAD_RETURN 0x58 +#define KEYCODE_KEYPAD_ENTER KEYCODE_KEYPAD_RETURN +#define KEYCODE_KEYPAD_END 0x59 +#define KEYCODE_KEYPAD_DOWN_ARROW 0x5A +#define KEYCODE_KEYPAD_PAGE_DOWN 0x5B +#define KEYCODE_KEYPAD_LEFT_ARROW 0x5C +#define KEYCODE_KEYPAD_RIGHT_ARROW 0x5E +#define KEYCODE_KEYPAD_HOME 0x5F +#define KEYCODE_KEYPAD_UP_ARROW 0x60 +#define KEYCODE_KEYPAD_PAGE_UP 0x61 +#define KEYCODE_KEYPAD_INSERT 0x62 +#define KEYCODE_KEYPAD_DELETE 0x63 +#define KEYCODE_APPLICATION 0x65 +#define KEYCODE_POWER 0x66 +#define KEYCODE_F13 0x68 +#define KEYCODE_F14 0x69 +#define KEYCODE_F15 0x6A +#define KEYCODE_F16 0x6B +#define KEYCODE_F17 0x6C +#define KEYCODE_F18 0x6D +#define KEYCODE_F19 0x6E +#define KEYCODE_F20 0x6F +#define KEYCODE_F21 0x70 +#define KEYCODE_F22 0x71 +#define KEYCODE_F23 0x72 +#define KEYCODE_F24 0x73 +#define KEYCODE_EXECUTE 0x74 +#define KEYCODE_HELP 0x75 +#define KEYCODE_MENU 0x76 +#define KEYCODE_SELECT 0x77 +#define KEYCODE_STOP 0x78 +#define KEYCODE_AGAIN 0x79 +#define KEYCODE_UNDO 0x7A +#define KEYCODE_CUT 0x7B +#define KEYCODE_COPY 0x7C +#define KEYCODE_PASTE 0x7D +#define KEYCODE_FIND 0x7E +#define KEYCODE_MUTE 0x7F +#define KEYCODE_VOLUME_UP 0x80 +#define KEYCODE_VOLUME_DOWN 0x81 +#define KEYCODE_CANCEL 0x9B +#define KEYCODE_CLEAR 0x9C +#define KEYCODE_PRIOR 0x9D +#define KEYCODE_KEYPAD_TAB 0xBA +#define KEYCODE_KEYPAD_BACKSPACE 0xBB + +// Legacy keycodes. These are what you use with 'press()' and 'release()' #define KEY_LEFT_CTRL 0x80 #define KEY_LEFT_SHIFT 0x81 #define KEY_LEFT_ALT 0x82 @@ -203,7 +295,6 @@ extern Mouse_ Mouse; #define CONSUMER_CONTROL_NEXT_TRACK 7 #define CONSUMER_CONTROL_EJECT 8 - // Low level key report: up to 6 keys and shift, ctrl etc at once #define KEYREPORT_KEYCOUNT 0x06 typedef struct @@ -225,6 +316,8 @@ class Keyboard_ : public Print virtual size_t write(uint8_t k); virtual size_t press(uint8_t k); virtual size_t release(uint8_t k); + virtual size_t pressKeycode(uint8_t k, uint8_t send); + virtual size_t releaseKeycode(uint8_t k, uint8_t send); virtual void releaseAll(void); virtual size_t systemControl(uint8_t k); virtual size_t consumerControl(uint8_t k); From c5efe1e5d092945745a507321d1c94b0ee6b2775 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 1 Dec 2014 13:31:14 -0500 Subject: [PATCH 11/27] Switch to less confusingly named HID keyboard character defines. Additionally, move to a complete list of all keyboard and keypad keycodes transcribed from the HID specification. --- hardware/arduino/avr/cores/arduino/HID.cpp | 18 ++-- hardware/arduino/avr/cores/arduino/USBAPI.h | 91 --------------------- 2 files changed, 10 insertions(+), 99 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 1a02fbefff7..41d4161b668 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -19,6 +19,8 @@ */ #include "USBAPI.h" +#include "USBDesc.h" +#include "HIDTables.h" #if defined(USBCON) #ifdef HID_ENABLED @@ -538,9 +540,9 @@ uint8_t USBPutChar(uint8_t c); uint8_t index = 0; uint8_t done = 0; - if ((k >= KEYCODE_LEFT_CTRL) && (k <= KEYCODE_RIGHT_GUI)) { + if ((k >= HID_KEYBOARD_LEFT_CONTROL) && (k <= HID_KEYBOARD_RIGHT_GUI)) { // it's a modifier key - _keyReport.modifiers |= (0x01 << (k - KEYCODE_LEFT_CTRL)); + _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 @@ -585,14 +587,14 @@ uint8_t USBPutChar(uint8_t c); } else { if (k >= KEY_LEFT_CTRL) { // it's a modifier key - k = k - KEY_LEFT_CTRL + KEYCODE_LEFT_CTRL; + 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 - pressKeycode(KEYCODE_LEFT_SHIFT, 0); + pressKeycode(HID_KEYBOARD_LEFT_SHIFT, 0); k = k ^ SHIFT; } } else { @@ -680,9 +682,9 @@ size_t Keyboard_::releaseKeycode(uint8_t k, uint8_t send) uint8_t indexB; uint8_t count; - if ((k >= KEYCODE_LEFT_CTRL) && (k <= KEYCODE_RIGHT_GUI)) { + if ((k >= HID_KEYBOARD_LEFT_CONTROL) && (k <= HID_KEYBOARD_RIGHT_GUI)) { // it's a modifier key - _keyReport.modifiers = _keyReport.modifiers & (~(0x01 << (k - KEYCODE_LEFT_CTRL))); + _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. @@ -732,14 +734,14 @@ size_t Keyboard_::release(uint8_t k) } else { if (k >= KEY_LEFT_CTRL) { // it's a modifier key - k = k - KEY_LEFT_CTRL + KEYCODE_LEFT_CTRL; + 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 - releaseKeycode(KEYCODE_LEFT_SHIFT, 0); + releaseKeycode(HID_KEYBOARD_LEFT_SHIFT, 0); k = k ^ SHIFT; } } else { diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 318664d2516..fb25c2760b9 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -124,97 +124,6 @@ extern Mouse_ Mouse; //================================================================================ // Keyboard -// USB HID based keycodes -// as taken from: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf -#define KEYCODE_LEFT_CTRL 0xE0 -#define KEYCODE_LEFT_SHIFT 0xE1 -#define KEYCODE_LEFT_ALT 0xE2 -#define KEYCODE_LEFT_GUI 0xE3 -#define KEYCODE_RIGHT_CTRL 0xE4 -#define KEYCODE_RIGHT_SHIFT 0xE5 -#define KEYCODE_RIGHT_ALT 0xE6 -#define KEYCODE_RIGHT_GUI 0xE7 - -#define KEYCODE_UP_ARROW 0x52 -#define KEYCODE_DOWN_ARROW 0x51 -#define KEYCODE_LEFT_ARROW 0x50 -#define KEYCODE_RIGHT_ARROW 0x4F -#define KEYCODE_BACKSPACE 0x2A -#define KEYCODE_TAB 0x2B -#define KEYCODE_RETURN 0x28 -#define KEYCODE_ESC 0x29 -#define KEYCODE_INSERT 0x49 -#define KEYCODE_DELETE 0xD4 -#define KEYCODE_PAGE_UP 0x4B -#define KEYCODE_PAGE_DOWN 0x4E -#define KEYCODE_HOME 0x4A -#define KEYCODE_END 0x4D -#define KEYCODE_CAPS_LOCK 0x39 -#define KEYCODE_F1 0x3A -#define KEYCODE_F2 0x3B -#define KEYCODE_F3 0x3C -#define KEYCODE_F4 0x3D -#define KEYCODE_F5 0x3E -#define KEYCODE_F6 0x3F -#define KEYCODE_F7 0x40 -#define KEYCODE_F8 0x41 -#define KEYCODE_F9 0x42 -#define KEYCODE_F10 0x43 -#define KEYCODE_F11 0x44 -#define KEYCODE_F12 0x45 - -#define KEYCODE_ENTER KEYCODE_RETURN -#define KEYCODE_SPACEBAR 0x2C -#define KEYCODE_PRINT_SCREEN 0x46 -#define KEYCODE_SCROLL_LOCK 0x47 -#define KEYCODE_PAUSE 0x48 -#define KEYCODE_KEYPAD_NUM_LOCK 0x53 -#define KEYCODE_KEYPAD_RETURN 0x58 -#define KEYCODE_KEYPAD_ENTER KEYCODE_KEYPAD_RETURN -#define KEYCODE_KEYPAD_END 0x59 -#define KEYCODE_KEYPAD_DOWN_ARROW 0x5A -#define KEYCODE_KEYPAD_PAGE_DOWN 0x5B -#define KEYCODE_KEYPAD_LEFT_ARROW 0x5C -#define KEYCODE_KEYPAD_RIGHT_ARROW 0x5E -#define KEYCODE_KEYPAD_HOME 0x5F -#define KEYCODE_KEYPAD_UP_ARROW 0x60 -#define KEYCODE_KEYPAD_PAGE_UP 0x61 -#define KEYCODE_KEYPAD_INSERT 0x62 -#define KEYCODE_KEYPAD_DELETE 0x63 -#define KEYCODE_APPLICATION 0x65 -#define KEYCODE_POWER 0x66 -#define KEYCODE_F13 0x68 -#define KEYCODE_F14 0x69 -#define KEYCODE_F15 0x6A -#define KEYCODE_F16 0x6B -#define KEYCODE_F17 0x6C -#define KEYCODE_F18 0x6D -#define KEYCODE_F19 0x6E -#define KEYCODE_F20 0x6F -#define KEYCODE_F21 0x70 -#define KEYCODE_F22 0x71 -#define KEYCODE_F23 0x72 -#define KEYCODE_F24 0x73 -#define KEYCODE_EXECUTE 0x74 -#define KEYCODE_HELP 0x75 -#define KEYCODE_MENU 0x76 -#define KEYCODE_SELECT 0x77 -#define KEYCODE_STOP 0x78 -#define KEYCODE_AGAIN 0x79 -#define KEYCODE_UNDO 0x7A -#define KEYCODE_CUT 0x7B -#define KEYCODE_COPY 0x7C -#define KEYCODE_PASTE 0x7D -#define KEYCODE_FIND 0x7E -#define KEYCODE_MUTE 0x7F -#define KEYCODE_VOLUME_UP 0x80 -#define KEYCODE_VOLUME_DOWN 0x81 -#define KEYCODE_CANCEL 0x9B -#define KEYCODE_CLEAR 0x9C -#define KEYCODE_PRIOR 0x9D -#define KEYCODE_KEYPAD_TAB 0xBA -#define KEYCODE_KEYPAD_BACKSPACE 0xBB - // Legacy keycodes. These are what you use with 'press()' and 'release()' #define KEY_LEFT_CTRL 0x80 #define KEY_LEFT_SHIFT 0x81 From 6fd35f631fb7daa050a1f7c4fe5c1ecd4ba90373 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 17:07:01 -0500 Subject: [PATCH 12/27] Add IDE keyword highlighting for new USB HID APIs --- build/shared/lib/keywords.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/shared/lib/keywords.txt b/build/shared/lib/keywords.txt index d77a4b10ce8..0e76bb087a2 100644 --- a/build/shared/lib/keywords.txt +++ b/build/shared/lib/keywords.txt @@ -214,11 +214,17 @@ Keyboard KEYWORD3 Mouse KEYWORD3 press KEYWORD2 release KEYWORD2 +pressKeycode KEYWORD2 +releaseKeycode KEYWORD2 releaseAll KEYWORD2 accept KEYWORD2 click KEYWORD2 move KEYWORD2 +moveAbs KEYWORD2 +write KEYWORD2 isPressed KEYWORD2 +systemControl KEYWORD2 +consumerControl KEYWORD2 setup KEYWORD3 Setup loop KEYWORD3 Loop From cc0cb957da990af9c4c86d624cf88567ed428e25 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 17:41:19 -0500 Subject: [PATCH 13/27] Demo for the AbsoluteMouse API --- .../Mouse/AbsoluteMouse/AbsoluteMouse.ino | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino diff --git a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino new file mode 100644 index 00000000000..437559aedfd --- /dev/null +++ b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino @@ -0,0 +1,34 @@ +/* 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.moveAbs(0,0,0); // Jump to the center of the screen + delay(2500); + Mouse.moveAbs(-500, -500, 0); // X position, Y position, Scroll Wheel + delay(2500); + Mouse.moveAbs(-500, 500, 0); // X position, Y position, Scroll Wheel + delay(2500); + Mouse.moveAbs(500, 500, 0); // X position, Y position, Scroll Wheel + delay(2500); + Mouse.moveAbs(500, -500, 0); // X position, Y position, Scroll Wheel + delay(2500); +} + + + From 05e71732b52e559170acad63ab2ae9d10776ad9f Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 19:02:26 -0500 Subject: [PATCH 14/27] Demo code for the ConsumerControl and SystemControl APIs --- .../ConsumerAndSystemControl.ino | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 build/shared/examples/09.USB/Keyboard/ConsumerAndSystemControl/ConsumerAndSystemControl.ino diff --git a/build/shared/examples/09.USB/Keyboard/ConsumerAndSystemControl/ConsumerAndSystemControl.ino b/build/shared/examples/09.USB/Keyboard/ConsumerAndSystemControl/ConsumerAndSystemControl.ino new file mode 100644 index 00000000000..13d82aa7528 --- /dev/null +++ b/build/shared/examples/09.USB/Keyboard/ConsumerAndSystemControl/ConsumerAndSystemControl.ino @@ -0,0 +1,54 @@ +/* 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 + +} + + + From c86e83e715742f3f5cbb5c2c511bd28be4a5b967 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 22:19:20 -0500 Subject: [PATCH 15/27] Enable Absolute Mouse support by default --- hardware/arduino/avr/cores/arduino/HID.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 41d4161b668..b630b0d3f1d 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -24,7 +24,7 @@ #if defined(USBCON) #ifdef HID_ENABLED -//#define MOUSE_ABS_ENABLED +#define HID_MOUSE_ABS_ENABLED //#define RAWHID_ENABLED // Singletons for mouse and keyboard From d51ff0818ff75697499e8035af0b2f8f7870ea0b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 22:41:52 -0500 Subject: [PATCH 16/27] Refactor the new rawKeycode API to be simpler and cleaner; add a "write keycode" method for parity with the old API. --- hardware/arduino/avr/cores/arduino/HID.cpp | 43 ++++++++++++++------- hardware/arduino/avr/cores/arduino/USBAPI.h | 7 +++- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index b630b0d3f1d..404be4fc183 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -533,9 +533,15 @@ uint8_t USBPutChar(uint8_t c); // 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. - // When send is set to FALSE (= 0x00) no sendReport() is executed. This comes in - // handy when combining key presses (e.g. SHIFT+A). - size_t Keyboard_::pressKeycode(uint8_t k, uint8_t send) + 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; @@ -570,9 +576,6 @@ uint8_t USBPutChar(uint8_t c); } } - if (0 != send) { - sendReport(&_keyReport); - } return 1; } @@ -594,7 +597,7 @@ uint8_t USBPutChar(uint8_t c); if (k & SHIFT) { // it's a capital letter or other character reached with shift // the left shift modifier - pressKeycode(HID_KEYBOARD_LEFT_SHIFT, 0); + addKeycodeToReport(HID_KEYBOARD_LEFT_SHIFT); k = k ^ SHIFT; } } else { @@ -603,7 +606,7 @@ uint8_t USBPutChar(uint8_t c); } } - pressKeycode(k, 1); + pressKeycode(k); return 1; } @@ -676,7 +679,15 @@ size_t Keyboard_::consumerControl(uint8_t k) // 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, uint8_t send) +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; @@ -715,9 +726,6 @@ size_t Keyboard_::releaseKeycode(uint8_t k, uint8_t send) } } - if (send) { - sendReport(&_keyReport); - } return 1; } @@ -741,7 +749,7 @@ size_t Keyboard_::release(uint8_t k) if ((k & SHIFT)) { // it's a capital letter or other character reached with shift // the left shift modifier - releaseKeycode(HID_KEYBOARD_LEFT_SHIFT, 0); + removeKeycodeFromReport(HID_KEYBOARD_LEFT_SHIFT); k = k ^ SHIFT; } } else { @@ -750,7 +758,7 @@ size_t Keyboard_::release(uint8_t k) } } - releaseKeycode(k, 1); + releaseKeycode(k); return 1; } @@ -773,6 +781,13 @@ size_t Keyboard_::write(uint8_t c) 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 #endif /* if defined(USBCON) */ diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index fb25c2760b9..4de65f1f82e 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -225,8 +225,11 @@ class Keyboard_ : public Print virtual size_t write(uint8_t k); virtual size_t press(uint8_t k); virtual size_t release(uint8_t k); - virtual size_t pressKeycode(uint8_t k, uint8_t send); - virtual size_t releaseKeycode(uint8_t k, uint8_t send); + 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); From 3b535fc49998b3ffeee6c8e471a2026b45989d1b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 23:19:43 -0500 Subject: [PATCH 17/27] Fixed a missing paren. Thanks to @follower --- .../examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino index 437559aedfd..6d1901f0362 100644 --- a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino +++ b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino @@ -1,6 +1,6 @@ /* AbsoluteMouse.ino - For ATmega32U4 based boards (like the Leonardo and Micro + 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 From 282d9c2791fd217d85bd08ffd35154bcb281caa7 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 12 Jan 2014 23:48:34 -0500 Subject: [PATCH 18/27] Typo fix (and American spelling standardization.) Thanks to @follower --- hardware/arduino/avr/cores/arduino/USBCore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/USBCore.cpp b/hardware/arduino/avr/cores/arduino/USBCore.cpp index ab845127802..26fe00f558e 100644 --- a/hardware/arduino/avr/cores/arduino/USBCore.cpp +++ b/hardware/arduino/avr/cores/arduino/USBCore.cpp @@ -683,8 +683,8 @@ static inline void USB_ClockEnable() } // Some tests on specific versions of macosx (10.7.3), reported some - // strange behaviuors when the board is reset using the serial - // port touch at 1200 bps. This delay fixes this behaviour. + // strange behaviors when the board is reset using the serial + // port touch at 1200 bps. This delay fixes this behavior. delay(1); USBCON = (USBCON & ~(1< Date: Sun, 19 Jan 2014 15:08:39 -0500 Subject: [PATCH 19/27] Switch absMouse to a coordinate system with an origin of 0,0 in the upper left corner, rather than the center of the screen. Allowing negative absolute coordinates leads to hard-to-debug problems with overflow and 'unreachable' parts of the screen. --- hardware/arduino/avr/cores/arduino/HID.cpp | 25 +++++++++++++++------ hardware/arduino/avr/cores/arduino/USBAPI.h | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 404be4fc183..f74a3ddd7dd 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -108,7 +108,7 @@ const u8 _hidReportDescriptor[] = { 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x09, 0x38, // USAGE (Wheel) - 0x16, 0x00, 0x80, // LOGICAL_MINIMUM (-32768) + 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767) 0x75, 0x10, // REPORT_SIZE (16) 0x95, 0x03, // REPORT_COUNT (3) @@ -322,17 +322,28 @@ void Mouse_::move(signed char x, signed char y, signed char wheel) HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m)); } -// all parameters have the range of -32768 to 32767 and must be scaled to screen pixels +// All parameters have the range of 0 to 32767. The USB Host +// will convert them to pixels on the screen. // some examples: -// x=0,y=0 is the middle of the screen -// x=-32768,y=-32768 is the top left corner -// x=32767,y=-32768 is the top right corner +// 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=-32768,y=32767 is the bottom left 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_::moveAbs(int16_t x, int16_t y, int16_t wheel) { u8 m[7]; - m[0] = _buttons; // TODO: is it a good idea to take over the _buttons from relative report here or should it be left out? + m[0] = _buttons; m[1] = LSB(x); m[2] = MSB(x); m[3] = LSB(y); diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 4de65f1f82e..71ccf82ffb5 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -113,7 +113,7 @@ class Mouse_ void end(void); void click(uint8_t b = MOUSE_LEFT); void move(signed char x, signed char y, signed char wheel = 0); - void moveAbs(int16_t x, int16_t y, int16_t wheel); // all parameters have the range of -32768 to 32767 and must be scaled to screen pixels + void moveAbs(int16_t x, int16_t y, int16_t wheel); 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 From 018545bfd9b6b0cc9a2cf0c79a2120544853490d Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 19 Jan 2014 18:47:56 -0500 Subject: [PATCH 20/27] Remove mouse wheel support from moveAbs. There's not a lot of value to having there be two ways to move the mouse wheel from two different (but similar) APIs. Additionally, with the change to zero-origin for absMouse, the zero-point for the wheel gets a little bit more confusing for users. --- hardware/arduino/avr/cores/arduino/HID.cpp | 15 ++++++--------- hardware/arduino/avr/cores/arduino/USBAPI.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index f74a3ddd7dd..14cc159c4da 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -107,11 +107,10 @@ const u8 _hidReportDescriptor[] = { 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) - 0x09, 0x38, // USAGE (Wheel) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767) 0x75, 0x10, // REPORT_SIZE (16) - 0x95, 0x03, // REPORT_COUNT (3) + 0x95, 0x02, // REPORT_COUNT (2) 0x81, 0x02, // INPUT (Data,Var,Abs) 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION @@ -322,9 +321,9 @@ void Mouse_::move(signed char x, signed char y, signed char wheel) HID_SendReport(HID_REPORTID_MOUSE,m,sizeof(m)); } -// All parameters have the range of 0 to 32767. The USB Host -// will convert them to pixels on the screen. -// some examples: +// 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 @@ -340,16 +339,14 @@ void Mouse_::move(signed char x, signed char y, signed char wheel) // http://lists.apple.com/archives/usb/2011/Jun/msg00032.html -void Mouse_::moveAbs(int16_t x, int16_t y, int16_t wheel) +void Mouse_::moveAbs(uint16_t x, uint16_t y) { - u8 m[7]; + u8 m[5]; m[0] = _buttons; m[1] = LSB(x); m[2] = MSB(x); m[3] = LSB(y); m[4] = MSB(y); - m[5] = LSB(wheel); - m[6] = MSB(wheel); HID_SendReport(HID_REPORTID_MOUSE_ABS,m,sizeof(m)); } diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 71ccf82ffb5..9f91733c5b9 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -113,7 +113,7 @@ class Mouse_ void end(void); void click(uint8_t b = MOUSE_LEFT); void move(signed char x, signed char y, signed char wheel = 0); - void moveAbs(int16_t x, int16_t y, int16_t wheel); + void moveAbs(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 From f0b5e7fa13ebdc8b3546b02780895943ec46befc Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 20 Jan 2014 13:00:06 -0500 Subject: [PATCH 21/27] Update AbsoluteMouse example to the simplified API --- .../09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino index 6d1901f0362..107c16bca7b 100644 --- a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino +++ b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino @@ -18,15 +18,15 @@ void setup() { void loop() { - Mouse.moveAbs(0,0,0); // Jump to the center of the screen + Mouse.moveAbs(16384,16384); // Jump to the center of the screen delay(2500); - Mouse.moveAbs(-500, -500, 0); // X position, Y position, Scroll Wheel + Mouse.moveAbs(0, 0); // X position, Y position delay(2500); - Mouse.moveAbs(-500, 500, 0); // X position, Y position, Scroll Wheel + Mouse.moveAbs(0, 32767); delay(2500); - Mouse.moveAbs(500, 500, 0); // X position, Y position, Scroll Wheel + Mouse.moveAbs(32767, 32767); delay(2500); - Mouse.moveAbs(500, -500, 0); // X position, Y position, Scroll Wheel + Mouse.moveAbs(32767,0); delay(2500); } From 9ba38e73d342f9f4d56e7b4aa35eb5ea226359ca Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 2 Feb 2014 14:56:27 -0500 Subject: [PATCH 22/27] Fix an off-by-8 error in the HID ConsumerControl driver that broke things on Windows devices --- hardware/arduino/avr/cores/arduino/HID.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 14cc159c4da..292624ad103 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -201,6 +201,10 @@ const u8 _hidReportDescriptor[] = { 0x09, 0x01, // USAGE (Consumer Control) 0xa1, 0x01, // COLLECTION (Application) 0x85, HID_REPORTID_CONSUMERCONTROL, // REPORT_ID (6) + 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 @@ -209,10 +213,6 @@ const u8 _hidReportDescriptor[] = { 0x09, 0xb6, // USAGE (Scan Previous Track) 0x06 0x09, 0xb5, // USAGE (Scan Next Track) 0x07 0x09, 0xb8, // USAGE (Eject) 0x08 - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0x01, // LOGICAL_MAXIMUM (1) - 0x75, 0x01, // REPORT_SIZE (1) - 0x95, 0x0f, // REPORT_COUNT (8) 0x81, 0x02, // INPUT (Data,Var,Abs) 0xc0, From 092dbd7a53bf96eca9209188143eacb1a80e12a5 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 2 Feb 2014 15:18:01 -0500 Subject: [PATCH 23/27] clean up and reorder the USB HID descriptors. No functional changes --- hardware/arduino/avr/cores/arduino/HID.cpp | 207 +++++++++++---------- 1 file changed, 104 insertions(+), 103 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 292624ad103..5ace8e64fd0 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -45,23 +45,54 @@ Keyboard_ Keyboard; #define RAWHID_TX_SIZE 64 #define RAWHID_RX_SIZE 64 -#define HID_REPORTID_MOUSE (1) -#define HID_REPORTID_KEYBOARD (2) -#define HID_REPORTID_RAWHID (3) +#define HID_REPORTID_KEYBOARD (1) +#define HID_REPORTID_MOUSE (2) +#define HID_REPORTID_MOUSE_ABS (3) #define HID_REPORTID_SYSTEMCONTROL (4) -#define HID_REPORTID_MOUSE_ABS (5) -#define HID_REPORTID_CONSUMERCONTROL (6) +#define HID_REPORTID_CONSUMERCONTROL (5) +#define HID_REPORTID_RAWHID (6) extern const u8 _hidReportDescriptor[] PROGMEM; const u8 _hidReportDescriptor[] = { + // 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 + // 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 (1) + 0x85, HID_REPORTID_MOUSE, // REPORT_ID 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x03, // USAGE_MAXIMUM (Button 3) @@ -92,7 +123,7 @@ const u8 _hidReportDescriptor[] = { 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) - 0x85, HID_REPORTID_MOUSE_ABS, // REPORT_ID (5) + 0x85, HID_REPORTID_MOUSE_ABS, // REPORT_ID 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x03, // USAGE_MAXIMUM (Button 3) @@ -116,106 +147,76 @@ const u8 _hidReportDescriptor[] = { 0xc0, // END_COLLECTION #endif - // Keyboard - 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47 - 0x09, 0x06, // USAGE (Keyboard) - 0xa1, 0x01, // COLLECTION (Application) - 0x85, HID_REPORTID_KEYBOARD, // REPORT_ID (2) - 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 - // 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 (4) - 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 + 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 + + // 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, #if RAWHID_ENABLED - // 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 (3) - 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 + // 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 #endif - 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) - 0x09, 0x01, // USAGE (Consumer Control) - 0xa1, 0x01, // COLLECTION (Application) - 0x85, HID_REPORTID_CONSUMERCONTROL, // REPORT_ID (6) - 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, - }; extern const HIDDescriptor _hidInterface PROGMEM; From 1b0b398a81ed49bac86c61a6c7e1f8eb2bd73048 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 10 Feb 2014 10:32:59 -0500 Subject: [PATCH 24/27] spell out moveAbsolute on the advice of David Mellis --- .../09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino | 10 +++++----- build/shared/lib/keywords.txt | 2 +- hardware/arduino/avr/cores/arduino/HID.cpp | 2 +- hardware/arduino/avr/cores/arduino/USBAPI.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino index 107c16bca7b..254cdcdc3a2 100644 --- a/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino +++ b/build/shared/examples/09.USB/Mouse/AbsoluteMouse/AbsoluteMouse.ino @@ -18,15 +18,15 @@ void setup() { void loop() { - Mouse.moveAbs(16384,16384); // Jump to the center of the screen + Mouse.moveAbsolute(16384,16384); // Jump to the center of the screen delay(2500); - Mouse.moveAbs(0, 0); // X position, Y position + Mouse.moveAbsolute(0, 0); // X position, Y position delay(2500); - Mouse.moveAbs(0, 32767); + Mouse.moveAbsolute(0, 32767); delay(2500); - Mouse.moveAbs(32767, 32767); + Mouse.moveAbsolute(32767, 32767); delay(2500); - Mouse.moveAbs(32767,0); + Mouse.moveAbsolute(32767,0); delay(2500); } diff --git a/build/shared/lib/keywords.txt b/build/shared/lib/keywords.txt index 0e76bb087a2..80c0be528d9 100644 --- a/build/shared/lib/keywords.txt +++ b/build/shared/lib/keywords.txt @@ -220,7 +220,7 @@ releaseAll KEYWORD2 accept KEYWORD2 click KEYWORD2 move KEYWORD2 -moveAbs KEYWORD2 +moveAbsolute KEYWORD2 write KEYWORD2 isPressed KEYWORD2 systemControl KEYWORD2 diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 5ace8e64fd0..310d7454a88 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -340,7 +340,7 @@ void Mouse_::move(signed char x, signed char y, signed char wheel) // http://lists.apple.com/archives/usb/2011/Jun/msg00032.html -void Mouse_::moveAbs(uint16_t x, uint16_t y) +void Mouse_::moveAbsolute(uint16_t x, uint16_t y) { u8 m[5]; m[0] = _buttons; diff --git a/hardware/arduino/avr/cores/arduino/USBAPI.h b/hardware/arduino/avr/cores/arduino/USBAPI.h index 9f91733c5b9..1121e4afe05 100644 --- a/hardware/arduino/avr/cores/arduino/USBAPI.h +++ b/hardware/arduino/avr/cores/arduino/USBAPI.h @@ -113,7 +113,7 @@ class Mouse_ void end(void); void click(uint8_t b = MOUSE_LEFT); void move(signed char x, signed char y, signed char wheel = 0); - void moveAbs(uint16_t x, uint16_t y); + 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 From b02e5aab2199b8a3dfadc7f882910ed0abed8bfa Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 27 Feb 2014 21:18:29 -0500 Subject: [PATCH 25/27] fix usb mouse report count --- hardware/arduino/avr/cores/arduino/HID.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 310d7454a88..15e88ff1a47 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -98,12 +98,12 @@ const u8 _hidReportDescriptor[] = { 0x29, 0x03, // USAGE_MAXIMUM (Button 3) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) - 0x95, 0x03, // REPORT_COUNT (3) + 0x95, 0x05, // REPORT_COUNT (5) 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) + 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) From 90329713f8d9f49b46c1b765d47ffa2c955e7d23 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 27 Feb 2014 21:19:13 -0500 Subject: [PATCH 26/27] beginnings of support for 5 button mice --- hardware/arduino/avr/cores/arduino/HID.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index 15e88ff1a47..f3cc4f38e05 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -95,7 +95,7 @@ const u8 _hidReportDescriptor[] = { 0x85, HID_REPORTID_MOUSE, // REPORT_ID 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) - 0x29, 0x03, // USAGE_MAXIMUM (Button 3) + 0x29, 0x05, // USAGE_MAXIMUM (Button 5) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x95, 0x05, // REPORT_COUNT (5) From ff04c1390921c2b2cfd55fcd6ea0a5484664e3fd Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 9 Mar 2014 17:17:37 -0700 Subject: [PATCH 27/27] extract the various HID report stanzas into preprocessor macros as prep for further refactoring --- hardware/arduino/avr/cores/arduino/HID.cpp | 323 +++++++++++---------- 1 file changed, 165 insertions(+), 158 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/HID.cpp b/hardware/arduino/avr/cores/arduino/HID.cpp index f3cc4f38e05..38b20bc3dda 100644 --- a/hardware/arduino/avr/cores/arduino/HID.cpp +++ b/hardware/arduino/avr/cores/arduino/HID.cpp @@ -52,170 +52,177 @@ Keyboard_ Keyboard; #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[] = { - - // 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 - - // 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 + HID_REPORT_KEYBOARD, + HID_REPORT_MOUSE_RELATIVE, #ifdef HID_MOUSE_ABS_ENABLED - // 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 + HID_REPORT_MOUSE_ABSOLUTE, #endif - - // 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 - - // 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, - + HID_REPORT_SYSTEMCONTROL, + HID_REPORT_CONSUMERCONTROL, #if RAWHID_ENABLED - // 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 + HID_REPORT_RAWHID #endif };