2018.07.26

Dependencies:   FATFileSystem2 mbed-rtos

Fork of USBHost by mbed official

Files at this revision

API Documentation at this revision

Comitter:
sayzyas
Date:
Thu Jun 18 08:05:23 2015 +0000
Parent:
32:e6717a485577
Child:
34:cac1e8336448
Commit message:
2015.06.18; ;

Changed in this revision

USBHostHID/USBHostGamepad.cpp Show annotated file Show diff for this revision Revisions of this file
USBHostHID/USBHostGamepad.h Show annotated file Show diff for this revision Revisions of this file
--- a/USBHostHID/USBHostGamepad.cpp	Tue Jun 02 05:57:44 2015 +0000
+++ b/USBHostHID/USBHostGamepad.cpp	Thu Jun 18 08:05:23 2015 +0000
@@ -37,10 +37,30 @@
     gamepad_device_found = false;
     gamepad_intf = -1;
 
+
     btnX = 0;
     btnY = 0;
     btnABCD = 0;
     btnSpecial = 0;
+
+    btn00 = 0;
+    btn01 = 1;
+    btn02 = 2;
+    btn03 = 3;
+    btn04 = 4;
+    btn05 = 5;
+    btn06 = 6;
+    btn07 = 7;
+    btn08 = 8;
+    btn09 = 9;
+    btn01 = 10;
+    btn11 = 11;
+    btn12 = 12;
+    btn13 = 13;
+    btn14 = 14;
+    btn15 = 15;
+    
+
 }
 
 bool USBHostGamepad::connected() {
@@ -92,6 +112,7 @@
 
 void USBHostGamepad::rxHandler() {
     int len_listen = int_in->getSize();
+//    printf("GamePad Length=%dyryn", len_listen);
 #if DEBUG > 3
     USB_DBG("USBHostGamepad::rxHandler() len_listen=%d\r\n", len_listen);
       for (int i = 0; i < len_listen; i++)
@@ -99,14 +120,48 @@
       printf("\r\n\r\n");
 #endif
     if (onUpdate) {
-        (*onUpdate)(report[0], report[1], report[5], report[6]);
+//        (*onUpdate)(report[0], report[1], report[5], report[6]);
+        (*onUpdate)(
+            report[0], 
+            report[1], 
+            report[2], 
+            report[3], 
+            report[4], 
+            report[5], 
+            report[6], 
+            report[7], 
+            report[8], 
+            report[9], 
+            report[10], 
+            report[11], 
+            report[12],
+            report[13],
+            report[14],
+            report[15]
+        );
     }
 
     // update gamepad state
-    btnX       = report[0];
-    btnY       = report[1];
-    btnABCD    = report[5];
-    btnSpecial = report[6];
+//   btnX       = report[0];
+//    btnY       = report[1];
+//    btnABCD    = report[5];
+//    btnSpecial = report[6];
+      btn00 = report[0];
+      btn01 = report[1];
+      btn02 = report[2];
+      btn03 = report[3];
+      btn04 = report[4];
+      btn05 = report[5];
+      btn06 = report[6];
+      btn07 = report[7];
+      btn08 = report[8];
+      btn09 = report[9];
+      btn10 = report[10];
+      btn11 = report[11];
+      btn12 = report[12];
+      btn13 = report[13];
+      btn14 = report[14];
+      btn15 = report[15];
 
     if (len_listen > sizeof(report)) {
         len_listen = sizeof(report);
@@ -183,9 +238,9 @@
     && buf[2] == 0x09 //Usage
     ){
         if( buf[3] == 0x04 ){
-            USB_DBG("GAMEPAD");
+            USB_DBG("ゲームパッドです:");
         }else if( buf[3] == 0x05){
-            USB_DBG("JOYSTICK");
+            USB_DBG("ジョイスティックです:");
         }else{
             ret = false;
         }
--- a/USBHostHID/USBHostGamepad.h	Tue Jun 02 05:57:44 2015 +0000
+++ b/USBHostHID/USBHostGamepad.h	Thu Jun 18 08:05:23 2015 +0000
@@ -67,7 +67,8 @@
      *
      * @param ptr function pointer
      */
-    inline void attachEvent(void (*ptr)(uint8_t btnX, uint8_t btnY, uint8_t btnABCD, uint8_t btnSpecial)) {
+//    inline void attachEvent(void (*ptr)(uint8_t btnX, uint8_t btnY, uint8_t btnABCD, uint8_t btnSpecial)) {
+    inline void attachEvent(void (*ptr)(uint8_t btn00, uint8_t btn01, uint8_t btn02, uint8_t btn03, uint8_t btn04, uint8_t btn05, uint8_t btn06, uint8_t btn07, uint8_t btn08, uint8_t btn09, uint8_t btn10, uint8_t btn11, uint8_t btn12, uint8_t btn13, uint8_t btn14, uint8_t btn15)) {
         if (ptr != NULL) {
             onUpdate = ptr;
         }
@@ -93,7 +94,8 @@
     USBHost * host;
     USBDeviceConnected * dev;
     USBEndpoint * int_in;
-    uint8_t report[8];
+//    uint8_t report[8];
+    uint8_t report[16];
 
     bool dev_connected;
     bool gamepad_device_found;
@@ -104,8 +106,28 @@
     uint8_t btnABCD;
     uint8_t btnSpecial;
 
+    uint8_t btn00;
+    uint8_t btn01;
+    uint8_t btn02;
+    uint8_t btn03;
+    uint8_t btn04;
+    uint8_t btn05;
+    uint8_t btn06;
+    uint8_t btn07;
+    uint8_t btn08;
+    uint8_t btn09;
+    uint8_t btn10;
+    uint8_t btn11;
+    uint8_t btn12;
+    uint8_t btn13;
+    uint8_t btn14;
+    uint8_t btn15;
+        
+
     void rxHandler();
-    void (*onUpdate)(uint8_t btnX, uint8_t btnY, uint8_t btnABCD, uint8_t btnSpecial);
+//    void (*onUpdate)(uint8_t btnX, uint8_t btnY, uint8_t btnABCD, uint8_t btnSpecial);
+    void (*onUpdate)(uint8_t btn00, uint8_t btn01, uint8_t btn02, uint8_t btn03, uint8_t btn04, uint8_t btn05, uint8_t btn06, uint8_t btn07, uint8_t btn08, uint8_t btn09, uint8_t btn10, uint8_t btn11, uint8_t btn12, uint8_t btn13,uint8_t btn14,uint8_t btn15 );
+    
     int report_id;
     void init();
     bool parseHidDescr();