Dependencies:   mbed

Committer:
abe00makoto
Date:
Thu May 26 19:39:37 2011 +0000
Revision:
1:237cfff63ef8
Parent:
0:e939856c1939

        

Who changed what in which revision?

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