Skip to content

Commit 0dfcb4c

Browse files
committed
uclogic: Differentiate touch ring and touch strip
1 parent a4442d0 commit 0dfcb4c

3 files changed

Lines changed: 114 additions & 25 deletions

File tree

hid-uclogic-params.c

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,14 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
804804
static const char transition_ver[] = "HUION_T153_160607";
805805
char *ver_ptr = NULL;
806806
const size_t ver_len = sizeof(transition_ver) + 1;
807+
__u8 *params_ptr = NULL;
808+
size_t params_len = 0;
809+
/* Parameters string descriptor of a model with touch ring (HS610) */
810+
const __u8 touch_ring_model_params_buf[] = {
811+
0x13, 0x03, 0x70, 0xC6, 0x00, 0x06, 0x7C, 0x00,
812+
0xFF, 0x1F, 0xD8, 0x13, 0x03, 0x0D, 0x10, 0x01,
813+
0x04, 0x3C, 0x3E
814+
};
807815

808816
/* Check arguments */
809817
if (params == NULL || hdev == NULL) {
@@ -844,7 +852,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
844852
} else {
845853
/* Try to probe v2 pen parameters */
846854
rc = uclogic_params_pen_init_v2(&p.pen, &found,
847-
NULL, NULL, hdev);
855+
&params_ptr, &params_len,
856+
hdev);
848857
if (rc != 0) {
849858
hid_err(hdev,
850859
"failed probing pen v2 parameters: %d\n", rc);
@@ -865,25 +874,60 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
865874
goto cleanup;
866875
}
867876

868-
/* Create v2 frame touch ring parameters */
869-
rc = uclogic_params_frame_init_with_desc(
877+
/* Link from pen sub-report */
878+
p.pen.subreport_list[0].value = 0xe0;
879+
p.pen.subreport_list[0].id =
880+
UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID;
881+
882+
/* If this is the model with touch ring */
883+
if (params_ptr != NULL &&
884+
params_len == sizeof(touch_ring_model_params_buf) &&
885+
memcmp(params_ptr, touch_ring_model_params_buf,
886+
params_len) == 0) {
887+
/* Create touch ring parameters */
888+
rc = uclogic_params_frame_init_with_desc(
870889
&p.frame_list[1],
871890
uclogic_rdesc_v2_frame_touch_ring_arr,
872891
uclogic_rdesc_v2_frame_touch_ring_size,
873892
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID);
874-
if (rc != 0) {
875-
hid_err(hdev,
876-
"failed creating v2 frame touch ring "
877-
"parameters: %d\n",
878-
rc);
879-
goto cleanup;
893+
if (rc != 0) {
894+
hid_err(hdev,
895+
"failed creating v2 frame touch "
896+
"ring parameters: %d\n",
897+
rc);
898+
goto cleanup;
899+
}
900+
p.frame_list[1].suffix = "Touch Ring";
901+
p.frame_list[1].dev_id_byte =
902+
UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
903+
p.frame_list[1].touch_byte = 5;
904+
p.frame_list[1].touch_max = 12;
905+
p.frame_list[1].touch_flip_at = 7;
906+
} else {
907+
/* Create touch strip parameters */
908+
rc = uclogic_params_frame_init_with_desc(
909+
&p.frame_list[1],
910+
uclogic_rdesc_v2_frame_touch_strip_arr,
911+
uclogic_rdesc_v2_frame_touch_strip_size,
912+
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID);
913+
if (rc != 0) {
914+
hid_err(hdev,
915+
"failed creating v2 frame touch "
916+
"strip parameters: %d\n",
917+
rc);
918+
goto cleanup;
919+
}
920+
p.frame_list[1].suffix = "Touch Strip";
921+
p.frame_list[1].dev_id_byte =
922+
UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
923+
p.frame_list[1].touch_byte = 5;
924+
p.frame_list[1].touch_max = 8;
880925
}
881-
p.frame_list[1].suffix = "Touch Ring";
882-
p.frame_list[1].dev_id_byte =
883-
UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE;
884-
p.frame_list[1].touch_byte = 5;
885-
p.frame_list[1].touch_max = 12;
886-
p.frame_list[1].touch_flip_at = 7;
926+
927+
/* Link from pen sub-report */
928+
p.pen.subreport_list[1].value = 0xf0;
929+
p.pen.subreport_list[1].id =
930+
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID;
887931

888932
/* Create v2 frame dial parameters */
889933
rc = uclogic_params_frame_init_with_desc(
@@ -903,19 +947,11 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
903947
UCLOGIC_RDESC_V2_FRAME_DIAL_DEV_ID_BYTE;
904948
p.frame_list[2].bitmap_dial_byte = 5;
905949

906-
/*
907-
* Link button and touch ring subreports from pen
908-
* reports
909-
*/
910-
p.pen.subreport_list[0].value = 0xe0;
911-
p.pen.subreport_list[0].id =
912-
UCLOGIC_RDESC_V2_FRAME_BUTTONS_ID;
913-
p.pen.subreport_list[1].value = 0xf0;
914-
p.pen.subreport_list[1].id =
915-
UCLOGIC_RDESC_V2_FRAME_TOUCH_ID;
950+
/* Link from pen sub-report */
916951
p.pen.subreport_list[2].value = 0xf1;
917952
p.pen.subreport_list[2].id =
918953
UCLOGIC_RDESC_V2_FRAME_DIAL_ID;
954+
919955
goto output;
920956
}
921957
hid_dbg(hdev, "pen v2 parameters not found\n");
@@ -956,6 +992,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
956992
memset(&p, 0, sizeof(p));
957993
rc = 0;
958994
cleanup:
995+
kfree(params_ptr);
959996
kfree(ver_ptr);
960997
uclogic_params_cleanup(&p);
961998
return rc;

hid-uclogic-rdesc.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,54 @@ const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[] = {
761761
const size_t uclogic_rdesc_v2_frame_touch_ring_size =
762762
sizeof(uclogic_rdesc_v2_frame_touch_ring_arr);
763763

764+
/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
765+
const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[] = {
766+
0x05, 0x01, /* Usage Page (Desktop), */
767+
0x09, 0x07, /* Usage (Keypad), */
768+
0xA1, 0x01, /* Collection (Application), */
769+
0x85, UCLOGIC_RDESC_V2_FRAME_TOUCH_ID,
770+
/* Report ID (TOUCH_ID), */
771+
0x14, /* Logical Minimum (0), */
772+
0x05, 0x0D, /* Usage Page (Digitizer), */
773+
0x09, 0x39, /* Usage (Tablet Function Keys), */
774+
0xA0, /* Collection (Physical), */
775+
0x25, 0x01, /* Logical Maximum (1), */
776+
0x75, 0x01, /* Report Size (1), */
777+
0x05, 0x09, /* Usage Page (Button), */
778+
0x09, 0x01, /* Usage (01h), */
779+
0x95, 0x01, /* Report Count (1), */
780+
0x81, 0x02, /* Input (Variable), */
781+
0x95, 0x07, /* Report Count (7), */
782+
0x81, 0x01, /* Input (Constant), */
783+
0x75, 0x08, /* Report Size (8), */
784+
0x95, 0x02, /* Report Count (2), */
785+
0x81, 0x01, /* Input (Constant), */
786+
0x05, 0x0D, /* Usage Page (Digitizer), */
787+
0x0A, 0xFF, 0xFF, /* Usage (FFFFh), */
788+
0x26, 0xFF, 0x00, /* Logical Maximum (255), */
789+
0x95, 0x01, /* Report Count (1), */
790+
0x81, 0x02, /* Input (Variable), */
791+
0x05, 0x01, /* Usage Page (Desktop), */
792+
0x09, 0x38, /* Usage (Wheel), */
793+
0x95, 0x01, /* Report Count (1), */
794+
0x15, 0x00, /* Logical Minimum (0), */
795+
0x25, 0x07, /* Logical Maximum (7), */
796+
0x81, 0x02, /* Input (Variable), */
797+
0x09, 0x30, /* Usage (X), */
798+
0x09, 0x31, /* Usage (Y), */
799+
0x14, /* Logical Minimum (0), */
800+
0x25, 0x01, /* Logical Maximum (1), */
801+
0x75, 0x01, /* Report Size (1), */
802+
0x95, 0x02, /* Report Count (2), */
803+
0x81, 0x02, /* Input (Variable), */
804+
0x95, 0x2E, /* Report Count (46), */
805+
0x81, 0x01, /* Input (Constant), */
806+
0xC0, /* End Collection, */
807+
0xC0 /* End Collection */
808+
};
809+
const size_t uclogic_rdesc_v2_frame_touch_strip_size =
810+
sizeof(uclogic_rdesc_v2_frame_touch_strip_arr);
811+
764812
/* Fixed report descriptor for (tweaked) v2 frame dial reports */
765813
const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
766814
0x05, 0x01, /* Usage Page (Desktop), */

hid-uclogic-rdesc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ extern const size_t uclogic_rdesc_v2_frame_buttons_size;
138138
extern const __u8 uclogic_rdesc_v2_frame_touch_ring_arr[];
139139
extern const size_t uclogic_rdesc_v2_frame_touch_ring_size;
140140

141+
/* Fixed report descriptor for (tweaked) v2 frame touch strip reports */
142+
extern const __u8 uclogic_rdesc_v2_frame_touch_strip_arr[];
143+
extern const size_t uclogic_rdesc_v2_frame_touch_strip_size;
144+
141145
/* Device ID byte offset in v2 frame touch ring/strip reports */
142146
#define UCLOGIC_RDESC_V2_FRAME_TOUCH_DEV_ID_BYTE 0x4
143147

0 commit comments

Comments
 (0)