 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
OldPrisoneR
Joined: 20 Mar 2008 Posts: 53
|
Posted: Mon Nov 10, 2008 2:32 am Post subject: 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 |
|
| Back to top |
|
 |
KickinAezz
Joined: 03 Jun 2007 Posts: 328
|
Posted: Mon Nov 10, 2008 11:26 am Post subject: |
|
|
Something to do with USB Host Mode support? _________________ Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
Last edited by KickinAezz on Mon Nov 10, 2008 1:53 pm; edited 1 time in total |
|
| Back to top |
|
 |
ghost_gluck

Joined: 04 Apr 2008 Posts: 7
|
Posted: Mon Nov 10, 2008 12:16 pm Post subject: |
|
|
May be, this information is helpful, see below:
| Code: |
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
};
|
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. |
|
| Back to top |
|
 |
OldPrisoneR
Joined: 20 Mar 2008 Posts: 53
|
Posted: Mon Nov 10, 2008 6:08 pm Post subject: |
|
|
| ghost_gluck wrote: | | ...but i couldn't see RootDescriptor's description in sources. |
Currently I'm trying to figure out how to send that HID descriptor
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 |
|
| Back to top |
|
 |
ghost_gluck

Joined: 04 Apr 2008 Posts: 7
|
Posted: Mon Nov 10, 2008 8:01 pm Post subject: |
|
|
Now I find USB Joystick Project on PIC18F2550 with sources at http://www.helmpcb.com/Electronics/USBJoystick/USBJoystick.aspx
Project contain Schematic and Source files http://www.helmpcb.com/Electronics/USBJoystick/USB%20Joystick%2001-03-08,%2016-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. |
|
| Back to top |
|
 |
mydipper
Joined: 05 Oct 2008 Posts: 6
|
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Tue Nov 11, 2008 2:05 am Post subject: |
|
|
| KickinAezz wrote: | | Something to do with USB Host Mode support? |
No its got nothing to do with host mode. HID is slave....
@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. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue Nov 11, 2008 5:49 am Post subject: Re: PSP USB HID descriptor |
|
|
| 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...
|
Take a look at the source for libhid. They request the HID descriptor with a control request on endpoint 0x81:
| Code: | 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);
|
I imagine you'll just need to listen for this control request and respond with your descriptor. |
|
| Back to top |
|
 |
ghost_gluck

Joined: 04 Apr 2008 Posts: 7
|
Posted: Tue Nov 11, 2008 7:13 pm Post subject: |
|
|
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. _________________ Sorry for terrible english. My native language is C++... |
|
| Back to top |
|
 |
OldPrisoneR
Joined: 20 Mar 2008 Posts: 53
|
Posted: Wed Nov 12, 2008 1:32 am Post subject: |
|
|
| Quote: | | In my opinion, UsbRequest function from source code is a callback, which called when data received to the device. |
Probably yes, but at first we must send all necessary descriptors
(cuz currently, as you may see, it's not called at all)
| Quote: | | But i don't know how to write from DEVICE to HOST. |
sceUsbbdReqSend - IN for HOST
sceUsbbdReqRecv - OUT for HOST
Just fill UsbdDeviceReq structure propertly
| Quote: | Do i need to start send descriptors at start?
What kind of packets i need to send at start? |
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
| Quote: | 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. |
He ment libhid for PC no doubts :p
P.S.: I've used RemoteJoy src ;) thx TyRaNiD |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Wed Nov 12, 2008 10:14 am Post subject: |
|
|
| 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.
|
All USB transactions are originated by the host. The device writes data to the host ONLY in response to a request from the host.
| Quote: | Do i need to start send descriptors at start?
What kind of packets i need to send at start? | You just need to respond to the requests for descriptors -- see my post above.
| Quote: | 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'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. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Wed Nov 12, 2008 10:16 am Post subject: |
|
|
| 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 | 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. |
|
| Back to top |
|
 |
ghost_gluck

Joined: 04 Apr 2008 Posts: 7
|
Posted: Wed Nov 12, 2008 9:53 pm Post subject: |
|
|
| jimparis wrote: | | 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.
|
All USB transactions are originated by the host. The device writes data to the host ONLY in response to a request from the host.
|
As "write from DEVICE to HOST" i mean transmit data to output buffer or send response.
| Quote: |
| Quote: | Do i need to start send descriptors at start?
What kind of packets i need to send at start? | You just need to respond to the requests for descriptors -- see my post above.
|
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.
| Quote: |
| Quote: | 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'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. |
As "Microsoft HID drivers" i mean default HID layer implemetation in M$ Windoze.
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++... |
|
| Back to top |
|
 |
OldPrisoneR
Joined: 20 Mar 2008 Posts: 53
|
Posted: Thu Nov 13, 2008 1:40 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
hnaves
Joined: 03 Feb 2009 Posts: 30
|
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat Jun 06, 2009 6:22 pm Post subject: |
|
|
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 ;) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|