PORTS Forum
Ports and Interfaces => USB => Topic started by: radix2 on October 31, 2011, 08:28:09 am
-
Hey
I have a device that is to appear as a 5 button mouse and a 4 button joystick. The descriptors I have work fine when used as separate (single interface/endpoint) devices, and the composite device works fine until I add the 4 joystick buttons to the joystick report descriptor. With the 4 joystick buttons inserted, the joystick stops appearing but the mouse still works.
I've tried moving the buttons around inside the joystick descriptor, and labeling them Button 6-9 (Usage Description) but nothing seems to work.
Thanks for any help
Joe
EDIT: hmm, seem's something more is happening, for I cannot add any more fields at all to either of the Report Descriptor's...
-
If you post your descriptors, someone might see something.
Jan
-
char REPORT_MOUSE[52] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
// -- 4 Buttons, 3 empty
0x05, 0x09, // Usage Page (Buttons)
0x19, 0x01, // Usage Minimum (01)
0x29, 0x01, // Usage Maximum (01)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x81, 0x01, // Input (Constant) for padding
// -- X/Y Axis + Scroll Wheel
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (3)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // End Collection (Physical)
0xC0 // End Collection (Application)
};
// TODO: add 4 joystick buttons
char REPORT_JOYSTICK[38] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (3)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // End Collection (Physical)
0x05, 0x02, // Usage Page (Simulation Controls)
0x95, 0x01, // Report Count (1)
0x09, 0xBB, // Usage (Throttle)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0 // End Collection (Application)
};
char HIDCONFIGDESC[] = {
// configuration_descriptor hid_configuration_descriptor
sizeof(configuration_descriptor), // Length
0x02, // Type
LE(sizeof(hid_configuration_descriptor)),// Totallength (= 9+9+9+7)
0x02, // NumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0x80, // bmAttributes
0x20, // MaxPower (in 2mA units)
// interface_descriptor hid_interface_descriptor
sizeof(interface_descriptor), // bLength
0x04, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x02, // bInterfaceProcotol
0x00, // iInterface
// class_descriptor hid_descriptor
sizeof(class_descriptor), // bLength
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
LE(sizeof(REPORT_MOUSE)), // wItemLength
// endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_descriptor), // bLength
0x05, // bDescriptorType
0x81, // bEndpointAddress
0x03, // bmAttributes
LE(EP1_PACKET_SIZE), // MaxPacketSize (LITTLE ENDIAN)
10, // bInterval
// interface_descriptor hid_interface_descriptor
sizeof(interface_descriptor), // bLength
0x04, // bDescriptorType
0x01, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x02, // bInterfaceProcotol
0x00, // iInterface
// class_descriptor hid_descriptor
sizeof(class_descriptor), // bLength
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
LE(sizeof(REPORT_JOYSTICK)), // wItemLength
// endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_descriptor), // bLength
0x05, // bDescriptorType
0x82, // bEndpointAddress
0x03, // bmAttributes
LE(EP1_PACKET_SIZE), // MaxPacketSize (LITTLE ENDIAN)
10, // bInterval
}
Thankyou
-
What are you inserting for the joystick buttons and where?
Jan
-
I was basically copying the Mouse descriptor's button bits into the Joystick descriptor (including the padding) in various places: above and below the x/y/z (in the physical collection) and before/after the Throttle (along with all the changes to make the throttle output [-127,127].
I also tried adding a Rudder (`0x09, 0xBA,`) in with the Throttle, and tried removing the buttons from the mouse (in order to put them all with the joystick, just to test), and add a Z axis to the mouse. Each time I changed the descriptor that endpoint stopped working (even with a driver-reinstall).
I can change the number of buttons on the mouse between 3, 5, and 9 easily (though windows ignores >5 I believe?) but I really could do with them being on the joystick.
Thanks
-
The mouse report descriptor has no buttons.
Same for the joystick.
Neither will enumerate properly with at least some versions of Windows.
Joystick data should be absolute.
Throttle has no report size.
The second endpoint descriptor specifies the max packet size for EP1.
Usage Page only needs to be specified if you are changing to a different Usage Page within a descriptor. This is just redundancy though.
-
Woops, sorry about that Guido, what I've posted is the last working state of the descriptors (I dont know why the buttons weren't in the mouse descriptor :\)
Thanks
Joe
-
Usage maximum for the buttons is the number of the buttons.
All the other points are still the same.
-
Do the Report Size properties not get inherited from the previous 'section'? Infact, when I try to add that property to it (or any other property), the joystick doesn't appear correctly to windows. Nor does the mouse work when I change the mouse descriptor. I've not made any changes between a point at which I could change the descriptor as I liked, to this point when any change breaks everything.
EP1_PACKET_SIZE == EP2_PACKET_SIZE where they're defined.
Thanks
Joe
-
No, Report Count, Size, and Usage are values that get used up by the input/output/feature statements
-
Hello chaps
I have a set of descriptors that has been working for a year or 2 with 18F chips
I made that under the powerful help of a chap called Tsuneo I think (that was 2 years ago)
You are welcome to it
It is in Assembly but can be used as a report descriptor set with other langages