PSP USB HID descriptor
-
- Posts: 53
- Joined: Thu Mar 20, 2008 2:33 am
PSP USB HID descriptor
Hello :p
I'm trying to write USBdriver for PSP to let the host detect it as a HID device (GAMEPAD)
First problem:
I need send HID descriptor to the host, but currently I don't know how to achieve that aim :(
PSP sends dev. descriptor
then it sends config., interface and EP descriptors...
But we need it to send config., interface, HID and EP descriptors...
I suppose we must try to with sceUsbbdReqRecv and sceUsbbdReqSend
Anyway, any suggestions are welcome :)
I've done some code, check it, if you are interesting in
source code
I'm trying to write USBdriver for PSP to let the host detect it as a HID device (GAMEPAD)
First problem:
I need send HID descriptor to the host, but currently I don't know how to achieve that aim :(
PSP sends dev. descriptor
then it sends config., interface and EP descriptors...
But we need it to send config., interface, HID and EP descriptors...
I suppose we must try to with sceUsbbdReqRecv and sceUsbbdReqSend
Anyway, any suggestions are welcome :)
I've done some code, check it, if you are interesting in
source code
-
- Posts: 328
- Joined: Sun Jun 03, 2007 10:05 pm
Something to do with USB Host Mode support?
Last edited by KickinAezz on Mon Nov 10, 2008 1:53 pm, edited 1 time in total.
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Use it more for Development than for Gaming.
- ghost_gluck
- Posts: 7
- Joined: Fri Apr 04, 2008 5:09 am
May be, this information is helpful, see below:
This information was get from HID Descriptor tool, profile - joystk.hid (http://www.usb.org/developers/hidpage/dt2_4.zip). from http://www.usb.org/developers/hidpage
Probably, you were used this tool, but i couldn't see RootDescriptor's description in sources.
Code: Select all
char ReportDescriptor[77] = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x02, // USAGE_PAGE (Simulation Controls)
0x09, 0xbb, // USAGE (Throttle)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0x09, 0x39, // USAGE (Hat switch)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x03, // LOGICAL_MAXIMUM (3)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46, 0x0e, 0x01, // PHYSICAL_MAXIMUM (270)
0x65, 0x14, // UNIT (Eng Rot:Angular Pos)
0x75, 0x04, // REPORT_SIZE (4)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x04, // USAGE_MAXIMUM (Button 4)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x04, // REPORT_COUNT (4)
0x55, 0x00, // UNIT_EXPONENT (0)
0x65, 0x00, // UNIT (None)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0 // END_COLLECTION
};
Probably, you were used this tool, but i couldn't see RootDescriptor's description in sources.
-
- Posts: 53
- Joined: Thu Mar 20, 2008 2:33 am
Currently I'm trying to figure out how to send that HID descriptorghost_gluck wrote:...but i couldn't see RootDescriptor's description in sources.
bearing in mind that idenfication process is as follows(approx):
host> GET DEVICE DESCRIPTOR
psp sends DEVICE DESCRIPTOR
host> GET DESCRIPTORS
psp sends CONFIG. INTERFACE and EP DESCRIPTORs
But we need also to send HID descriptor between INTERFACE and EP DESCRIPTORs at this stage.
And this is the main problem(currently)...
At last we must send ReportDescriptor (thx for example and links btw :))
So that's why I haven't included ReportDescriptor in source code
- ghost_gluck
- Posts: 7
- Joined: Fri Apr 04, 2008 5:09 am
Now I find USB Joystick Project on PIC18F2550 with sources at http://www.helmpcb.com/Electronics/USBJ ... stick.aspx
Project contain Schematic and Source files http://www.helmpcb.com/Electronics/USBJ ... -35-23.zip
See USB Joystick\Source Code\USBdsc.c, line 36.
unsigned char const DescTables[] = {
}
At line 100 begins Endpoint1 TX descriptor and at end of this descriptor, starts ReportDescriptor from joystk.hid
I don't develop HID devices or devices, based on PIC microcontrollers and i don't fully understand, how HID layer and PIC hardware works. But i find in the source directory USBJoystick_callertable.txt. This file contains list of called functions and they order. May be, this information is helpful to you.
I download mikroC v8 compiler http://www.mikroe.com/en/compilers/mikroc/pic/ for investigate functions and documentation about libraries, included in USBJoystick project.
Additional Projects http://pe.ece.olin.edu/ece/projects.html
PS. Sorry for my bad English, because it is not my native language.
Project contain Schematic and Source files http://www.helmpcb.com/Electronics/USBJ ... -35-23.zip
See USB Joystick\Source Code\USBdsc.c, line 36.
unsigned char const DescTables[] = {
}
At line 100 begins Endpoint1 TX descriptor and at end of this descriptor, starts ReportDescriptor from joystk.hid
I don't develop HID devices or devices, based on PIC microcontrollers and i don't fully understand, how HID layer and PIC hardware works. But i find in the source directory USBJoystick_callertable.txt. This file contains list of called functions and they order. May be, this information is helpful to you.
I download mikroC v8 compiler http://www.mikroe.com/en/compilers/mikroc/pic/ for investigate functions and documentation about libraries, included in USBJoystick project.
Additional Projects http://pe.ece.olin.edu/ece/projects.html
PS. Sorry for my bad English, because it is not my native language.
I also found the USBJoy project on AVR ATmega8.
website :
http://www.raijuu.net/2008/08/usbjoy/
source code :
http://avrusb.wikidot.com/local--files/ ... 060108.zip
It contains the source code for PlayStation and PlayStation 2 joypad.
However, it is hard for me to follow, because my technical base is not on the programming..
Sorry for bad English, too ;)
website :
http://www.raijuu.net/2008/08/usbjoy/
source code :
http://avrusb.wikidot.com/local--files/ ... 060108.zip
It contains the source code for PlayStation and PlayStation 2 joypad.
However, it is hard for me to follow, because my technical base is not on the programming..
Sorry for bad English, too ;)
No its got nothing to do with host mode. HID is slave....KickinAezz wrote:Something to do with USB Host Mode support?
@OP, it looks like all you need to do is figure out how to use those two functions. Ask SilverSpring or someone, he would probably have the most vast knowledge of all the firmware functions.
Re: PSP USB HID descriptor
Take a look at the source for libhid. They request the HID descriptor with a control request on endpoint 0x81:OldPrisoneR wrote:Hello :p
I'm trying to write USBdriver for PSP to let the host detect it as a HID device (GAMEPAD)
First problem:
I need send HID descriptor to the host, but currently I don't know how to achieve that aim :(
PSP sends dev. descriptor
then it sends config., interface and EP descriptors...
But we need it to send config., interface, HID and EP descriptors...
Code: Select all
TRACE("retrieving HID descriptor for USB device %s...", hidif->id);
int len = usb_control_msg(hidif->dev_handle,
USB_ENDPOINT_IN+1,
USB_REQ_GET_DESCRIPTOR,
(USB_DT_HID << 8) + 0, hidif->interface,
(char*)buffer, BUFLEN,
USB_TIMEOUT);
- ghost_gluck
- Posts: 7
- Joined: Fri Apr 04, 2008 5:09 am
In my opinion, UsbRequest function from source code is a callback, which called when data received to the device.
IMHO this function can handle all request from HOST to DEVICE.
But i don't know how to write from DEVICE to HOST.
Do UsbData might be used as input and output buffer?
If No - how i can manipulate with data?
I install USBTrace from http://sysnucleus.com/ to get raw exchange protocol between devices.
Do i need to start send descriptors at start?
What kind of packets i need to send at start?
jimparis, Did you mean about libusb for HOST or DEVICE?
If HOST then DEVICE must be HID compatible and standard drivers was used for USB HID Joystick from microsoft.
If DEVICE - please specify, where we can download port of libhid for PSP.
OldPrisoneR, As i see, you use part of usbhostfs driver.
IMHO this function can handle all request from HOST to DEVICE.
But i don't know how to write from DEVICE to HOST.
Do UsbData might be used as input and output buffer?
If No - how i can manipulate with data?
I install USBTrace from http://sysnucleus.com/ to get raw exchange protocol between devices.
Do i need to start send descriptors at start?
What kind of packets i need to send at start?
jimparis, Did you mean about libusb for HOST or DEVICE?
If HOST then DEVICE must be HID compatible and standard drivers was used for USB HID Joystick from microsoft.
If DEVICE - please specify, where we can download port of libhid for PSP.
OldPrisoneR, As i see, you use part of usbhostfs driver.
Sorry for terrible english. My native language is C++...
-
- Posts: 53
- Joined: Thu Mar 20, 2008 2:33 am
Probably yes, but at first we must send all necessary descriptorsIn my opinion, UsbRequest function from source code is a callback, which called when data received to the device.
(cuz currently, as you may see, it's not called at all)
sceUsbbdReqSend - IN for HOSTBut i don't know how to write from DEVICE to HOST.
sceUsbbdReqRecv - OUT for HOST
Just fill UsbdDeviceReq structure propertly
You see, when you call sceUsbActivate PSP automaticly send all descriptors which you have set up in UsbDriver structure - and that's the main problemDo i need to start send descriptors at start?
What kind of packets i need to send at start?
He ment libhid for PC no doubts :pjimparis, Did you mean about libusb for HOST or DEVICE?
If HOST then DEVICE must be HID compatible and standard drivers was used for USB HID Joystick from microsoft.
If DEVICE - please specify, where we can download port of libhid for PSP.
P.S.: I've used RemoteJoy src ;) thx TyRaNiD
All USB transactions are originated by the host. The device writes data to the host ONLY in response to a request from the host.ghost_gluck wrote:In my opinion, UsbRequest function from source code is a callback, which called when data received to the device.
IMHO this function can handle all request from HOST to DEVICE.
But i don't know how to write from DEVICE to HOST.
You just need to respond to the requests for descriptors -- see my post above.Do i need to start send descriptors at start?
What kind of packets i need to send at start?
I'm talking about libhid on the host. This has nothing to do with Microsoft (?!) HID drivers -- it is a complete HID layer on top of libusb. You can use that source to see how the HID descriptors are requested from the device. Then you can code the device side to watch for those requests and respond accordingly.jimparis, Did you mean about libusb for HOST or DEVICE?
If HOST then DEVICE must be HID compatible and standard drivers was used for USB HID Joystick from microsoft.
If DEVICE - please specify, where we can download port of libhid for PSP.
So you never see the control request that I outlined in my post above? If not, you're going to have to dig deeper into sceUsbActivate and see why that request is not making it through.OldPrisoneR wrote:You see, when you call sceUsbActivate PSP automaticly send all descriptors which you have set up in UsbDriver structure - and that's the main problem
- ghost_gluck
- Posts: 7
- Joined: Fri Apr 04, 2008 5:09 am
As "write from DEVICE to HOST" i mean transmit data to output buffer or send response.jimparis wrote:All USB transactions are originated by the host. The device writes data to the host ONLY in response to a request from the host.ghost_gluck wrote:In my opinion, UsbRequest function from source code is a callback, which called when data received to the device.
IMHO this function can handle all request from HOST to DEVICE.
But i don't know how to write from DEVICE to HOST.
Now i know how implemented device registration and data exchange on PSP after I was investigating documentation and source code of the sample and usbhostfs.You just need to respond to the requests for descriptors -- see my post above.Do i need to start send descriptors at start?
What kind of packets i need to send at start?
As "Microsoft HID drivers" i mean default HID layer implemetation in M$ Windoze.I'm talking about libhid on the host. This has nothing to do with Microsoft (?!) HID drivers -- it is a complete HID layer on top of libusb. You can use that source to see how the HID descriptors are requested from the device. Then you can code the device side to watch for those requests and respond accordingly.jimparis, Did you mean about libusb for HOST or DEVICE?
If HOST then DEVICE must be HID compatible and standard drivers was used for USB HID Joystick from microsoft.
If DEVICE - please specify, where we can download port of libhid for PSP.
I could not saw HID descriptor in USB trace log in answer on request "GET_DESCRIPTOR_FROM_DEVICE" and device could not recognized by OS, because device's configuration block does not have HID descriptor and device identify itself as HID compatible. aren't?
Now i don't know, how to attach HID Descriptor to the configuration. May be it's not possible at this moment. May be new firmware have new functions like sceUsbbdRegisterEx and data structures to register device with all descriptors.
P.S. More detail investigation of usb.prx is need.
Sorry for terrible english. My native language is C++...
-
- Posts: 53
- Joined: Thu Mar 20, 2008 2:33 am
It makes me wonder, why there are two pointers in UsbData::Interfaces (pinterdesc[2])
Is that means we can use two interface descriptors?
If that's true we can send HID descriptor (it has the same size) instead of second interface...
but where should we put the second interface in?
UsbData::InterDesc::desc has only 12 bytes
And we need at least 9+9=18 bytes
BTW, wtf is UsbData::InterDesc::pad for??? :p
Is that means we can use two interface descriptors?
If that's true we can send HID descriptor (it has the same size) instead of second interface...
but where should we put the second interface in?
UsbData::InterDesc::desc has only 12 bytes
And we need at least 9+9=18 bytes
BTW, wtf is UsbData::InterDesc::pad for??? :p
Nice, certainly plenty of stuff I never worked out when implementing usbhostfs, surprised it works ;) At least I can see why the padding was there (I kinda guessed it might be something like extra fields but I didn't need to spend any extra time finding out).
Now we will see if any of those people wanting to make the PSP a gamepad come back and do some work ;)
Now we will see if any of those people wanting to make the PSP a gamepad come back and do some work ;)