Skip to content
24 changes: 24 additions & 0 deletions hid-uclogic-params.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ static const char *uclogic_params_pen_inrange_to_str(
}
}

/**
* Patches the descriptor if needed
*
* @hdev: The HID device the pen parameters describe.
* @desc_ptr: The pointer to the report descriptor
*/
static void patch_descriptor(struct hid_device *hdev, __u8 *desc_ptr)
{
if (strcmp(hdev->name, "UC-Logic ARTISUL D16") == 0) {
//it's the D16, so patch the
//descriptor to ignore the tilt bytes
const int template_size = uclogic_rdesc_v1_pen_template_size;

desc_ptr[template_size - 5] = 0x95; // \ Report Count (1)
desc_ptr[template_size - 4] = 0x01; // /
desc_ptr[template_size - 3] = 0x80; // input
desc_ptr[template_size - 2] = 0xC0; // End Collection
desc_ptr[template_size - 1] = 0xC0; // End Collection
}
}

/**
* Dump tablet interface pen parameters with hid_dbg(), indented with one tab.
*
Expand Down Expand Up @@ -298,6 +319,9 @@ static int uclogic_params_pen_init_v1(struct uclogic_params_pen *pen,
uclogic_rdesc_v1_pen_template_arr,
uclogic_rdesc_v1_pen_template_size,
desc_params, ARRAY_SIZE(desc_params));

patch_descriptor(hdev,desc_ptr);

if (desc_ptr == NULL) {
rc = -ENOMEM;
goto cleanup;
Expand Down
4 changes: 3 additions & 1 deletion hid-uclogic-rdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ const __u8 uclogic_rdesc_v1_pen_template_arr[] = {
/* Logical Maximum (PLACEHOLDER), */
0x81, 0x02, /* Input (Variable), */
0xC0, /* End Collection, */
0xC0 /* End Collection */
0xC0, /* End Collection */

0, 0, 0 //a few extra bytes in case it needs expanded
};

const size_t uclogic_rdesc_v1_pen_template_size =
Expand Down