手動機アーム、mbed基盤のspiをおくるだけのプログラムです(9/4)

Dependencies:   SPI_master_arm_shudouki mbed

Fork of SPI_master_arm_shudouki2 by F^3 RC 2班

Committer:
yoka06
Date:
Mon Aug 21 08:49:06 2017 +0000
Revision:
0:76d1c7f13415
a

Who changed what in which revision?

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