XOOMの動作状況を聞き処理を変えてみました。 USBケーブルを抜いた際に処理を終了するようにしました。

Dependencies:   mbed

Committer:
abe00makoto
Date:
Wed May 25 09:34:38 2011 +0000
Revision:
0:9fb6c423e32c
Child:
2:a05c7cbe396f
support ADK

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abe00makoto 0:9fb6c423e32c 1 /*
abe00makoto 0:9fb6c423e32c 2 Copyright (c) 2010 Peter Barrett
abe00makoto 0:9fb6c423e32c 3
abe00makoto 0:9fb6c423e32c 4 Permission is hereby granted, free of charge, to any person obtaining a copy
abe00makoto 0:9fb6c423e32c 5 of this software and associated documentation files (the "Software"), to deal
abe00makoto 0:9fb6c423e32c 6 in the Software without restriction, including without limitation the rights
abe00makoto 0:9fb6c423e32c 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
abe00makoto 0:9fb6c423e32c 8 copies of the Software, and to permit persons to whom the Software is
abe00makoto 0:9fb6c423e32c 9 furnished to do so, subject to the following conditions:
abe00makoto 0:9fb6c423e32c 10
abe00makoto 0:9fb6c423e32c 11 The above copyright notice and this permission notice shall be included in
abe00makoto 0:9fb6c423e32c 12 all copies or substantial portions of the Software.
abe00makoto 0:9fb6c423e32c 13
abe00makoto 0:9fb6c423e32c 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
abe00makoto 0:9fb6c423e32c 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
abe00makoto 0:9fb6c423e32c 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
abe00makoto 0:9fb6c423e32c 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
abe00makoto 0:9fb6c423e32c 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
abe00makoto 0:9fb6c423e32c 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
abe00makoto 0:9fb6c423e32c 20 THE SOFTWARE.
abe00makoto 0:9fb6c423e32c 21 */
abe00makoto 0:9fb6c423e32c 22
abe00makoto 0:9fb6c423e32c 23 /*
abe00makoto 0:9fb6c423e32c 24 Tue Apr 26 2011 Bart Janssens: added PS3 USB support
abe00makoto 0:9fb6c423e32c 25 */
abe00makoto 0:9fb6c423e32c 26
abe00makoto 0:9fb6c423e32c 27 #include <stdio.h>
abe00makoto 0:9fb6c423e32c 28 #include <stdlib.h>
abe00makoto 0:9fb6c423e32c 29 #include <stdio.h>
abe00makoto 0:9fb6c423e32c 30 #include <string.h>
abe00makoto 0:9fb6c423e32c 31
abe00makoto 0:9fb6c423e32c 32 #include "USBHost.h"
abe00makoto 0:9fb6c423e32c 33 #include "Utils.h"
abe00makoto 0:9fb6c423e32c 34 #include "ps3.h"
abe00makoto 0:9fb6c423e32c 35 #include "ADK.h"
abe00makoto 0:9fb6c423e32c 36
abe00makoto 0:9fb6c423e32c 37 #define AUTOEVT(_class,_subclass,_protocol) (((_class) << 16) | ((_subclass) << 8) | _protocol)
abe00makoto 0:9fb6c423e32c 38 #define AUTO_KEYBOARD AUTOEVT(CLASS_HID,1,1)
abe00makoto 0:9fb6c423e32c 39 #define AUTO_MOUSE AUTOEVT(CLASS_HID,1,2)
abe00makoto 0:9fb6c423e32c 40 //#define AUTO_PS3 AUTOEVT(CLASS_HID,0,0)
abe00makoto 0:9fb6c423e32c 41
abe00makoto 0:9fb6c423e32c 42 u8 auto_mouse[4]; // buttons,dx,dy,scroll
abe00makoto 0:9fb6c423e32c 43 u8 auto_keyboard[8]; // modifiers,reserved,keycode1..keycode6
abe00makoto 0:9fb6c423e32c 44 u8 auto_joystick[4]; // x,y,buttons,throttle
abe00makoto 0:9fb6c423e32c 45 //u8 auto_ps3[48];
abe00makoto 0:9fb6c423e32c 46
abe00makoto 0:9fb6c423e32c 47
abe00makoto 0:9fb6c423e32c 48
abe00makoto 0:9fb6c423e32c 49
abe00makoto 0:9fb6c423e32c 50 void AutoEventCallback(int device, int endpoint, int status, u8* data, int len, void* userData) {
abe00makoto 0:9fb6c423e32c 51 int evt = (int)userData;
abe00makoto 0:9fb6c423e32c 52 switch (evt) {
abe00makoto 0:9fb6c423e32c 53 case AUTO_KEYBOARD:
abe00makoto 0:9fb6c423e32c 54 printf("AUTO_KEYBOARD ");
abe00makoto 0:9fb6c423e32c 55 break;
abe00makoto 0:9fb6c423e32c 56 case AUTO_MOUSE:
abe00makoto 0:9fb6c423e32c 57 printf("AUTO_MOUSE ");
abe00makoto 0:9fb6c423e32c 58 break;
abe00makoto 0:9fb6c423e32c 59 // case AUTO_PS3:
abe00makoto 0:9fb6c423e32c 60 // printf("AUTO_PS3 ");
abe00makoto 0:9fb6c423e32c 61 // ParsePs3Report(data,len);
abe00makoto 0:9fb6c423e32c 62 // break;
abe00makoto 0:9fb6c423e32c 63 default:
abe00makoto 0:9fb6c423e32c 64 printf("HUH ");
abe00makoto 0:9fb6c423e32c 65 }
abe00makoto 0:9fb6c423e32c 66 //printfBytes("data",data,len);
abe00makoto 0:9fb6c423e32c 67 USBInterruptTransfer(device,endpoint,data,len,AutoEventCallback,userData);
abe00makoto 0:9fb6c423e32c 68 }
abe00makoto 0:9fb6c423e32c 69
abe00makoto 0:9fb6c423e32c 70 // Establish transfers for interrupt events
abe00makoto 0:9fb6c423e32c 71 void AddAutoEvent(int device, InterfaceDescriptor* id, EndpointDescriptor* ed) {
abe00makoto 0:9fb6c423e32c 72 printf("message from endpoint %02X\r\n",ed->bEndpointAddress);
abe00makoto 0:9fb6c423e32c 73 printf("Class Sub Proto: %02X %02X %02X\r\n",id->bInterfaceClass,id->bInterfaceSubClass,id->bInterfaceProtocol);
abe00makoto 0:9fb6c423e32c 74 //if ((ed->bmAttributes & 3) != ENDPOINT_INTERRUPT || !(ed->bEndpointAddress & 0x80))
abe00makoto 0:9fb6c423e32c 75 // return;
abe00makoto 0:9fb6c423e32c 76
abe00makoto 0:9fb6c423e32c 77 // Make automatic interrupt enpoints for known devices
abe00makoto 0:9fb6c423e32c 78 u32 evt = AUTOEVT(id->bInterfaceClass,id->bInterfaceSubClass,id->bInterfaceProtocol);
abe00makoto 0:9fb6c423e32c 79 printf("Evt: %08X \r\n",evt);
abe00makoto 0:9fb6c423e32c 80 u8* dst = 0;
abe00makoto 0:9fb6c423e32c 81 int len;
abe00makoto 0:9fb6c423e32c 82 switch (evt) {
abe00makoto 0:9fb6c423e32c 83 case AUTO_MOUSE:
abe00makoto 0:9fb6c423e32c 84 dst = auto_mouse;
abe00makoto 0:9fb6c423e32c 85 len = sizeof(auto_mouse);
abe00makoto 0:9fb6c423e32c 86 break;
abe00makoto 0:9fb6c423e32c 87 case AUTO_KEYBOARD:
abe00makoto 0:9fb6c423e32c 88 dst = auto_keyboard;
abe00makoto 0:9fb6c423e32c 89 len = sizeof(auto_keyboard);
abe00makoto 0:9fb6c423e32c 90 break;
abe00makoto 0:9fb6c423e32c 91 // case AUTO_PS3:
abe00makoto 0:9fb6c423e32c 92 // printf("PS3 event ? \r\n");
abe00makoto 0:9fb6c423e32c 93 // dst = auto_ps3;
abe00makoto 0:9fb6c423e32c 94 // len = sizeof(auto_ps3);
abe00makoto 0:9fb6c423e32c 95 default:
abe00makoto 0:9fb6c423e32c 96 printf("Interrupt endpoint %02X %08X\r\n",ed->bEndpointAddress,evt);
abe00makoto 0:9fb6c423e32c 97 break;
abe00makoto 0:9fb6c423e32c 98 }
abe00makoto 0:9fb6c423e32c 99 if (dst) {
abe00makoto 0:9fb6c423e32c 100 printf("Auto Event for %02X %08X\r\n",ed->bEndpointAddress,evt);
abe00makoto 0:9fb6c423e32c 101 USBInterruptTransfer(device,ed->bEndpointAddress,dst,len,AutoEventCallback,(void*)evt);
abe00makoto 0:9fb6c423e32c 102 }
abe00makoto 0:9fb6c423e32c 103 }
abe00makoto 0:9fb6c423e32c 104
abe00makoto 0:9fb6c423e32c 105 void PrintString(int device, int i) {
abe00makoto 0:9fb6c423e32c 106 u8 buffer[256];
abe00makoto 0:9fb6c423e32c 107 int le = GetDescriptor(device,DESCRIPTOR_TYPE_STRING,i,buffer,255);
abe00makoto 0:9fb6c423e32c 108 if (le < 0)
abe00makoto 0:9fb6c423e32c 109 return;
abe00makoto 0:9fb6c423e32c 110 char* dst = (char*)buffer;
abe00makoto 0:9fb6c423e32c 111 for (int j = 2; j < le; j += 2)
abe00makoto 0:9fb6c423e32c 112 *dst++ = buffer[j];
abe00makoto 0:9fb6c423e32c 113 *dst = 0;
abe00makoto 0:9fb6c423e32c 114 printf("%d:%s\r\n",i,(const char*)buffer);
abe00makoto 0:9fb6c423e32c 115 }
abe00makoto 0:9fb6c423e32c 116
abe00makoto 0:9fb6c423e32c 117 // Walk descriptors and create endpoints for a given device
abe00makoto 0:9fb6c423e32c 118 int StartAutoEvent(int device, int configuration, int interfaceNumber) {
abe00makoto 0:9fb6c423e32c 119
abe00makoto 0:9fb6c423e32c 120 printf("StartAutoEvent \r\n");
abe00makoto 0:9fb6c423e32c 121
abe00makoto 0:9fb6c423e32c 122 u8 buffer[255];
abe00makoto 0:9fb6c423e32c 123 int err = GetDescriptor(device,DESCRIPTOR_TYPE_CONFIGURATION,0,buffer,255);
abe00makoto 0:9fb6c423e32c 124 if (err < 0)
abe00makoto 0:9fb6c423e32c 125 return err;
abe00makoto 0:9fb6c423e32c 126
abe00makoto 0:9fb6c423e32c 127 int len = buffer[2] | (buffer[3] << 8);
abe00makoto 0:9fb6c423e32c 128 u8* d = buffer;
abe00makoto 0:9fb6c423e32c 129 u8* end = d + len;
abe00makoto 0:9fb6c423e32c 130 while (d < end) {
abe00makoto 0:9fb6c423e32c 131 if (d[1] == DESCRIPTOR_TYPE_INTERFACE) {
abe00makoto 0:9fb6c423e32c 132 InterfaceDescriptor* id = (InterfaceDescriptor*)d;
abe00makoto 0:9fb6c423e32c 133 if (id->bInterfaceNumber == interfaceNumber) {
abe00makoto 0:9fb6c423e32c 134 d += d[0];
abe00makoto 0:9fb6c423e32c 135 while (d < end && d[1] != DESCRIPTOR_TYPE_INTERFACE) {
abe00makoto 0:9fb6c423e32c 136 if (d[1] == DESCRIPTOR_TYPE_ENDPOINT)
abe00makoto 0:9fb6c423e32c 137 AddAutoEvent(device,id,(EndpointDescriptor*)d);
abe00makoto 0:9fb6c423e32c 138 d += d[0];
abe00makoto 0:9fb6c423e32c 139 }
abe00makoto 0:9fb6c423e32c 140 }
abe00makoto 0:9fb6c423e32c 141 }
abe00makoto 0:9fb6c423e32c 142 d += d[0];
abe00makoto 0:9fb6c423e32c 143 }
abe00makoto 0:9fb6c423e32c 144 return 0;
abe00makoto 0:9fb6c423e32c 145 }
abe00makoto 0:9fb6c423e32c 146
abe00makoto 0:9fb6c423e32c 147 /*
abe00makoto 0:9fb6c423e32c 148 int StartPS3Event(int device, int configuration, int interfaceNumber)
abe00makoto 0:9fb6c423e32c 149 {
abe00makoto 0:9fb6c423e32c 150
abe00makoto 0:9fb6c423e32c 151 printf("StartPS3Event \r\n");
abe00makoto 0:9fb6c423e32c 152
abe00makoto 0:9fb6c423e32c 153 EndpointDescriptor* ep;
abe00makoto 0:9fb6c423e32c 154
abe00makoto 0:9fb6c423e32c 155 u8 buf[4];
abe00makoto 0:9fb6c423e32c 156 buf[0] = 0x42;
abe00makoto 0:9fb6c423e32c 157 buf[1] = 0x0c;
abe00makoto 0:9fb6c423e32c 158 buf[2] = 0x00;
abe00makoto 0:9fb6c423e32c 159 buf[3] = 0x00;
abe00makoto 0:9fb6c423e32c 160
abe00makoto 0:9fb6c423e32c 161 u8 buf2[8];
abe00makoto 0:9fb6c423e32c 162 u8 buf3[8];
abe00makoto 0:9fb6c423e32c 163
abe00makoto 0:9fb6c423e32c 164 buf2[0] = 0x01;
abe00makoto 0:9fb6c423e32c 165 buf2[1] = 0x00;
abe00makoto 0:9fb6c423e32c 166 buf2[2] = 0x00;
abe00makoto 0:9fb6c423e32c 167 buf2[3] = 0x02;
abe00makoto 0:9fb6c423e32c 168 buf2[4] = 0x72;
abe00makoto 0:9fb6c423e32c 169 buf2[5] = 0xAD;
abe00makoto 0:9fb6c423e32c 170 buf2[6] = 0xF3;
abe00makoto 0:9fb6c423e32c 171 buf2[7] = 0x5B;
abe00makoto 0:9fb6c423e32c 172
abe00makoto 0:9fb6c423e32c 173
abe00makoto 0:9fb6c423e32c 174
abe00makoto 0:9fb6c423e32c 175
abe00makoto 0:9fb6c423e32c 176 int result;
abe00makoto 0:9fb6c423e32c 177 int err;
abe00makoto 0:9fb6c423e32c 178
abe00makoto 0:9fb6c423e32c 179 u8 buffer[255];
abe00makoto 0:9fb6c423e32c 180 err = GetDescriptor(device,DESCRIPTOR_TYPE_CONFIGURATION,0,buffer,255);
abe00makoto 0:9fb6c423e32c 181 if (err < 0)
abe00makoto 0:9fb6c423e32c 182 return err;
abe00makoto 0:9fb6c423e32c 183
abe00makoto 0:9fb6c423e32c 184
abe00makoto 0:9fb6c423e32c 185
abe00makoto 0:9fb6c423e32c 186 //configure the device
abe00makoto 0:9fb6c423e32c 187 //err = USBControlTransfer(device, HOST_TO_DEVICE|REQUEST_TYPE_STANDARD|RECIPIENT_DEVICE, SET_CONFIGURATION, 1, 0, 0, 0, 0, 0 );
abe00makoto 0:9fb6c423e32c 188 err = SetConfiguration(device,1);
abe00makoto 0:9fb6c423e32c 189 printf("set config result = %d\r\n", err);
abe00makoto 0:9fb6c423e32c 190
abe00makoto 0:9fb6c423e32c 191 // get Mac address
abe00makoto 0:9fb6c423e32c 192 //err = USBControlTransfer(device, HOST_TO_DEVICE|REQUEST_TYPE_CLASS|RECIPIENT_DEVICE, HID_REQUEST_GET_REPORT, 0x03f5, 0, buf3, sizeof(buf3), 0, 0 );
abe00makoto 0:9fb6c423e32c 193 //printf("get Mac to %02X:%02X:%02X:%02X:%02X:%02X , result = %d\r\n", buf3[2], buf3[3], buf3[4], buf3[5], buf3[6], buf3[7], err);
abe00makoto 0:9fb6c423e32c 194
abe00makoto 0:9fb6c423e32c 195 // set Mac address
abe00makoto 0:9fb6c423e32c 196 err = USBControlTransfer(device, HOST_TO_DEVICE|REQUEST_TYPE_CLASS|RECIPIENT_INTERFACE, HID_REQUEST_SET_REPORT, 0x03f5, 0, buf2, sizeof(buf2), 0, 0 );
abe00makoto 0:9fb6c423e32c 197 printf("set Mac to %02X:%02X:%02X:%02X:%02X:%02X , result = %d\r\n", buf2[2], buf2[3], buf2[4], buf2[5], buf2[6], buf2[7], err);
abe00makoto 0:9fb6c423e32c 198
abe00makoto 0:9fb6c423e32c 199 // get Mac address
abe00makoto 0:9fb6c423e32c 200 //err = USBControlTransfer(device, HOST_TO_DEVICE|REQUEST_TYPE_CLASS|RECIPIENT_DEVICE, HID_REQUEST_GET_REPORT, 0x03f5, 0, buf3, sizeof(buf3), 0, 0 );
abe00makoto 0:9fb6c423e32c 201 //printf("get Mac to %02X:%02X:%02X:%02X:%02X:%02X , result = %d\r\n", buf3[2], buf3[3], buf3[4], buf3[5], buf3[6], buf3[7], err);
abe00makoto 0:9fb6c423e32c 202
abe00makoto 0:9fb6c423e32c 203 err = USBControlTransfer(device, HOST_TO_DEVICE|REQUEST_TYPE_CLASS|RECIPIENT_INTERFACE, HID_REQUEST_SET_REPORT, 0x03f4,0, buf, sizeof(buf), 0, 0 );
abe00makoto 0:9fb6c423e32c 204 printf("set report result = %d\r\n", err);
abe00makoto 0:9fb6c423e32c 205 //USBTransfer(device,0,DEVICE_TO_HOST,buf,sizeof(buf),0,0);
abe00makoto 0:9fb6c423e32c 206
abe00makoto 0:9fb6c423e32c 207 int len = buffer[2] | (buffer[3] << 8);
abe00makoto 0:9fb6c423e32c 208 u8* d = buffer;
abe00makoto 0:9fb6c423e32c 209 u8* end = d + len;
abe00makoto 0:9fb6c423e32c 210 while (d < end)
abe00makoto 0:9fb6c423e32c 211 {
abe00makoto 0:9fb6c423e32c 212 if (d[1] == DESCRIPTOR_TYPE_INTERFACE)
abe00makoto 0:9fb6c423e32c 213 {
abe00makoto 0:9fb6c423e32c 214 InterfaceDescriptor* id = (InterfaceDescriptor*)d;
abe00makoto 0:9fb6c423e32c 215 if (id->bInterfaceNumber == interfaceNumber)
abe00makoto 0:9fb6c423e32c 216 {
abe00makoto 0:9fb6c423e32c 217 d += d[0];
abe00makoto 0:9fb6c423e32c 218 while (d < end && d[1] != DESCRIPTOR_TYPE_INTERFACE)
abe00makoto 0:9fb6c423e32c 219 {
abe00makoto 0:9fb6c423e32c 220 if (d[1] == DESCRIPTOR_TYPE_ENDPOINT)
abe00makoto 0:9fb6c423e32c 221 ep = (EndpointDescriptor*)d;
abe00makoto 0:9fb6c423e32c 222
abe00makoto 0:9fb6c423e32c 223 if (ep->bEndpointAddress == 0x02) {
abe00makoto 0:9fb6c423e32c 224 printf("PS3 input endpoint (0x02) found\r\n");
abe00makoto 0:9fb6c423e32c 225
abe00makoto 0:9fb6c423e32c 226 }
abe00makoto 0:9fb6c423e32c 227 if (ep->bEndpointAddress == 0x81) {
abe00makoto 0:9fb6c423e32c 228 printf("PS3 output endpoint (0x81) found\r\n");
abe00makoto 0:9fb6c423e32c 229 AddAutoEvent(device,id,(EndpointDescriptor*)d);
abe00makoto 0:9fb6c423e32c 230 }
abe00makoto 0:9fb6c423e32c 231 d += d[0];
abe00makoto 0:9fb6c423e32c 232 }
abe00makoto 0:9fb6c423e32c 233 }
abe00makoto 0:9fb6c423e32c 234 }
abe00makoto 0:9fb6c423e32c 235 d += d[0];
abe00makoto 0:9fb6c423e32c 236 }
abe00makoto 0:9fb6c423e32c 237 return 0;
abe00makoto 0:9fb6c423e32c 238 }
abe00makoto 0:9fb6c423e32c 239 */
abe00makoto 0:9fb6c423e32c 240
abe00makoto 0:9fb6c423e32c 241 // Implemented in main.cpp
abe00makoto 0:9fb6c423e32c 242 int OnDiskInsert(int device);
abe00makoto 0:9fb6c423e32c 243
abe00makoto 0:9fb6c423e32c 244 // Implemented in TestShell.cpp
abe00makoto 0:9fb6c423e32c 245 int OnBluetoothInsert(int device);
abe00makoto 0:9fb6c423e32c 246
abe00makoto 0:9fb6c423e32c 247 void OnLoadDevice(int device, DeviceDescriptor* deviceDesc, InterfaceDescriptor* interfaceDesc) {
abe00makoto 0:9fb6c423e32c 248 printf("LoadDevice %d %02X:%02X:%02X\r\n",device,interfaceDesc->bInterfaceClass,interfaceDesc->bInterfaceSubClass,interfaceDesc->bInterfaceProtocol);
abe00makoto 0:9fb6c423e32c 249 char s[128];
abe00makoto 0:9fb6c423e32c 250 u8 my_mac[6] = {0x00, 0x02, 0x72, 0xAD, 0xF3, 0x5B}; // mac address of my Bluetooth device
abe00makoto 0:9fb6c423e32c 251
abe00makoto 0:9fb6c423e32c 252 u8 buf2[6];
abe00makoto 0:9fb6c423e32c 253
abe00makoto 0:9fb6c423e32c 254 buf2[0] = 0x00;
abe00makoto 0:9fb6c423e32c 255 buf2[1] = 0x02;
abe00makoto 0:9fb6c423e32c 256 buf2[2] = 0x72;
abe00makoto 0:9fb6c423e32c 257 buf2[3] = 0xAD;
abe00makoto 0:9fb6c423e32c 258 buf2[4] = 0xF3;
abe00makoto 0:9fb6c423e32c 259 buf2[5] = 0x5B;
abe00makoto 0:9fb6c423e32c 260
abe00makoto 0:9fb6c423e32c 261
abe00makoto 0:9fb6c423e32c 262 for (int i = 1; i < 3; i++) {
abe00makoto 0:9fb6c423e32c 263 if (GetString(device,i,s,sizeof(s)) < 0)
abe00makoto 0:9fb6c423e32c 264 break;
abe00makoto 0:9fb6c423e32c 265 printf("%d: %s\r\n",i,s);
abe00makoto 0:9fb6c423e32c 266 }
abe00makoto 0:9fb6c423e32c 267
abe00makoto 0:9fb6c423e32c 268 switch (interfaceDesc->bInterfaceClass) {
abe00makoto 0:9fb6c423e32c 269 /*
abe00makoto 0:9fb6c423e32c 270 case CLASS_MASS_STORAGE:
abe00makoto 0:9fb6c423e32c 271 if (interfaceDesc->bInterfaceSubClass == 0x06 && interfaceDesc->bInterfaceProtocol == 0x50)
abe00makoto 0:9fb6c423e32c 272 OnDiskInsert(device); // it's SCSI!
abe00makoto 0:9fb6c423e32c 273 break;
abe00makoto 0:9fb6c423e32c 274 */
abe00makoto 0:9fb6c423e32c 275 case CLASS_WIRELESS_CONTROLLER:
abe00makoto 0:9fb6c423e32c 276 if (interfaceDesc->bInterfaceSubClass == 0x01 && interfaceDesc->bInterfaceProtocol == 0x01)
abe00makoto 0:9fb6c423e32c 277 OnBluetoothInsert(device); // it's bluetooth!
abe00makoto 0:9fb6c423e32c 278 break;
abe00makoto 0:9fb6c423e32c 279 case CLASS_HID:
abe00makoto 0:9fb6c423e32c 280 printf("idVendor = %04X idProduct = %04X \r\n",deviceDesc->idVendor,deviceDesc->idProduct);
abe00makoto 0:9fb6c423e32c 281 //printf("device = %d configuration = %d interfaceNumber = %d\r\n", device, configuration, interfaceNumber);
abe00makoto 0:9fb6c423e32c 282 //if (deviceDesc->idVendor == 0x054C && deviceDesc->idProduct == 0x0268) StartPS3Event(device,1,0);
abe00makoto 0:9fb6c423e32c 283 if (deviceDesc->idVendor == 0x054C && deviceDesc->idProduct == 0x0268) {
abe00makoto 0:9fb6c423e32c 284 Ps3USB _Ps3USB(device,1,0);
abe00makoto 0:9fb6c423e32c 285
abe00makoto 0:9fb6c423e32c 286 _Ps3USB.SetPair(my_mac);
abe00makoto 0:9fb6c423e32c 287 _Ps3USB.Enable();
abe00makoto 0:9fb6c423e32c 288 _Ps3USB.Led(1);
abe00makoto 0:9fb6c423e32c 289 _Ps3USB.Rumble(0x20,0xff,0x20,0xff);
abe00makoto 0:9fb6c423e32c 290 _Ps3USB.ShowPair();
abe00makoto 0:9fb6c423e32c 291
abe00makoto 0:9fb6c423e32c 292 } else StartAutoEvent(device,1,0);
abe00makoto 0:9fb6c423e32c 293 break;
abe00makoto 0:9fb6c423e32c 294
abe00makoto 0:9fb6c423e32c 295 case CLASS_VENDOR_SPECIFIC:
abe00makoto 0:9fb6c423e32c 296 if (deviceDesc->idVendor == 0x18D1 &&
abe00makoto 0:9fb6c423e32c 297 (deviceDesc->idProduct == 0x2D00 || deviceDesc->idProduct == 0x2D01))
abe00makoto 0:9fb6c423e32c 298 {
abe00makoto 0:9fb6c423e32c 299
abe00makoto 0:9fb6c423e32c 300 printf("accessory mode ok.\r\n");
abe00makoto 0:9fb6c423e32c 301 printf("idVender=%x idProduct=%x interfaceDesc->bInterfaceClass=%d\r\n",deviceDesc->idVendor,deviceDesc->idProduct,interfaceDesc->bInterfaceClass);
abe00makoto 0:9fb6c423e32c 302 AdkUSB _AdkUSB(device,1,0);
abe00makoto 0:9fb6c423e32c 303 _AdkUSB.loop();
abe00makoto 0:9fb6c423e32c 304
abe00makoto 0:9fb6c423e32c 305 }
abe00makoto 0:9fb6c423e32c 306 break;
abe00makoto 0:9fb6c423e32c 307
abe00makoto 0:9fb6c423e32c 308 default:
abe00makoto 0:9fb6c423e32c 309 printf(" try to change accmode.interfaceDesc->bInterfaceClass=%d\r\n",interfaceDesc->bInterfaceClass);
abe00makoto 0:9fb6c423e32c 310 if (switchDevice(device))break;
abe00makoto 0:9fb6c423e32c 311
abe00makoto 0:9fb6c423e32c 312 printf("Not yet supported \r\n");
abe00makoto 0:9fb6c423e32c 313 //StartAutoEvent(device,1,0);
abe00makoto 0:9fb6c423e32c 314 break;
abe00makoto 0:9fb6c423e32c 315 }
abe00makoto 0:9fb6c423e32c 316 }