Fork to support Mouse boot protocol and steam controllers.

Fork of USBHOST by ST

Revision:
7:cc595e523032
Parent:
5:fc157e6bd5a5
Child:
8:e57ccb876952
--- a/USBHostHID/USBHostMouse.cpp	Wed Apr 26 20:08:31 2017 +0000
+++ b/USBHostHID/USBHostMouse.cpp	Thu Aug 17 22:08:04 2017 +0000
@@ -95,10 +95,37 @@
 
 void USBHostMouse::rxHandler() {
     int len_listen = int_in->getLengthTransferred();
+    int buttons_t, x_t, y_t, z_t;
+/*    {
+        int index;
+        for (index=0;index < len_listen; index++)
+        {
+            printf("%2x ",report[index]);
+        }
+        
+        if (index>0) printf("  %x:%x \r\n",dev->getVid(), dev->getPid());
+    }*/
+    
+    // We really should be parsing the pid report but this is a good workaround 
+    // for my wireless mouse for now!
+    if (dev->getVid() == 0x62a &&  dev->getPid() == 0x4101)
+    {
+        buttons_t = report[1] & 0x07;
+        x_t = report[2];
+        y_t = report[3] >> 4;
+        z_t = report[4];
+    }
+    else
+    {
+        buttons_t = report[0] & 0x07;
+        x_t = report[1];
+        y_t = report[2];
+        z_t = report[3];
+    }
     if (len_listen !=0) {
 
         if (onUpdate) {
-            (*onUpdate)(report[0] & 0x07, report[1], report[2], report[3]);
+            (*onUpdate)(buttons_t & 0x07, x_t, y_t, z_t);
         }
 
         if (onButtonUpdate && (buttons != (report[0] & 0x07))) {
@@ -106,22 +133,22 @@
         }
 
         if (onXUpdate && (x != report[1])) {
-            (*onXUpdate)(report[1]);
+            (*onXUpdate)(x_t);
         }
 
         if (onYUpdate && (y != report[2])) {
-            (*onYUpdate)(report[2]);
+            (*onYUpdate)(y_t);
         }
 
         if (onZUpdate && (z != report[3])) {
-            (*onZUpdate)(report[3]);
+            (*onZUpdate)(z_t);
         }
 
         // update mouse state
-        buttons = report[0] & 0x07;
-        x = report[1];
-        y = report[2];
-        z = report[3];
+        buttons = buttons_t;
+        x = x_t;
+        y = y_t;
+        z = z_t;
     }
     /*  set again the maximum value */
     len_listen = int_in->getSize();