diff --git a/hid-uclogic-params.c b/hid-uclogic-params.c index 7f7cc36..0406270 100644 --- a/hid-uclogic-params.c +++ b/hid-uclogic-params.c @@ -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. * @@ -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; diff --git a/hid-uclogic-rdesc.c b/hid-uclogic-rdesc.c index c26bfb1..f97f936 100644 --- a/hid-uclogic-rdesc.c +++ b/hid-uclogic-rdesc.c @@ -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 =