Advertisement
Guest User

Untitled

a guest
Aug 1st, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 33.47 KB | None | 0 0
  1. /*
  2.              LUFA Library
  3.      Copyright (C) Dean Camera, 2015.
  4.  
  5.   dean [at] fourwalledcubicle [dot] com
  6.            www.lufa-lib.org
  7. */
  8.  
  9. /*
  10.   Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com)
  11.  
  12.   Permission to use, copy, modify, distribute, and sell this
  13.   software and its documentation for any purpose is hereby granted
  14.   without fee, provided that the above copyright notice appear in
  15.   all copies and that both that the copyright notice and this
  16.   permission notice and warranty disclaimer appear in supporting
  17.   documentation, and that the name of the author not be used in
  18.   advertising or publicity pertaining to distribution of the
  19.   software without specific, written prior permission.
  20.  
  21.   The author disclaims all warranties with regard to this
  22.   software, including all implied warranties of merchantability
  23.   and fitness.  In no event shall the author be liable for any
  24.   special, indirect or consequential damages or any damages
  25.   whatsoever resulting from loss of use, data or profits, whether
  26.   in an action of contract, negligence or other tortious action,
  27.   arising out of or in connection with the use or performance of
  28.   this software.
  29. */
  30.  
  31. /** \file
  32.  *
  33.  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special
  34.  *  computer-readable structures which the host requests upon device enumeration, to determine
  35.  *  the device's capabilities and functions.
  36.  */
  37.  
  38. #include "Descriptors.h"
  39.  
  40. /** HID class report descriptor. This is a special descriptor constructed with values from the
  41.  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This
  42.  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding)
  43.  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for
  44.  *  more details on HID report descriptors.
  45.  */
  46. const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
  47. {
  48.  
  49.     0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
  50.     0x09, 0x04,                    // USAGE (Joystick)
  51.     0xa1, 0x01,                    // COLLECTION (Application)
  52.     0xa1, 0x00,                    //   COLLECTION (Physical)
  53.     0x85, 0x01,
  54.     0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
  55.     0x09, 0x30,                    //     USAGE (X)
  56.     0x09, 0x31,                    //     USAGE (Y)
  57.     0x09, 0x32,                    //     USAGE (Z)
  58.     0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
  59.     0x26, 0xff, 0x71,              //     LOGICAL_MAXIMUM (25000)
  60.     0x75, 0x10,                    //     REPORT_SIZE (16)
  61.     0x95, 0x03,                    //     REPORT_COUNT (3)
  62.     0x81, 0x02,                    //     INPUT (Data,Var,Abs)
  63.     //HID_RI_END_COLLECTION(0),
  64.     0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
  65.     0x09, 0x33,                    //     USAGE (X)
  66.     0x95, 0x01,                    //     REPORT_COUNT (1)
  67.     0x75, 0x10,                    //     REPORT_SIZE (16)
  68.     0x26, 0xff, 0xff,              //     LOGICAL_MAXIMUM (32000)
  69.     0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
  70.     0x81, 0x02,                    //     INPUT (Data,Var,Abs)
  71.     0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
  72.     0x09, 0x34,                    //     USAGE (Ry)
  73.     0x09, 0x35,                    //     USAGE (Rz)
  74.     0x09, 0x36,                    //     USAGE (Slider)
  75.     0x09, 0x36,                    //     USAGE (Slider)
  76.     0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
  77.     0x26, 0x00, 0x04,              //     LOGICAL_MAXIMUM (1024)
  78.     0x75, 0x10,                    //     REPORT_SIZE (16)
  79.     0x95, 0x04,                    //     REPORT_COUNT (5)
  80.     0x81, 0x02,                    //     INPUT (Data,Var,Abs)
  81.     0x05, 0x09,                    //     USAGE_PAGE (Button)
  82.     0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
  83.     0x29, 0x20,                    //     USAGE_MAXIMUM (Button 48)
  84.     0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
  85.     0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
  86.     0x95, 0x20,                    //     REPORT_COUNT (48)
  87.     0x75, 0x01,                    //     REPORT_SIZE (1)
  88.     0x81, 0x02,                    //     INPUT (Data,Var,Abs)
  89.     0x05, 0x01,                     // Usage Page (Generic Desktop)
  90.     0x09, 0x39,                     // Usage (Hat switch)
  91.     0x09, 0x39,                     // Usage (Hat switch)
  92.     0x09, 0x39,                     // Usage (Hat switch)
  93.     0x09, 0x39,                     // Usage (Hat switch)
  94.     0x15, 0x00,                     // Logical Minimum (0)
  95.     0x25, 0x07,                     // Logical Maximum (7)
  96.     0x35, 0x00,                     // Physical Minimum (0)
  97.     0x46, 0x3B, 0x01,               // Physical Maximum (315)
  98.     0x75, 0x04,                     // Report Size (4)
  99.     0x95, 0x04,                     // Report Count (4)
  100.     0x65, 0x14,                     // Unit (20)
  101.     0x81, 0x42,                     // Input (variable,absolute,null_state)
  102.     0xc0,                          //     END_COLLECTION
  103.    
  104.         0x05,0x0F,  // USAGE_PAGE (Physical Interface)
  105.         0x09,0x92,  // USAGE (PID State Report)
  106.         0xA1,0x02,  // COLLECTION (Logical)
  107.         0x85,0x02,  // REPORT_ID (02)
  108.         0x09,0x9F,  // USAGE (Device Paused)
  109.         0x09,0xA0,  // USAGE (Actuators Enabled)
  110.         0x09,0xA4,  // USAGE (Safety Switch)
  111.         0x09,0xA5,  // USAGE (Actuator Override Switch)
  112.         0x09,0xA6,  // USAGE (Actuator Power)
  113.         0x15,0x00,  // LOGICAL_MINIMUM (00)
  114.         0x25,0x01,  // LOGICAL_MINIMUM (01)
  115.         0x35,0x00,  // PHYSICAL_MINIMUM (00)
  116.         0x45,0x01,  // PHYSICAL_MAXIMUM (01)
  117.         0x75,0x01,  // REPORT_SIZE (01)
  118.         0x95,0x05,  // REPORT_COUNT (05)
  119.         0x81,0x02,  // INPUT (Data,Var,Abs)
  120.         0x95,0x03,  // REPORT_COUNT (03)
  121.         0x81,0x03,  // INPUT (Constant,Var,Abs)
  122.         0x09,0x94,  // USAGE (Effect Playing)
  123.         0x15,0x00,  // LOGICAL_MINIMUM (00)
  124.         0x25,0x01,  // LOGICAL_MAXIMUM (01)
  125.         0x35,0x00,  // PHYSICAL_MINIMUM (00)
  126.         0x45,0x01,  // PHYSICAL_MAXIMUM (01)
  127.         0x75,0x01,  // REPORT_SIZE (01)
  128.         0x95,0x01,  // REPORT_COUNT (01)
  129.         0x81,0x02,  // INPUT (Data,Var,Abs)
  130.         0x09,0x22,  // USAGE (Effect Block Index)
  131.         0x15,0x01,  // LOGICAL_MINIMUM (01)
  132.         0x25,0x28,  // LOGICAL_MAXIMUM (28)
  133.         0x35,0x01,  // PHYSICAL_MINIMUM (01)
  134.         0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  135.         0x75,0x07,  // REPORT_SIZE (07)
  136.         0x95,0x01,  // REPORT_COUNT (01)
  137.         0x81,0x02,  // INPUT (Data,Var,Abs)
  138.         0xC0,   // END COLLECTION ()
  139.        
  140.             0x09,0x21,  // USAGE (Set Effect Report)
  141.             0xA1,0x02,  // COLLECTION (Logical)
  142.             0x85,0x01,  // REPORT_ID (01)
  143.             0x09,0x22,  // USAGE (Effect Block Index)
  144.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  145.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  146.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  147.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  148.             0x75,0x08,  // REPORT_SIZE (08)
  149.             0x95,0x01,  // REPORT_COUNT (01)
  150.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  151.             0x09,0x25,  // USAGE (25)
  152.             0xA1,0x02,  // COLLECTION (Logical)
  153.             0x09,0x26,  // USAGE (26)
  154.             0x09,0x27,  // USAGE (27)
  155.             0x09,0x30,  // USAGE (30)
  156.             0x09,0x31,  // USAGE (31)
  157.             0x09,0x32,  // USAGE (32)
  158.             0x09,0x33,  // USAGE (33)
  159.             0x09,0x34,  // USAGE (34)
  160.             0x09,0x40,  // USAGE (40)
  161.             0x09,0x41,  // USAGE (41)
  162.             0x09,0x42,  // USAGE (42)
  163.             0x09,0x43,  // USAGE (43)
  164.             0x09,0x28,  // USAGE (28)
  165.             0x25,0x0C,  // LOGICAL_MAXIMUM (0C)
  166.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  167.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  168.             0x45,0x0C,  // PHYSICAL_MAXIMUM (0C)
  169.             0x75,0x08,  // REPORT_SIZE (08)
  170.             0x95,0x01,  // REPORT_COUNT (01)
  171.             0x91,0x00,  // OUTPUT (Data)
  172.             0xC0,   // END COLLECTION ()
  173.             0x09,0x50,  // USAGE (Duration)
  174.             0x09,0x54,  // USAGE (Trigger Repeat Interval)
  175.             0x09,0x51,  // USAGE (Sample Period)
  176.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  177.             0x26,0xFF,0x7F, // LOGICAL_MAXIMUM (7F FF)
  178.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  179.             0x46,0xFF,0x7F, // PHYSICAL_MAXIMUM (7F FF)
  180.             0x66,0x03,0x10, // UNIT (Eng Lin:Time)
  181.             0x55,0xFD,  // UNIT_EXPONENT (-3)
  182.             0x75,0x10,  // REPORT_SIZE (10)
  183.             0x95,0x03,  // REPORT_COUNT (03)
  184.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  185.             0x55,0x00,  // UNIT_EXPONENT (00)
  186.             0x66,0x00,0x00, // UNIT (None)
  187.             0x09,0x52,  // USAGE (Gain)
  188.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  189.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  190.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  191.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  192.             0x75,0x08,  // REPORT_SIZE (08)
  193.             0x95,0x01,  // REPORT_COUNT (01)
  194.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  195.             0x09,0x53,  // USAGE (Trigger Button)
  196.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  197.             0x25,0x08,  // LOGICAL_MAXIMUM (08)
  198.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  199.             0x45,0x08,  // PHYSICAL_MAXIMUM (08)
  200.             0x75,0x08,  // REPORT_SIZE (08)
  201.             0x95,0x01,  // REPORT_COUNT (01)
  202.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  203.             0x09,0x55,  // USAGE (Axes Enable)
  204.             0xA1,0x02,  // COLLECTION (Logical)
  205.             0x05,0x01,  // USAGE_PAGE (Generic Desktop)
  206.             0x09,0x30,  // USAGE (X)
  207.             0x09,0x31,  // USAGE (Y)
  208.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  209.             0x25,0x01,  // LOGICAL_MAXIMUM (01)
  210.             0x75,0x01,  // REPORT_SIZE (01)
  211.             0x95,0x02,  // REPORT_COUNT (02)
  212.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  213.             0xC0,   // END COLLECTION ()
  214.             0x05,0x0F,  // USAGE_PAGE (Physical Interface)
  215.             0x09,0x56,  // USAGE (Direction Enable)
  216.             0x95,0x01,  // REPORT_COUNT (01)
  217.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  218.             0x95,0x05,  // REPORT_COUNT (05)
  219.             0x91,0x03,  // OUTPUT (Constant,Var,Abs)
  220.             0x09,0x57,  // USAGE (Direction)
  221.             0xA1,0x02,  // COLLECTION (Logical)
  222.             0x0B,0x01,0x00,0x0A,0x00,
  223.             0x0B,0x02,0x00,0x0A,0x00,
  224.             0x66,0x14,0x00, // UNIT (Eng Rot:Angular Pos)
  225.             0x55,0xFE,  // UNIT_EXPONENT (FE)
  226.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  227.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  228.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  229.             0x47,0xA0,0x8C,0x00,0x00,   // PHYSICAL_MAXIMUM (00 00 8C A0)
  230.             0x66,0x00,0x00, // UNIT (None)
  231.             0x75,0x08,  // REPORT_SIZE (08)
  232.             0x95,0x02,  // REPORT_COUNT (02)
  233.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  234.             0x55,0x00,  // UNIT_EXPONENT (00)
  235.             0x66,0x00,0x00, // UNIT (None)
  236.             0xC0,   // END COLLECTION ()
  237.             0x05,0x0F,  // USAGE_PAGE (Physical Interface)
  238.             //      0x09,0xA7,  // USAGE (Start Delay)
  239.             0x66,0x03,0x10, // UNIT (Eng Lin:Time)
  240.             0x55,0xFD,  // UNIT_EXPONENT (-3)
  241.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  242.             0x26,0xFF,0x7F, // LOGICAL_MAXIMUM (7F FF)
  243.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  244.             0x46,0xFF,0x7F, // PHYSICAL_MAXIMUM (7F FF)
  245.             0x75,0x10,  // REPORT_SIZE (10)
  246.             0x95,0x01,  // REPORT_COUNT (01)
  247.             //      0x91,0x02,  // OUTPUT (Data,Var,Abs)
  248.             0x66,0x00,0x00, // UNIT (None)
  249.             0x55,0x00,  // UNIT_EXPONENT (00)
  250.             0xC0,   // END COLLECTION ()
  251.        
  252.         0x05,0x0F,  // USAGE_PAGE (Physical Interface)
  253.         0x09,0x5A,  // USAGE (Set Envelope Report)
  254.         0xA1,0x02,  // COLLECTION (Logical)
  255.         0x85,0x02,  // REPORT_ID (02)
  256.             0x09,0x22,  // USAGE (Effect Block Index)
  257.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  258.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  259.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  260.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  261.             0x75,0x08,  // REPORT_SIZE (08)
  262.             0x95,0x01,  // REPORT_COUNT (01)
  263.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  264.             0x09,0x5B,  // USAGE (Attack Level)
  265.             0x09,0x5D,  // USAGE (Fade Level)
  266.  
  267.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  268.             0x26,0x10,0x27, // LOGICAL_MAXIMUM (00 FF)
  269.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  270.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  271.             0x75,0x10,  // REPORT_SIZE (08)
  272.                
  273.             0x95,0x02,  // REPORT_COUNT (02)
  274.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  275.             0x09,0x5C,  // USAGE (5C)
  276.             0x09,0x5E,  // USAGE (5E)
  277.             0x66,0x03,0x10, // UNIT (Eng Lin:Time)
  278.             0x55,0xFD,  // UNIT_EXPONENT (-3)
  279.             0x26,0xFF,0x7F, // LOGICAL_MAXIMUM (7F FF)
  280.             0x46,0xFF,0x7F, // PHYSICAL_MAXIMUM (7F FF)
  281.             0x75,0x10,  // REPORT_SIZE (10)
  282.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  283.             0x45,0x00,  // PHYSICAL_MAXIMUM (00)
  284.             0x66,0x00,0x00, // UNIT (None)
  285.             0x55,0x00,  // UNIT_EXPONENT (00)
  286.             0xC0,   // END COLLECTION ()
  287.            
  288.             0x09,0x5F,  // USAGE (Set Condition Report)
  289.             0xA1,0x02,  // COLLECTION (Logical)
  290.             0x85,0x03,  // REPORT_ID (03)
  291.             0x09,0x22,  // USAGE (Effect Block Index)
  292.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  293.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  294.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  295.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  296.             0x75,0x08,  // REPORT_SIZE (08)
  297.             0x95,0x01,  // REPORT_COUNT (01)
  298.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  299.             0x09,0x23,  // USAGE (Parameter Block Offset)
  300.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  301.             0x25,0x01,  // LOGICAL_MAXIMUM (01)
  302.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  303.             0x45,0x01,  // PHYSICAL_MAXIMUM (01)
  304.             0x75,0x04,  // REPORT_SIZE (04)
  305.             0x95,0x01,  // REPORT_COUNT (01)
  306.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  307.             0x09,0x58,  // USAGE (Type Specific Block Offset)
  308.             0xA1,0x02,  // COLLECTION (Logical)
  309.             0x0B,0x01,0x00,0x0A,0x00,   // USAGE (Instance 1)
  310.             0x0B,0x02,0x00,0x0A,0x00,   // USAGE (Instance 2)
  311.             0x75,0x02,  // REPORT_SIZE (02)
  312.             0x95,0x02,  // REPORT_COUNT (02)
  313.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  314.             0xC0,   // END COLLECTION ()
  315.             0x15,0x80,  // LOGICAL_MINIMUM (80)
  316.             0x25,0x7F,  // LOGICAL_MAXIMUM (7F)
  317.             0x36,0xF0,0xD8, // PHYSICAL_MINIMUM (-10000)
  318.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  319.             0x09,0x60,  // USAGE (CP Offset)
  320.                 0x09,0x61,  // USAGE (Positive Coefficient)
  321.                 0x09,0x62,  // USAGE (Negative Coefficient)
  322.                 0x09,0x63,  // USAGE (Positive Saturation)
  323.                 0x09,0x64,  // USAGE (Negative Saturation)
  324.                 0x09,0x65,  // USAGE (Dead Band )
  325.                 0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
  326.                 0x26, 0x10, 0x27,              //     LOGICAL_MAXIMUM (25000)
  327.             0x75, 0x10,                    //     REPORT_SIZE (16)
  328.             //0x75,0x08,    // REPORT_SIZE (08)
  329.             0x95,0x06,  // REPORT_COUNT (01)
  330.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  331.             0x36,0xF0,0xD8, // PHYSICAL_MINIMUM (-10000)
  332.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  333.         /*
  334.             0x95,0x02,  // REPORT_COUNT (01)    // ???? WAS 2 with "negative coeff"
  335.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  336.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  337.              0x26, 0x10, 0x27,  // LOGICAL_MAXIMUM (00 FF)
  338.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  339.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  340.            
  341.             0x09,0x63,  // USAGE (Positive Saturation)
  342.             0x09,0x64,  // USAGE (Negative Saturation)
  343.             0x75,0x10,  // REPORT_SIZE (08)
  344.             0x95,0x02,  // REPORT_COUNT (02)
  345.             //      0x91,0x02,  // OUTPUT (Data,Var,Abs)
  346.             //      0x09,0x65,  // USAGE (Dead Band )
  347.                     0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
  348.                     0x26, 0x10, 0x27,              //     LOGICAL_MAXIMUM (25000)
  349.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  350.             0x95,0x01,  // REPORT_COUNT (01)
  351.             //      0x91,0x02,  // OUTPUT (Data,Var,Abs)
  352.             */
  353.             0xC0,   // END COLLECTION ()
  354.            
  355.             0x09,0x6E,  // USAGE (Set Periodic Report)
  356.             0xA1,0x02,  // COLLECTION (Logical)
  357.             0x85,0x04,  // REPORT_ID (04)
  358.             0x09,0x22,  // USAGE (Effect Block Index)
  359.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  360.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  361.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  362.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  363.             0x75,0x08,  // REPORT_SIZE (08)
  364.             0x95,0x01,  // REPORT_COUNT (01)
  365.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  366.             0x09,0x70,  // USAGE (Magnitude)
  367.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  368.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  369.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  370.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  371.             0x75,0x08,  // REPORT_SIZE (08)
  372.             0x95,0x01,  // REPORT_COUNT (01)
  373.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  374.             0x09,0x6F,  // USAGE (Offset)
  375.             0x15,0x80,  // LOGICAL_MINIMUM (80)
  376.             0x25,0x7F,  // LOGICAL_MAXIMUM (7F)
  377.             0x36,0xF0,0xD8, // PHYSICAL_MINIMUM (-10000)
  378.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  379.             0x95,0x01,  // REPORT_COUNT (01)
  380.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  381.             0x09,0x71,  // USAGE (Phase)
  382.             0x66,0x14,0x00, // UNIT (Eng Rot:Angular Pos)
  383.             0x55,0xFE,  // UNIT_EXPONENT (FE)
  384.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  385.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  386.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  387.             0x47,0xA0,0x8C,0x00,0x00,   // PHYSICAL_MAXIMUM (00 00 8C A0)
  388.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  389.             0x09,0x72,  // USAGE (Period)
  390.             0x26,0xFF,0x7F, // LOGICAL_MAXIMUM (7F FF)
  391.             0x46,0xFF,0x7F, // PHYSICAL_MAXIMUM (7F FF)
  392.             0x66,0x03,0x10, // UNIT (Eng Lin:Time)
  393.             0x55,0xFD,  // UNIT_EXPONENT (-3)
  394.             0x75,0x10,  // REPORT_SIZE (10)
  395.             0x95,0x01,  // REPORT_COUNT (01)
  396.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  397.             0x66,0x00,0x00, // UNIT (None)
  398.             0x55,0x00,  // UNIT_EXPONENT (00)
  399.             0xC0,   // END COLLECTION ()
  400.            
  401.             0x09,0x73,  // USAGE (Set Constant Force Report)
  402.             0xA1,0x02,  // COLLECTION (Logical)
  403.             0x85,0x05,  // REPORT_ID (05)
  404.             0x09,0x22,  // USAGE (Effect Block Index)
  405.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  406.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  407.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  408.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  409.             0x75,0x08,  // REPORT_SIZE (08)
  410.             0x95,0x01,  // REPORT_COUNT (01)
  411.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  412.             0x09,0x70,  // USAGE (Magnitude)
  413.             0x16,0x01,0xFF, // LOGICAL_MINIMUM (-255)
  414.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (255)
  415.             0x36,0xF0,0xD8, // PHYSICAL_MINIMUM (-10000)
  416.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  417.             0x75,0x10,  // REPORT_SIZE (10)
  418.             0x95,0x01,  // REPORT_COUNT (01)
  419.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  420.             0xC0,   // END COLLECTION ()
  421.            
  422.             0x09,0x74,  // USAGE (Set Ramp Force Report)
  423.             0xA1,0x02,  // COLLECTION (Logical)
  424.             0x85,0x06,  // REPORT_ID (06)
  425.             0x09,0x22,  // USAGE (Effect Block Index)
  426.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  427.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  428.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  429.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  430.             0x75,0x08,  // REPORT_SIZE (08)
  431.             0x95,0x01,  // REPORT_COUNT (01)
  432.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  433.             0x09,0x75,  // USAGE (Ramp Start)
  434.             0x09,0x76,  // USAGE (Ramp End)
  435.             0x15,0x80,  // LOGICAL_MINIMUM (-128)
  436.             0x25,0x7F,  // LOGICAL_MAXIMUM (127)
  437.             //0x15,0x00,
  438.             //0x25,0xff,
  439.             0x36,0xF0,0xD8, // PHYSICAL_MINIMUM (-10000)
  440.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  441.             0x75,0x08,  // REPORT_SIZE (08)
  442.             0x95,0x02,  // REPORT_COUNT (02)
  443.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  444.             0xC0,   // END COLLECTION ()
  445.            
  446.             0x09,0x68,  // USAGE (Custom Force Data Report)
  447.             0xA1,0x02,  // COLLECTION (Logical)
  448.             0x85,0x07,  // REPORT_ID (07)
  449.             0x09,0x22,  // USAGE (Effect Block Index)
  450.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  451.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  452.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  453.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  454.             0x75,0x08,  // REPORT_SIZE (08)
  455.             0x95,0x01,  // REPORT_COUNT (01)
  456.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  457.             0x09,0x6C,  // USAGE (Custom Force Data Offset)
  458.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  459.             0x26,0x10,0x27, // LOGICAL_MAXIMUM (10000)
  460.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  461.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  462.             0x75,0x10,  // REPORT_SIZE (10)
  463.             0x95,0x01,  // REPORT_COUNT (01)
  464.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  465.             0x09,0x69,  // USAGE (Custom Force Data)
  466.             0x15,0x81,  // LOGICAL_MINIMUM (-127)
  467.             0x25,0x7F,  // LOGICAL_MAXIMUM (127)
  468.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  469.             0x46,0xFF,0x00, // PHYSICAL_MAXIMUM (255)
  470.             0x75,0x08,  // REPORT_SIZE (08)
  471.             0x95,0x0C,  // REPORT_COUNT (0C)
  472.             0x92,0x02,0x01, // OUTPUT ( Data,Var,Abs,Buf)
  473.             0xC0,   // END COLLECTION ()
  474.            
  475.             0x09,0x66,  // USAGE (Download Force Sample)
  476.             0xA1,0x02,  // COLLECTION (Logical)
  477.             0x85,0x08,  // REPORT_ID (08)
  478.             0x05,0x01,  // USAGE_PAGE (Generic Desktop)
  479.             0x09,0x30,  // USAGE (X)
  480.             0x09,0x31,  // USAGE (Y)
  481.             0x15,0x81,  // LOGICAL_MINIMUM (-127)
  482.             0x25,0x7F,  // LOGICAL_MAXIMUM (127)
  483.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  484.             0x46,0xFF,0x00, // PHYSICAL_MAXIMUM (255)
  485.             0x75,0x08,  // REPORT_SIZE (08)
  486.             0x95,0x02,  // REPORT_COUNT (02)
  487.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  488.             0xC0,   // END COLLECTION ()
  489.            
  490.             0x05,0x0F,  // USAGE_PAGE (Physical Interface)
  491.             0x09,0x77,  // USAGE (Effect Operation Report)
  492.             0xA1,0x02,  // COLLECTION (Logical)
  493.             0x85,0x0A,  // REPORT_ID (0A)
  494.             0x09,0x22,  // USAGE (Effect Block Index)
  495.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  496.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  497.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  498.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  499.             0x75,0x08,  // REPORT_SIZE (08)
  500.             0x95,0x01,  // REPORT_COUNT (01)
  501.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  502.             0x09,0x78,  // USAGE (78)
  503.             0xA1,0x02,  // COLLECTION (Logical)
  504.             0x09,0x79,  // USAGE (Op Effect Start)
  505.             0x09,0x7A,  // USAGE (Op Effect Start Solo)
  506.             0x09,0x7B,  // USAGE (Op Effect Stop)
  507.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  508.             0x25,0x03,  // LOGICAL_MAXIMUM (03)
  509.             0x75,0x08,  // REPORT_SIZE (08)
  510.             0x95,0x01,  // REPORT_COUNT (01)
  511.             0x91,0x00,  // OUTPUT (Data,Ary,Abs)
  512.             0xC0,   // END COLLECTION ()
  513.             0x09,0x7C,  // USAGE (Loop Count)
  514.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  515.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  516.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  517.             0x46,0xFF,0x00, // PHYSICAL_MAXIMUM (00 FF)
  518.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  519.             0xC0,   // END COLLECTION ()
  520.            
  521.             0x09,0x90,  // USAGE (PID Block Free Report)
  522.             0xA1,0x02,  // COLLECTION (Logical)
  523.             0x85,0x0B,  // REPORT_ID (0B)
  524.             0x09,0x22,  // USAGE (Effect Block Index)
  525.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  526.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  527.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  528.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  529.             0x75,0x08,  // REPORT_SIZE (08)
  530.             0x95,0x01,  // REPORT_COUNT (01)
  531.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  532.             0xC0,   // END COLLECTION ()
  533.            
  534.             0x09,0x96,  // USAGE (PID Device Control)
  535.             0xA1,0x02,  // COLLECTION (Logical)
  536.             0x85,0x0C,  // REPORT_ID (0C)
  537.             0x09,0x97,  // USAGE (DC Enable Actuators)
  538.             0x09,0x98,  // USAGE (DC Disable Actuators)
  539.             0x09,0x99,  // USAGE (DC Stop All Effects)
  540.             0x09,0x9A,  // USAGE (DC Device Reset)
  541.             0x09,0x9B,  // USAGE (DC Device Pause)
  542.             0x09,0x9C,  // USAGE (DC Device Continue)
  543.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  544.             0x25,0x06,  // LOGICAL_MAXIMUM (06)
  545.             0x75,0x08,  // REPORT_SIZE (08)
  546.             0x95,0x01,  // REPORT_COUNT (01)
  547.             0x91,0x00,  // OUTPUT (Data)
  548.             0xC0,   // END COLLECTION ()
  549.            
  550.             0x09,0x7D,  // USAGE (Device Gain Report)
  551.             0xA1,0x02,  // COLLECTION (Logical)
  552.             0x85,0x0D,  // REPORT_ID (0D)
  553.             0x09,0x7E,  // USAGE (Device Gain)
  554.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  555.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  556.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  557.             0x46,0x10,0x27, // PHYSICAL_MAXIMUM (10000)
  558.             0x75,0x08,  // REPORT_SIZE (08)
  559.             0x95,0x01,  // REPORT_COUNT (01)
  560.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  561.             0xC0,   // END COLLECTION ()
  562.            
  563.             0x09,0x6B,  // USAGE (Set Custom Force Report)
  564.             0xA1,0x02,  // COLLECTION (Logical)
  565.             0x85,0x0E,  // REPORT_ID (0E)
  566.             0x09,0x22,  // USAGE (Effect Block Index)
  567.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  568.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  569.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  570.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  571.             0x75,0x08,  // REPORT_SIZE (08)
  572.             0x95,0x01,  // REPORT_COUNT (01)
  573.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  574.             0x09,0x6D,  // USAGE (Sample Count)
  575.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  576.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  577.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  578.             0x46,0xFF,0x00, // PHYSICAL_MAXIMUM (00 FF)
  579.             0x75,0x08,  // REPORT_SIZE (08)
  580.             0x95,0x01,  // REPORT_COUNT (01)
  581.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  582.             0x09,0x51,  // USAGE (Sample Period)
  583.             0x66,0x03,0x10, // UNIT (Eng Lin:Time)
  584.             0x55,0xFD,  // UNIT_EXPONENT (-3)
  585.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  586.             0x26,0xFF,0x7F, // LOGICAL_MAXIMUM (32767)
  587.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  588.             0x46,0xFF,0x7F, // PHYSICAL_MAXIMUM (32767)
  589.             0x75,0x10,  // REPORT_SIZE (10)
  590.             0x95,0x01,  // REPORT_COUNT (01)
  591.             0x91,0x02,  // OUTPUT (Data,Var,Abs)
  592.             0x55,0x00,  // UNIT_EXPONENT (00)
  593.             0x66,0x00,0x00, // UNIT (None)
  594.             0xC0,   // END COLLECTION ()
  595.            
  596.             0x09,0xAB,  // USAGE (Create New Effect Report)
  597.             0xA1,0x02,  // COLLECTION (Logical)
  598.             0x85,0x05,  // REPORT_ID (05)
  599.             0x09,0x25,  // USAGE (Effect Type)
  600.             0xA1,0x02,  // COLLECTION (Logical)
  601.             0x09,0x26,  // USAGE (26)
  602.             0x09,0x27,  // USAGE (27)
  603.             0x09,0x30,  // USAGE (30)
  604.             0x09,0x31,  // USAGE (31)
  605.             0x09,0x32,  // USAGE (32)
  606.             0x09,0x33,  // USAGE (33)
  607.             0x09,0x34,  // USAGE (34)
  608.             0x09,0x40,  // USAGE (40)
  609.             0x09,0x41,  // USAGE (41)
  610.             0x09,0x42,  // USAGE (42)
  611.             0x09,0x43,  // USAGE (43)
  612.             0x09,0x28,  // USAGE (28)
  613.             0x25,0x0C,  // LOGICAL_MAXIMUM (0C)
  614.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  615.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  616.             0x45,0x0C,  // PHYSICAL_MAXIMUM (0C)
  617.             0x75,0x08,  // REPORT_SIZE (08)
  618.             0x95,0x01,  // REPORT_COUNT (01)
  619.             0xB1,0x00,  // FEATURE (Data)
  620.             0xC0,   // END COLLECTION ()
  621.             0x05,0x01,  // USAGE_PAGE (Generic Desktop)
  622.             0x09,0x3B,  // USAGE (Byte Count)
  623.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  624.             0x26,0xFF,0x01, // LOGICAL_MAXIMUM (511)
  625.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  626.             0x46,0xFF,0x01, // PHYSICAL_MAXIMUM (511)
  627.             0x75,0x0A,  // REPORT_SIZE (0A)
  628.             0x95,0x01,  // REPORT_COUNT (01)
  629.             0xB1,0x02,  // FEATURE (Data,Var,Abs)
  630.             0x75,0x06,  // REPORT_SIZE (06)
  631.             0xB1,0x01,  // FEATURE (Constant,Ary,Abs)
  632.             0xC0,   // END COLLECTION ()
  633.            
  634.             0x05,0x0F,  // USAGE_PAGE (Physical Interface)
  635.             0x09,0x89,  // USAGE (PID Block Load Report)
  636.             0xA1,0x02,  // COLLECTION (Logical)
  637.             0x85,0x06,  // REPORT_ID (06)
  638.             0x09,0x22,  // USAGE (Effect Block Index)
  639.             0x25,0x28,  // LOGICAL_MAXIMUM (28)
  640.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  641.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  642.             0x45,0x28,  // PHYSICAL_MAXIMUM (28)
  643.             0x75,0x08,  // REPORT_SIZE (08)
  644.             0x95,0x01,  // REPORT_COUNT (01)
  645.             0xB1,0x02,  // FEATURE (Data,Var,Abs)
  646.             0x09,0x8B,  // USAGE (Block Load Status)
  647.             0xA1,0x02,  // COLLECTION (Logical)
  648.             0x09,0x8C,  // USAGE (Block Load Success)
  649.             0x09,0x8D,  // USAGE (Block Load Full)
  650.             0x09,0x8E,  // USAGE (Block Load Error)
  651.             0x25,0x03,  // LOGICAL_MAXIMUM (03)
  652.             0x15,0x01,  // LOGICAL_MINIMUM (01)
  653.             0x35,0x01,  // PHYSICAL_MINIMUM (01)
  654.             0x45,0x03,  // PHYSICAL_MAXIMUM (03)
  655.             0x75,0x08,  // REPORT_SIZE (08)
  656.             0x95,0x01,  // REPORT_COUNT (01)
  657.             0xB1,0x00,  // FEATURE (Data)
  658.             0xC0,   // END COLLECTION ()
  659.             0x09,0xAC,  // USAGE (RAM Pool Available)
  660.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  661.             0x27,0xFF,0xFF,0x00,0x00,   // LOGICAL_MAXIMUM (00 00 FF FF)
  662.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  663.             0x47,0xFF,0xFF,0x00,0x00,   // PHYSICAL_MAXIMUM (00 00 FF FF)
  664.             0x75,0x10,  // REPORT_SIZE (10)
  665.             0x95,0x01,  // REPORT_COUNT (01)
  666.             0xB1,0x00,  // FEATURE (Data)
  667.             0xC0,   // END COLLECTION ()
  668.            
  669.             0x09,0x7F,  // USAGE (PID Pool Report)
  670.             0xA1,0x02,  // COLLECTION (Logical)
  671.             0x85,0x07,  // REPORT_ID (07)
  672.             0x09,0x80,  // USAGE (RAM Pool Size)
  673.             0x75,0x10,  // REPORT_SIZE (10)
  674.             0x95,0x01,  // REPORT_COUNT (01)
  675.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  676.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  677.             0x27,0xFF,0xFF,0x00,0x00,   // LOGICAL_MAXIMUM (00 00 FF FF)
  678.             0x47,0xFF,0xFF,0x00,0x00,   // PHYSICAL_MAXIMUM (00 00 FF FF)
  679.             0xB1,0x02,  // FEATURE (Data,Var,Abs)
  680.             0x09,0x83,  // USAGE (Simultaneous Effects Max)
  681.             0x26,0xFF,0x00, // LOGICAL_MAXIMUM (00 FF)
  682.             0x46,0xFF,0x00, // PHYSICAL_MAXIMUM (00 FF)
  683.             0x75,0x08,  // REPORT_SIZE (08)
  684.             0x95,0x01,  // REPORT_COUNT (01)
  685.             0xB1,0x02,  // FEATURE (Data,Var,Abs)
  686.             0x09,0xA9,  // USAGE (Device Managed Pool)
  687.             0x09,0xAA,  // USAGE (Shared Parameter Blocks)
  688.             0x75,0x01,  // REPORT_SIZE (01)
  689.             0x95,0x02,  // REPORT_COUNT (02)
  690.             0x15,0x00,  // LOGICAL_MINIMUM (00)
  691.             0x25,0x01,  // LOGICAL_MAXIMUM (01)
  692.             0x35,0x00,  // PHYSICAL_MINIMUM (00)
  693.             0x45,0x01,  // PHYSICAL_MAXIMUM (01)
  694.             0xB1,0x02,  // FEATURE (Data,Var,Abs)
  695.             0x75,0x06,  // REPORT_SIZE (06)
  696.             0x95,0x01,  // REPORT_COUNT (01)
  697.             0xB1,0x03,  // FEATURE ( Cnst,Var,Abs)
  698.             0xC0,   // END COLLECTION ()
  699.            
  700.     0xc0,                          // END_COLLECTION
  701.    
  702.  
  703.      
  704.      
  705.    
  706.    
  707. };
  708.  
  709. /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
  710.  *  device characteristics, including the supported USB version, control endpoint size and the
  711.  *  number of device configurations. The descriptor is read out by the USB host when the enumeration
  712.  *  process begins.
  713.  */
  714. const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
  715. {
  716.     .Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
  717.  
  718.     .USBSpecification       = VERSION_BCD(1,1,0),
  719.     .Class                  = USB_CSCP_NoDeviceClass,
  720.     .SubClass               = USB_CSCP_NoDeviceSubclass,
  721.     .Protocol               = USB_CSCP_NoDeviceProtocol,
  722.  
  723.     .Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE,
  724.  
  725.     .VendorID               = 0x03EB,
  726.     .ProductID              = 0x2043,
  727.     .ReleaseNumber          = VERSION_BCD(0,0,1),
  728.  
  729.     .ManufacturerStrIndex   = STRING_ID_Manufacturer,
  730.     .ProductStrIndex        = STRING_ID_Product,
  731.     .SerialNumStrIndex      = NO_DESCRIPTOR,
  732.  
  733.     .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
  734. };
  735.  
  736. /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
  737.  *  of the device in one of its supported configurations, including information about any device interfaces
  738.  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
  739.  *  a configuration so that the host may correctly communicate with the USB device.
  740.  */
  741. const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
  742. {
  743.     .Config =
  744.         {
  745.             .Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
  746.  
  747.             .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
  748.             .TotalInterfaces        = 1,
  749.  
  750.             .ConfigurationNumber    = 1,
  751.             .ConfigurationStrIndex  = NO_DESCRIPTOR,
  752.  
  753.             .ConfigAttributes       = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
  754.  
  755.             .MaxPowerConsumption    = USB_CONFIG_POWER_MA(100)
  756.         },
  757.  
  758.     .HID_Interface =
  759.         {
  760.             .Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
  761.  
  762.             .InterfaceNumber        = INTERFACE_ID_Joystick,
  763.             .AlternateSetting       = 0x00,
  764.  
  765.             .TotalEndpoints         = 1,
  766.  
  767.             .Class                  = HID_CSCP_HIDClass,
  768.             .SubClass               = HID_CSCP_NonBootSubclass,
  769.             .Protocol               = HID_CSCP_NonBootProtocol,
  770.  
  771.             .InterfaceStrIndex      = NO_DESCRIPTOR
  772.         },
  773.  
  774.     .HID_JoystickHID =
  775.         {
  776.             .Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
  777.  
  778.             .HIDSpec                = VERSION_BCD(1,1,1),
  779.             .CountryCode            = 0x00,
  780.             .TotalReportDescriptors = 1,
  781.             .HIDReportType          = HID_DTYPE_Report,
  782.             .HIDReportLength        = sizeof(JoystickReport)
  783.         },
  784.  
  785.     .HID_ReportINEndpoint =
  786.         {
  787.             .Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
  788.  
  789.             .EndpointAddress        = JOYSTICK_EPADDR,
  790.             .Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  791.             .EndpointSize           = JOYSTICK_EPSIZE,
  792.             .PollingIntervalMS      = 0x05
  793.         }
  794. };
  795.  
  796. /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
  797.  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
  798.  *  via the language ID table available at USB.org what languages the device supports for its string descriptors.
  799.  */
  800. const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG);
  801.  
  802. /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
  803.  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
  804.  *  Descriptor.
  805.  */
  806. const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR(L"MetalGear Honk");
  807.  
  808. /** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
  809.  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
  810.  *  Descriptor.
  811.  */
  812. const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"Big Block");
  813.  
  814. /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
  815.  *  documentation) by the application code so that the address and size of a requested descriptor can be given
  816.  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
  817.  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
  818.  *  USB host.
  819.  */
  820. uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
  821.                                     const uint8_t wIndex,
  822.                                     const void** const DescriptorAddress)
  823. {
  824.     const uint8_t  DescriptorType   = (wValue >> 8);
  825.     const uint8_t  DescriptorNumber = (wValue & 0xFF);
  826.  
  827.     const void* Address = NULL;
  828.     uint16_t    Size    = NO_DESCRIPTOR;
  829.  
  830.     switch (DescriptorType)
  831.     {
  832.         case DTYPE_Device:
  833.             Address = &DeviceDescriptor;
  834.             Size    = sizeof(USB_Descriptor_Device_t);
  835.             break;
  836.         case DTYPE_Configuration:
  837.             Address = &ConfigurationDescriptor;
  838.             Size    = sizeof(USB_Descriptor_Configuration_t);
  839.             break;
  840.         case DTYPE_String:
  841.             switch (DescriptorNumber)
  842.             {
  843.                 case STRING_ID_Language:
  844.                     Address = &LanguageString;
  845.                     Size    = pgm_read_byte(&LanguageString.Header.Size);
  846.                     break;
  847.                 case STRING_ID_Manufacturer:
  848.                     Address = &ManufacturerString;
  849.                     Size    = pgm_read_byte(&ManufacturerString.Header.Size);
  850.                     break;
  851.                 case STRING_ID_Product:
  852.                     Address = &ProductString;
  853.                     Size    = pgm_read_byte(&ProductString.Header.Size);
  854.                     break;
  855.             }
  856.  
  857.             break;
  858.         case DTYPE_HID:
  859.             Address = &ConfigurationDescriptor.HID_JoystickHID;
  860.             Size    = sizeof(USB_HID_Descriptor_HID_t);
  861.             break;
  862.         case DTYPE_Report:
  863.             Address = &JoystickReport;
  864.             Size    = sizeof(JoystickReport);
  865.             break;
  866.     }
  867.  
  868.     *DescriptorAddress = Address;
  869.     return Size;
  870. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement