diff options
Diffstat (limited to 'hid-dials/Src/usbd_hid.c')
-rw-r--r-- | hid-dials/Src/usbd_hid.c | 112 |
1 files changed, 48 insertions, 64 deletions
diff --git a/hid-dials/Src/usbd_hid.c b/hid-dials/Src/usbd_hid.c index f06d2db..3704be4 100644 --- a/hid-dials/Src/usbd_hid.c +++ b/hid-dials/Src/usbd_hid.c @@ -152,7 +152,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ 0xE0, /*bmAttributes: bus powered and Support Remote Wake-up */ 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ - /************** Descriptor of Joystick Mouse interface ****************/ + /* Interface descriptor */ /* 09 */ 0x09, /*bLength: Interface Descriptor size*/ USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/ @@ -165,7 +165,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ 0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ 0x01, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ 0, /*iInterface: Index of string descriptor*/ - /******************** Descriptor of Joystick Mouse HID ********************/ + /* HID descriptor */ /* 18 */ 0x09, /*bLength: HID Descriptor size*/ HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ @@ -176,7 +176,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ 0x22, /*bDescriptorType*/ HID_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/ 0x00, - /******************** Descriptor of Mouse endpoint ********************/ + /* HID endpoint descriptor */ /* 27 */ 0x07, /*bLength: Endpoint Descriptor size*/ USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ @@ -233,29 +233,21 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_ __ALIGN_BEGIN static uint8_t HID_ReportDesc[HID_REPORT_DESC_SIZE] __ALIGN_END = { - //copy from arduino code https://github.com/arduino-libraries/Keyboard/blob/master/src/Keyboard.cpp - - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x06, // Usage (Keyboard) - 0xA1, 0x01, // Collection (Application) - - 0x85, 0x01, // Report ID (1) - - 0x05, 0x07, // Usage Page (Kbrd/Keypad) - 0x19, 0xE0, // Usage Minimum (0xE0) - 0x29, 0xE7, // Usage Maximum (0xE7) - - // it seam we missed the shit ctrl etc .. here - 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,No Wrap,Linear,Preferred State,No Null Position) - 0x95, 0x01, // Report Count (1) - 0x75, 0x08, // Report Size (8) - 0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) -#if HID_LED_SUPPORT - // --------------------- output report for LED + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x06, // USAGE (Keyboard) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, 0x01, /* Report ID */ + 0x05, 0x07, // USAGE_PAGE (Keyboard) + 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) 0x95, 0x05, // REPORT_COUNT (5) 0x75, 0x01, // REPORT_SIZE (1) 0x05, 0x08, // USAGE_PAGE (LEDs) @@ -265,50 +257,42 @@ __ALIGN_BEGIN static uint8_t HID_ReportDesc[HID_REPORT_DESC_SIZE] __ALIGN_END = 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x03, // REPORT_SIZE (3) 0x91, 0x03, // OUTPUT (Cnst,Var,Abs) -#endif - 0x95, 0x06, // Report Count (6) - 0x75, 0x08, // Report Size (8) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x65, // Logical Maximum (101) - 0x05, 0x07, // Usage Page (Kbrd/Keypad) - 0x19, 0x00, // Usage Minimum (0x00) - 0x29, 0x65, // Usage Maximum (0x65) - 0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, // End Collection - - // 47 bytes -#if HID_MEDIA_REPORT - //help from http://www.microchip.com/forums/m618147.aspx - // this way of describing and sending media control is convenient - // short descriptor that permit all kidn meda by sending "usage" code - // see usb hid spec for full list - // it is possible to define one media key per bit it requires more space - // for descripotor and report ending is tighlyu couple to decriptor - // so it is not as convenient - // one such working code can be find here https://github.com/markwj/hidmedia/blob/master/hidmedia.X/usb_descriptors.c - // - - 0x05, 0x0C, // Usage Page (Consumer) - 0x09, 0x01, // Usage (Consumer Control) - 0xA1, 0x01, // Collection (Application) - 0x85, HID_MEDIA_REPORT, // Report ID (VOLUME_REPORT ) - 0x19, 0x00, // Usage Minimum (Unassigned) - 0x2A, 0x3C, 0x02, // Usage Maximum (AC Format) - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0x3C, 0x02, // Logical Maximum (572) - 0x95, 0x01, // Report Count (1) - 0x75, 0x10, // Report Size (16) - 0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, // End Collection + 0x95, 0x06, // REPORT_COUNT (6) + 0x75, 0x08, // REPORT_SIZE (8) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x65, // LOGICAL_MAXIMUM (101) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) + 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) + 0x81, 0x00, // INPUT (Data,Ary,Abs) + 0xc0, // End Collection +// + 0x05, 0x0C, /* Usage Page (Consumer Devices) */ + 0x09, 0x01, /* Usage (Consumer Control) */ + 0xA1, 0x01, /* Collection (Application) */ + 0x85, 0x02, /* Report ID=2 */ + 0x05, 0x0C, /* Usage Page (Consumer Devices) */ + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0x01, /* Logical Maximum (1) */ + 0x75, 0x01, /* Report Size (1) */ + 0x95, 0x07, /* Report Count (7) */ + 0x09, 0xB5, /* Usage (Scan Next Track) */ + 0x09, 0xB6, /* Usage (Scan Previous Track) */ + 0x09, 0xB7, /* Usage (Stop) */ + 0x09, 0xCD, /* Usage (Play / Pause) */ + 0x09, 0xE2, /* Usage (Mute) */ + 0x09, 0xE9, /* Usage (Volume Up) */ + 0x09, 0xEA, /* Usage (Volume Down) */ + 0x81, 0x02, /* Input (Data, Variable, Absolute) */ + 0x95, 0x01, /* Report Count (1) */ + 0x81, 0x01, /* Input (Constant) */ + 0xC0, // End Collection // how to format the 3 byte report // byte 0 report ID = 0x02 (VOLUME_REPORT) // byte 1 media code for ex VOL_UP 0xE9 , VOL_DONW 0xEA ... etc // byte 2 0x00 // a second report with 0 code shal be send to avoid "key repaeat" - - // 25 bytes -#endif }; uint32_t nOutData; |