Some fixes to the endpoint handling

This commit is contained in:
Ingo Ruhnke 2008-05-03 11:58:50 +02:00
parent 1a946f6bfa
commit e0e55064d9
3 changed files with 45 additions and 21 deletions

View file

@ -1,7 +1,7 @@
===========================
[[ Protocol Descriptions ]]
===========================
General:
========
@ -11,13 +11,16 @@ for correctness.
Use usb_interrupt_read() not usb_bulk_read(), the later one fails with
the Xbox360 guitar.
Xbox:
=====
The A, B, X, Y, black and white buttons on the Xbox pad are 8bit pressure sensitive.
The A, B, X, Y, black, white, LT and RT buttons on the Xbox pad are 8bit
pressure sensitive.
Led: doesn't have LEDs
The two memory ports of the controller aren't discussed here.
LED: the controller doesn't have LEDs
+----------- small weight (right side), 0-255
v v-- large weight (left side), 0-255
Rumble: { 0x00, 0x06, 0x00, s, 0x00, large };
@ -66,14 +69,29 @@ Xbox360 Controller
==================
The Xbox360 controller doesn't have pressure sensitive A,B,X,Y,LB,RB
buttons like the Xbox controller, only LT and RT are analog.
buttons like the Xbox controller, only LT and RT are analog. Black and
white are replaced by LB and RB. And in addition to that it has a
guide button (big fat X).
Interface 0:
Endpoint 1(in): Controller events
Endpoint 2(out): Messages to the controller
Interface 1:
Endpoint 3(in): UNKNOWN (maybe headset)
Endpoint 4(out): UNKNOWN (maybe headset)
Endpoint 5(in): UNKNOWN (maybe headset)
Endpoint 6(out): UNKNOWN (maybe headset)
Interface 2:
Endpoint 6(in): UNKNOWN (maybe headset)
Interface 3:
None:
On first connect the controller sends:
len: 3 data: 0x01 0x03 0x0e // current LED status
len: 3 data: 0x02 0x03 0x00
len: 3 data: 0x02 0x03 0x00 // UNKNOWN: maybe headset connection status or volume
len: 3 data: 0x03 0x03 0x03 // Rumble Status (0x00 in the last pos means rumble is disabled, 0x03 is default)
len: 3 data: 0x08 0x03 0x00
len: 3 data: 0x08 0x03 0x00 // UNKNOWN: maybe headset connection status or volume
len: 20 data: 0x00 0x14 0x00 0x00 0x00 0x00 0x69 0xed 0x23 0xff 0x6b 0x00 0x15 0x03 0x00 0x00 0x00 0x00 0x00 0x00
len: 20 data: 0x00 0x14 0x00 0x00 0x00 0x00 0xfc 0xec 0x23 0xff 0x6b 0x00 0x15 0x03 0x00 0x00 0x00 0x00 0x00 0x00
@ -99,7 +117,7 @@ Rumble: { 0x00, 0x08, 0x00, large, small, 0x00, 0x00, 0x00 };
`--------- type of message
Unknown:
sending { 0x02, 0x03, INT } causes a reply of { 0x03, 0x03, INT } (values of 0-3 are supported)
sending { 0x02, 0x03, INT } causes a reply of { 0x03, 0x03, INT } (values of 0-3 are supported)
sending { 0x02, 0x03, 0x00 } causes future rumble update messages to be ignored, this seems to be permanent, even disconnecting the controller doesn't reset it
Event Messages:
@ -210,17 +228,17 @@ The wireless reciever acts as a single USB device, each of the four
controller is on a seperate Interface together with the headset port:
Interface 0:
Endpoint 1: Controller 1
Endpoint 2: Headset 1
Endpoint 1(in/out): Controller 1
Endpoint 2(in/out): Headset 1
Interface 1:
Endpoint 3: Controller 1
Endpoint 4: Headset 1
Endpoint 3(in/out): Controller 1
Endpoint 4(in/out): Headset 1
Interface 2:
Endpoint 5: Controller 1
Endpoint 6: Headset 1
Endpoint 5(in/out): Controller 1
Endpoint 6(in/out): Headset 1
Interface 3:
Endpoint 7: Controller 4
Endpoint 8: Headset 1
Endpoint 7(in/out): Controller 4
Endpoint 8(in/out): Headset 1
v-- typo? might be 0x0c, i.e. length
Rumble: { 0x00, 0x01, 0x0f, 0xc0, 0x00, large, small, 0x00, 0x00, 0x00, 0x00, 0x00 }

5
TODO
View file

@ -1,10 +1,13 @@
use bInterfaceProtocol or so to detect the gamepad, not idVendor/idProduct
Pictures of Xbox360 and controller:
http://g-prime.net/x360/
FIX:
=====
filter auto known unknown messages
usbcat contains ugly endpoint hack
uinput name should be configurable
uinput busid/devid shouldn't be hardcoded
Battery warning: LEDs 1,4 then 2,3 over and over ~10 times rapidly

View file

@ -74,8 +74,11 @@ cat_usb_device(struct usb_device* dev, int interface, int endpoint)
}
else
{
if (usb_claim_interface(handle, interface) != 0) // FIXME: bInterfaceNumber shouldn't be hardcoded
std::cout << "Claming interface " << interface << std::endl;
if (usb_claim_interface(handle, interface) != 0)
{
std::cout << "Claming interface " << interface << " success" << std::endl;
std::cout << "Error claiming the interface: " << usb_strerror() << std::endl;
if (usb_detach_kernel_driver_np(handle, interface) < 0)
{
@ -83,7 +86,7 @@ cat_usb_device(struct usb_device* dev, int interface, int endpoint)
exit(EXIT_FAILURE);
}
if (usb_claim_interface(handle, interface) != 0) // FIXME: bInterfaceNumber shouldn't be hardcoded
if (usb_claim_interface(handle, interface) != 0)
{
std::cout << "Error claiming the interface: " << usb_strerror() << std::endl;
exit(EXIT_FAILURE);
@ -166,7 +169,7 @@ int main(int argc, char** argv)
list_usb_devices();
}
else if ((argc == 4 || argc == 5) && strcmp("cat", argv[1]) == 0)
else if ((argc == 4 || argc == 5 || argc == 6) && strcmp("cat", argv[1]) == 0)
{
uint16_t idVendor;
uint16_t idProduct;
@ -176,7 +179,7 @@ int main(int argc, char** argv)
if (sscanf(argv[2], "0x%hx", &idVendor) == 1 &&
sscanf(argv[3], "0x%hx", &idProduct) == 1)
{
if (argc == 5)
if (argc >= 5)
interface = atoi(argv[4]);
if (argc == 6)