Sorry if this message is going to the wrong list. I am not sure if there is a dedicated HID list, and this post is too technical for the usb-users.
I have been digging around the HID code to get the "Microsoft Sidewinder Strategic Commander" to work fully with linux. By working, I mean being able to turn LEDs on and off. My hacking was very successful, as I have achieved (nearly) full functionality, but I could not do it very cleanly.
After a bit of digging I have narrowed down the following design flaw: in hidinput_configure_usage:
case HID_UP_LED:
usage->code = (usage->hid - 1) & 0xf; usage->type = EV_LED; bit = input->ledbit; max = LED_MAX; break;
It seems that the code of the led is its usage. This somewhat makes sense for the keyboards, as one of the usages is numlock and other keyboard specific LEDs. However, there are more usages, such as "Indicator On" which can be (and are) tied to more leds than one. Moreover there can be more than one usage tied to a single LED.
There may be other classes (not just LEDs) that suffer from this.
This causes a major problem in encoding such devices. My question is whether there are any plans to rework that section, and what is the priority of such a task. I am considering doing the work, but I have severe time constraints. Furthermore, this change would requre struct changes to handle many-many relationships. I believe that such changes should be done by those with more experience.
This post is a bit of the follow-up of the message that I sent privately to Vojtech. But as I now consider this to be a more general problem, as well as having further understanding of HID, I decided to post this to all devs.
Couple more details: The device (with some of my annotations in *****):
evbug.c: Connected device: "Microsoft SideWinder Joystick", usb-0000:00:02.0-1/input0
input: USB HID v1.10 Joystick [Microsoft SideWinder Joystick] on usb-0000:00:02.0-1
hid-debug: input GenericDesktop.0031 = -44
hid-debug: input Button.000e = 1
hid-debug: input Undefined.0008 = 1
hid-debug: input LED.0041 = 1
INPUT(1)[INPUT]
Field(0)
Physical(GenericDesktop.0001)
Usage(3)
GenericDesktop.0030
GenericDesktop.0031
GenericDesktop.0035
Logical Minimum(-512)
Logical Maximum(511)
Physical Minimum(0)
Physical Maximum(1023)
Report Size(10)
Report Count(3)
Report Offset(0)
Flags( Variable Absolute )
Field(1)
Usage(12)
Button.0001
Button.0002
Button.0003
Button.0004
Button.0005
Button.0006
Button.0007
Button.0008
Button.0009
Button.000a
Button.000b
Button.000c
Logical Minimum(0)
Logical Maximum(1)
Physical Minimum(0)
Physical Maximum(1)
Report Size(1)
Report Count(12)
Report Offset(32)
Flags( Variable Absolute )
Field(2)
Usage(3)
Button.000d
Button.000e
Button.000f
Logical Minimum(1)
Logical Maximum(3)
Physical Minimum(0)
Physical Maximum(1)
Report Size(2)
Report Count(1)
Report Offset(44)
Flags( Array Absolute NoPrefferedState )
FEATURE(1)[FEATURE]
Field(0)
Logical(LED.003c)
Usage(3)
LED.0041
LED.003d
LED.0040
Logical Minimum(0)
Logical Maximum(2)
Physical Minimum(0)
Physical Maximum(1)
Report Size(2)
Report Count(6) *****6 LEDS*****
Report Offset(0)
Flags( Array Absolute NoPrefferedState NullState )
Field(1)
Logical(LED.003c)
Usage(3)
LED.0041 ****3 usages for led*****
LED.003d ****same 3 as in previous 6****
LED.0040
Logical Minimum(0)
Logical Maximum(2)
Physical Minimum(0)
Physical Maximum(1)
Report Size(2)
Report Count(1) ********1 LED*******
Report Offset(12)
Flags( Array Absolute NoPrefferedState NullState )
FEATURE(2)[FEATURE]
Field(0)
Usage(1)
LED.0045 *****Blink on delay*******
Logical Minimum(1)
Logical Maximum(255)
Physical Minimum(1)
Physical Maximum(255)
Unit Exponent(2)
Unit(SI Linear : Seconds)
Report Size(8)
Report Count(1)
Report Offset(0)
Flags( Array Absolute NoPrefferedState NullState )
Field(1)
Usage(1)
LED.0046 ******Blink off delay******
Logical Minimum(1)
Logical Maximum(255)
Physical Minimum(1)
Physical Maximum(255)
Unit Exponent(2)
Unit(SI Linear : Seconds)
Report Size(8)
Report Count(1)
Report Offset(8)
Flags( Array Absolute NoPrefferedState NullState )
evbug.c: Connected device: "Microsoft Microsoft SideWinder Strategic Commander", usb-0000:00:02.0-2/input0
input: USB HID v1.10 Device [Microsoft Microsoft SideWinder Strategic Commander] on usb-0000:00:02.0-2
My changes (against 2.6.3) (containing horrible hacks that I am ashamed of.
hid-core.c
1007a1008,1021
>
> report_enum = hid->report_enum + HID_FEATURE_REPORT;
> list = report_enum->report_list.next;
>
> while (list != &report_enum->report_list) {
> struct hid_report *report = (struct hid_report *) list;
> list = list->next;
> for (i = 0; i < report->maxfield; i++) {
> *field = report->field[i];
> for (j = 0; j < (*field)->maxusage; j++)
> if ((*field)->usage[j].type == type && (*field)->usage[j].code == code)
> return j;
> }
> }
hid-input.c
169c169,198
< usage->code = (usage->hid - 1) & 0xf;
---
> if (usage->hid - 1 > 0xf)
> switch(usage->hid-1) {
> case 0x80041:
> if (field->report_count == 6)
> usage->code = 5;
> else usage->code = 8;
> break;
> case 0x8003d:
> if (field->report_count == 6)
> usage->code = 6;
> else
> usage->code = 9;
> break;
> case 0x80040:
> if (field->report_count == 6)
> usage->code = 7;
> else
> usage->code = 10;
> break;
> case 0x80045:
> usage->code = 11;
> break;
> case 0x80046:
> usage->code = 12;
> break;
> default:
> usage->code = (usage->hid - 1) & 0xf;
> }
> else
> usage->code = (usage->hid - 1) & 0xf;
170a200
> printk("LED detected, code: %d, orig: 0x%x\n", usage->code, usage->hid -1);
515a546,551
> /* this is completely bogus for LEDS */
>
> printk("Looking for code: 0x%x\n", code);
>
> if (code < 5 || code > 11) {
>
520a557,575
> }
> else {
> if (code <=10) {
> // primary buttons
> offset = (code - 5);
> if (hid_find_field(hid,type,5, &field) == -1) {
> printk("OOPS, can not find event field\n");
> return -1;
> }
> }
> else { // code == 11
> offset = 0;
> if (hid_find_field(hid,type, 8, &field) == -1) {
> printk("OOPS, can not find event field\n");
> return -1;
> }
> }
> }
>
564c619
< for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
---
> for (k = HID_INPUT_REPORT; k <= HID_FEATURE_REPORT; k++) {
Please forgive me if I violated mailing list etiquette. I am a complete novice to mailing lists, as well as the development process. I am also subscribed to the digest, so I might not respond immediately.
Thanks for the advice.
-- Alex Vaynberg Senior, Computer Science Carnegie Mellon University
------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
