主導機 mbed用のプログラムです 改良しました

Dependencies:   mbed

Fork of F3RC_syudou_master by yuto kawamura

Committer:
hirokimineshita
Date:
Fri May 15 02:45:57 2015 +0000
Revision:
8:6d0de6154e8f
Parent:
0:736c76a75def
Child:
13:3d7a8cb91eeb
2015/05/15 AM 11 need not register MAC Address

Who changed what in which revision?

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