Author Topic: Mouse & Joystick Composite with Buttons  (Read 23065 times)

radix2

  • Member
  • ***
  • Posts: 5
Mouse & Joystick Composite with Buttons
« 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...
« Last Edit: October 31, 2011, 10:11:04 am by radix2 »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Mouse & Joystick Composite with Buttons
« Reply #1 on: October 31, 2011, 11:22:05 am »
If you post your descriptors, someone might see something.

Jan

radix2

  • Member
  • ***
  • Posts: 5
Re: Mouse & Joystick Composite with Buttons
« Reply #2 on: October 31, 2011, 11:36:25 am »
Code: (Mouse report) [Select]
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)
};

Code: (Joystick report) [Select]
// 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)
};

Code: (Configuration Descriptor) [Select]
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
« Last Edit: November 02, 2011, 04:10:17 am by radix2 »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Mouse & Joystick Composite with Buttons
« Reply #3 on: October 31, 2011, 11:50:16 am »
What are you inserting for the joystick buttons and where?

Jan

radix2

  • Member
  • ***
  • Posts: 5
Re: Mouse & Joystick Composite with Buttons
« Reply #4 on: October 31, 2011, 11:58:50 am »
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

Guido Koerber

  • Frequent Contributor
  • ****
  • Posts: 72
Re: Mouse & Joystick Composite with Buttons
« Reply #5 on: November 01, 2011, 08:12:46 pm »
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.

radix2

  • Member
  • ***
  • Posts: 5
Re: Mouse & Joystick Composite with Buttons
« Reply #6 on: November 02, 2011, 04:11:19 am »
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

Guido Koerber

  • Frequent Contributor
  • ****
  • Posts: 72
Re: Mouse & Joystick Composite with Buttons
« Reply #7 on: November 02, 2011, 04:29:09 am »
Usage maximum for the buttons is the number of the buttons.

All the other points are still the same.

radix2

  • Member
  • ***
  • Posts: 5
Re: Mouse & Joystick Composite with Buttons
« Reply #8 on: November 02, 2011, 06:17:27 am »
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

Guido Koerber

  • Frequent Contributor
  • ****
  • Posts: 72
Re: Mouse & Joystick Composite with Buttons
« Reply #9 on: November 02, 2011, 08:39:30 am »
No, Report Count, Size, and Usage are values that get used up by the input/output/feature statements

gbr

  • Member
  • ***
  • Posts: 23
Re: Mouse & Joystick Composite with Buttons
« Reply #10 on: December 03, 2012, 03:43:51 am »
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