Closed valpackett closed 5 years ago
try to replace HUD_CONFIG with HUD_INPUT_MODE in hid_tlc_locate parameters
That doesn't help.
Again, the body of the HID_TLC_FOREACH_ITEM
loop does not get executed, so it doesn't get to the point where it compares features.. maybe the magic macro is broken for the last TLC or something? I'll try debugging with a manual loop that does similar things
Oh. There was also a problem with the macro. iter += (… ? 1 : 0) == tidx
should be (iter += (… ? 1 : 0)) == tidx
! (INPUT_MODE
was also required)
Parenthesis committed. Thanks! Strange enough, the buggy code worked well with second TLC while I was testing it with my touchscreen's firmware downloader TLC
The new hconf code cannot find the input mode feature on the Pixelbook touchpad…
Parsed descriptor
``` 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x02, // Usage (Mouse) 0xA1, 0x01, // Collection (Application) 0x85, 0x02, // Report ID (2) 0x09, 0x01, // Usage (Pointer) 0xA1, 0x00, // Collection (Physical) 0x05, 0x09, // Usage Page (Button) 0x19, 0x01, // Usage Minimum (0x01) 0x29, 0x02, // Usage Maximum (0x02) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x02, // Report Count (2) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x95, 0x06, // Report Count (6) 0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x30, // Usage (X) 0x09, 0x31, // Usage (Y) 0x15, 0x81, // Logical Minimum (-127) 0x25, 0x7F, // Logical Maximum (127) 0x75, 0x08, // Report Size (8) 0x95, 0x02, // Report Count (2) 0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) 0xC0, // End Collection 0xC0, // End Collection 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x05, // Usage (Touch Pad) 0xA1, 0x01, // Collection (Application) 0x85, 0x01, // Report ID (1) 0x05, 0x09, // Usage Page (Button) 0x19, 0x01, // Usage Minimum (0x01) 0x29, 0x01, // Usage Maximum (0x01) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x54, // Usage (0x54) 0x25, 0x05, // Logical Maximum (5) 0x75, 0x07, // Report Size (7) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x22, // Usage (Finger) 0xA1, 0x02, // Collection (Logical) 0x09, 0x47, // Usage (0x47) 0x09, 0x42, // Usage (Tip Switch) 0x09, 0x32, // Usage (In Range) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x03, // Report Count (3) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x51, // Usage (0x51) 0x25, 0x1F, // Logical Maximum (31) 0x75, 0x05, // Report Size (5) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x30, // Usage (X) 0x55, 0x0E, // Unit Exponent (-2) 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) 0x35, 0x00, // Physical Minimum (0) 0x46, 0x06, 0x04, // Physical Maximum (1030) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x31, // Usage (Y) 0x46, 0xA8, 0x02, // Physical Maximum (680) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x09, 0x48, // Usage (0x48) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x09, 0x49, // Usage (0x49) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x30, // Usage (Tip Pressure) 0x26, 0xFF, 0x00, // Logical Maximum (255) 0x75, 0x08, // Report Size (8) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x3F, // Usage (Azimuth) 0x16, 0x00, 0x00, // Logical Minimum (0) 0x26, 0x68, 0x01, // Logical Maximum (360) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0xC0, // End Collection 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x22, // Usage (Finger) 0xA1, 0x02, // Collection (Logical) 0x09, 0x47, // Usage (0x47) 0x09, 0x42, // Usage (Tip Switch) 0x09, 0x32, // Usage (In Range) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x03, // Report Count (3) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x51, // Usage (0x51) 0x25, 0x1F, // Logical Maximum (31) 0x75, 0x05, // Report Size (5) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x30, // Usage (X) 0x55, 0x0E, // Unit Exponent (-2) 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) 0x35, 0x00, // Physical Minimum (0) 0x46, 0x06, 0x04, // Physical Maximum (1030) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x31, // Usage (Y) 0x46, 0xA8, 0x02, // Physical Maximum (680) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x09, 0x48, // Usage (0x48) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x09, 0x49, // Usage (0x49) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x30, // Usage (Tip Pressure) 0x26, 0xFF, 0x00, // Logical Maximum (255) 0x75, 0x08, // Report Size (8) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x3F, // Usage (Azimuth) 0x16, 0x00, 0x00, // Logical Minimum (0) 0x26, 0x68, 0x01, // Logical Maximum (360) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0xC0, // End Collection 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x22, // Usage (Finger) 0xA1, 0x02, // Collection (Logical) 0x09, 0x47, // Usage (0x47) 0x09, 0x42, // Usage (Tip Switch) 0x09, 0x32, // Usage (In Range) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x03, // Report Count (3) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x51, // Usage (0x51) 0x25, 0x1F, // Logical Maximum (31) 0x75, 0x05, // Report Size (5) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x30, // Usage (X) 0x55, 0x0E, // Unit Exponent (-2) 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) 0x35, 0x00, // Physical Minimum (0) 0x46, 0x06, 0x04, // Physical Maximum (1030) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x31, // Usage (Y) 0x46, 0xA8, 0x02, // Physical Maximum (680) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x09, 0x48, // Usage (0x48) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x09, 0x49, // Usage (0x49) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x30, // Usage (Tip Pressure) 0x26, 0xFF, 0x00, // Logical Maximum (255) 0x75, 0x08, // Report Size (8) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x3F, // Usage (Azimuth) 0x16, 0x00, 0x00, // Logical Minimum (0) 0x26, 0x68, 0x01, // Logical Maximum (360) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0xC0, // End Collection 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x22, // Usage (Finger) 0xA1, 0x02, // Collection (Logical) 0x09, 0x47, // Usage (0x47) 0x09, 0x42, // Usage (Tip Switch) 0x09, 0x32, // Usage (In Range) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x03, // Report Count (3) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x51, // Usage (0x51) 0x25, 0x1F, // Logical Maximum (31) 0x75, 0x05, // Report Size (5) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x30, // Usage (X) 0x55, 0x0E, // Unit Exponent (-2) 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) 0x35, 0x00, // Physical Minimum (0) 0x46, 0x06, 0x04, // Physical Maximum (1030) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x31, // Usage (Y) 0x46, 0xA8, 0x02, // Physical Maximum (680) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x09, 0x48, // Usage (0x48) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x09, 0x49, // Usage (0x49) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x30, // Usage (Tip Pressure) 0x26, 0xFF, 0x00, // Logical Maximum (255) 0x75, 0x08, // Report Size (8) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x3F, // Usage (Azimuth) 0x16, 0x00, 0x00, // Logical Minimum (0) 0x26, 0x68, 0x01, // Logical Maximum (360) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0xC0, // End Collection 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x22, // Usage (Finger) 0xA1, 0x02, // Collection (Logical) 0x09, 0x47, // Usage (0x47) 0x09, 0x42, // Usage (Tip Switch) 0x09, 0x32, // Usage (In Range) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x01, // Logical Maximum (1) 0x75, 0x01, // Report Size (1) 0x95, 0x03, // Report Count (3) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x51, // Usage (0x51) 0x25, 0x1F, // Logical Maximum (31) 0x75, 0x05, // Report Size (5) 0x95, 0x01, // Report Count (1) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) 0x09, 0x30, // Usage (X) 0x55, 0x0E, // Unit Exponent (-2) 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) 0x35, 0x00, // Physical Minimum (0) 0x46, 0x06, 0x04, // Physical Maximum (1030) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x31, // Usage (Y) 0x46, 0xA8, 0x02, // Physical Maximum (680) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x26, 0x80, 0x33, // Logical Maximum (13184) 0x09, 0x48, // Usage (0x48) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x26, 0x00, 0x22, // Logical Maximum (8704) 0x09, 0x49, // Usage (0x49) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x30, // Usage (Tip Pressure) 0x26, 0xFF, 0x00, // Logical Maximum (255) 0x75, 0x08, // Report Size (8) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x09, 0x3F, // Usage (Azimuth) 0x16, 0x00, 0x00, // Logical Minimum (0) 0x26, 0x68, 0x01, // Logical Maximum (360) 0x75, 0x10, // Report Size (16) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0xC0, // End Collection 0x55, 0x0C, // Unit Exponent (-4) 0x66, 0x01, 0x10, // Unit (System: SI Linear, Time: Seconds) 0x47, 0xFF, 0xFF, 0x00, 0x00, // Physical Maximum (65534) 0x27, 0xFF, 0xFF, 0x00, 0x00, // Logical Maximum (65534) 0x75, 0x10, // Report Size (16) 0x95, 0x01, // Report Count (1) 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x56, // Usage (0x56) 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) 0x05, 0x0D, // Usage Page (Digitizer) 0x85, 0x0A, // Report ID (10) 0x09, 0x55, // Usage (0x55) 0x09, 0x59, // Usage (0x59) 0x75, 0x08, // Report Size (8) 0x95, 0x02, // Report Count (2) 0x25, 0x0F, // Logical Maximum (15) 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) 0x06, 0x00, 0xFF, // Usage Page (Vendor Defined 0xFF00) 0x85, 0x0B, // Report ID (11) 0x09, 0xC5, // Usage (0xC5) 0x15, 0x00, // Logical Minimum (0) 0x26, 0xFF, 0x00, // Logical Maximum (255) 0x75, 0x08, // Report Size (8) 0x96, 0x00, 0x01, // Report Count (256) 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) 0xC0, // End Collection 0x05, 0x0D, // Usage Page (Digitizer) 0x09, 0x0E, // Usage (0x0E) 0xA1, 0x01, // Collection (Application) 0x85, 0x0C, // Report ID (12) 0x09, 0x22, // Usage (Finger) 0xA1, 0x02, // Collection (Logical) 0x09, 0x52, // Usage (0x52) 0x15, 0x00, // Logical Minimum (0) 0x25, 0x0F, // Logical Maximum (15) 0x75, 0x08, // Report Size (8) 0x95, 0x01, // Report Count (1) 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) 0xC0, // End Collection 0x09, 0x22, // Usage (Finger) 0xA1, 0x00, // Collection (Physical) 0x85, 0x0D, // Report ID (13) 0x09, 0x57, // Usage (0x57) 0x09, 0x58, // Usage (0x58) 0x75, 0x04, // Report Size (4) 0x95, 0x02, // Report Count (2) 0x25, 0x01, // Logical Maximum (1) 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) 0xC0, // End Collection 0xC0, // End Collection // 702 bytes ```Added some debug prints: the
HID_TLC_FOREACH_ITEM
loop does not do any iterations at all.Only adding back the old-style loop from
hmt
helped.Working hack code
```c static int hconf_attach(device_t dev) { struct hconf_softc *sc = device_get_softc(dev); const struct hid_device_info *hw = hid_get_device_info(dev); uint32_t flags; void *d_ptr; uint16_t d_len; uint8_t tlc_index; int error; device_set_desc(dev, hw->name); error = hid_get_report_descr(dev, &d_ptr, &d_len); if (error) { device_printf(dev, "could not retrieve report descriptor from " "device: %d\n", error); return (ENXIO); } sc->dev = dev; tlc_index = hidbus_get_index(dev); /* Parse features for input mode switch */ if (hid_tlc_locate(d_ptr, d_len, HID_USAGE2(HUP_DIGITIZERS, HUD_CONFIG), hid_feature, tlc_index, 0, &sc->input_mode_loc, &flags, &sc->input_mode_rid, NULL) && (flags & (HIO_VARIABLE | HIO_RELATIVE)) == HIO_VARIABLE) sc->input_mode_rlen = hid_report_size_1(d_ptr, d_len, hid_feature, sc->input_mode_rid); else { device_printf(dev,"failed to locate new style\n"); bool conf_coll = false; struct hid_item hi; struct hid_data *hd = hid_start_parse(d_ptr, d_len, 1 << hid_feature); while (hid_get_item(hd, &hi)) { switch (hi.kind) { case hid_collection: if (hi.collevel == 1 && hi.usage == HID_USAGE2(HUP_DIGITIZERS, HUD_CONFIG)) conf_coll = true; break; case hid_endcollection: if (hi.collevel == 0 && conf_coll) conf_coll = false; break; case hid_feature: if (conf_coll && hi.usage == HID_USAGE2(HUP_DIGITIZERS, HUD_INPUT_MODE)) { sc->input_mode_rid = hi.report_ID; if (sc == NULL) { device_printf(dev,"failed to locate old style\n"); hid_end_parse(hd); break; } sc->input_mode_loc = hi.loc; sc->input_mode_rlen = hid_report_size_1(d_ptr, d_len, hid_feature, sc->input_mode_rid); } default: break; } } hid_end_parse(hd); } return (0); } ```