USBJoystick updated for 32 buttons and added wait-for-connect.

Dependents:   joy2

Revision:
1:f44ae6479bfe
Parent:
0:e086541742c3
Child:
2:de0ca539fa79
--- a/USBJoystick.cpp	Thu Jan 05 14:22:02 2017 +0000
+++ b/USBJoystick.cpp	Sun Jul 25 18:01:15 2021 +0000
@@ -47,6 +47,8 @@
    report.data[1] = _r & 0xff;               
    report.data[2] = _x & 0xff;            
    report.data[3] = _y & 0xff;
+   report.data[4] = _x & 0xff;            
+   report.data[5] = _y & 0xff;
 
 
 #if (BUTTONS4 == 1)               
@@ -81,14 +83,14 @@
 
 #if (BUTTONS32 == 1)               
 //Use 4 bit padding for hat4 or hat8
-   report.data[4] = (_hat & 0x0f) ;
+   report.data[6] = (_hat & 0x0f) ;
 
 //No bit padding for 32 buttons                                         
-   report.data[5] = (_buttons >>  0) & 0xff;
-   report.data[6] = (_buttons >>  8) & 0xff;
-   report.data[7] = (_buttons >> 16) & 0xff;
-   report.data[8] = (_buttons >> 24) & 0xff;
-   report.length = 9;
+   report.data[7] = (_buttons >>  0) & 0xff;
+   report.data[8] = (_buttons >>  8) & 0xff;
+   report.data[9] = (_buttons >> 16) & 0xff;
+   report.data[10] = (_buttons >> 24) & 0xff;
+   report.length = 11;
 #endif
        
    return send(&report);
@@ -151,11 +153,13 @@
                COLLECTION(1), 0x00,            // Physical
                  USAGE(1), 0x30,                 // X
                  USAGE(1), 0x31,                 // Y
+                 USAGE(1), 0x32,                 // Z
+                 USAGE(1), 0x33,                 // RX
 //  8 bit values
                  LOGICAL_MINIMUM(1), 0x81,       // -127
                  LOGICAL_MAXIMUM(1), 0x7f,       // 127
                  REPORT_SIZE(1), 0x08,
-                 REPORT_COUNT(1), 0x02,
+                 REPORT_COUNT(1), 0x04,
                  INPUT(1), 0x02,                 // Data, Variable, Absolute                  
 // 16 bit values
 //                 LOGICAL_MINIMUM(1), 0x00,       // 0