Commits

Andrew Cooper committed b81bca2

Fix HID reporting

  • Participants
  • Parent commits 80da7fa

Comments (0)

Files changed (4)

 volatile uint8_t cpt_sof = 0;
 extern uint8_t jump_bootloader;
 uint8_t g_last_joy = 0;
-
+int report_cnt = 0;
 struct hid_report report;
 
 //_____ D E F I N I T I O N S __________________________________________________
     Usb_select_endpoint(EP_HID_IN);
     if( !Is_usb_write_enabled() )
         return; // Not ready to send report
+
+    ++report_cnt;
+    report.buttons.raw = (0x1FFF & report_cnt);
 
     for( i = 0; i < sizeof( report ); ++i )
     {
-
+        Usb_write_byte( report_p[i] ); // Joystick
     }
-    // Send report
-    Usb_write_byte(g_last_joy); // Joystick
-    Usb_write_byte(GPIOR1); // Dummy (not used)
-    Usb_write_byte(GPIOR1); // Dummy (not used)
-    Usb_write_byte(GPIOR1); // Dummy (not used)
-    Usb_write_byte(GPIOR1); // Dummy (not used)
-    Usb_write_byte(GPIOR1); // Dummy (not used)
-    Usb_write_byte(GPIOR1); // Dummy (not used)
-    Usb_write_byte(GPIOR1); // Dummy (not used)
 
     Usb_ack_in_ready(); // Send data over the USB
 }
     /*
      * Inputs, 1bit * 13
      * Usage: Generic Desktop / Gamepad / Button
-     */
-    uint8_t b1 :1;
-    uint8_t b2 :1;
-    uint8_t b3 :1;
-    uint8_t b4 :1;
-    uint8_t b5 :1;
-    uint8_t b6 :1;
-    uint8_t b7 :1;
-    uint8_t b8 :1;
-    uint8_t b9 :1;
-    uint8_t b10 :1;
-    uint8_t b11 :1;
-    uint8_t b12 :1;
-    uint8_t b13 :1;
+     */
+    union
+    {
+        struct
+        {
+        uint8_t b1 :1;
+        uint8_t b2 :1;
+        uint8_t b3 :1;
+        uint8_t b4 :1;
+        uint8_t b5 :1;
+        uint8_t b6 :1;
+        uint8_t b7 :1;
+        uint8_t b8 :1;
+        uint8_t b9 :1;
+        uint8_t b10 :1;
+        uint8_t b11 :1;
+        uint8_t b12 :1;
+        uint8_t b13 :1;
 
-    /*
-     * Padding, 1bit * 3
-     */
-    uint8_t pad1 :3;
+        /*
+         * Padding, 1bit * 3
+         */
+        uint8_t pad1 :3;
+        } bits;
+
+        uint16_t raw;
+    } buttons;
 
     /*
      * Inputs: 4bit * 1

File usb_descriptors.h

 #define EP_ATTRIBUTES_2     0x03          // BULK = 0x02, INTERUPT = 0x03
 #define EP_SIZE_2           64
 #define EP_INTERVAL_2       1 //interrupt pooling from host
-#define SIZE_OF_REPORT        156
+#define SIZE_OF_REPORT        137
 
 #define DEVICE_STATUS         USB_DEVICE_STATUS_BUS_POWERED
 

File usb_specific_request.c

     usb_configure_endpoint( EP_HID_IN,
         TYPE_INTERRUPT,
         DIRECTION_IN,
-        SIZE_8,
+        SIZE_64,
         ONE_BANK,
         NYET_ENABLED);
 
     usb_configure_endpoint( EP_HID_OUT,
         TYPE_INTERRUPT,
         DIRECTION_OUT,
-        SIZE_8,
+        SIZE_64,
         ONE_BANK,
         NYET_ENABLED);
 }