Skip to content

Commit 387dcab

Browse files
JoseExpositoJiri Kosina
authored andcommitted
HID: uclogic: Add support for UGEE v2 mouse frames
Add the required HID descriptors and the initialization function for UGEE v2 frames with a mouse in the frame. Tested-by: Jouke Witteveen <[email protected]> Signed-off-by: José Expósito <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent b67439d commit 387dcab

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

drivers/hid/hid-uclogic-params.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,28 @@ static int uclogic_params_ugee_v2_init_frame_dial(struct uclogic_params *p,
11891189
return 0;
11901190
}
11911191

1192+
/**
1193+
* uclogic_params_ugee_v2_init_frame_mouse() - initialize a UGEE v2 frame with a
1194+
* mouse.
1195+
* @p: Parameters to fill in, cannot be NULL.
1196+
*
1197+
* Returns:
1198+
* Zero, if successful. A negative errno code on error.
1199+
*/
1200+
static int uclogic_params_ugee_v2_init_frame_mouse(struct uclogic_params *p)
1201+
{
1202+
int rc = 0;
1203+
1204+
if (!p)
1205+
return -EINVAL;
1206+
1207+
rc = uclogic_params_frame_init_with_desc(&p->frame_list[1],
1208+
uclogic_rdesc_ugee_v2_frame_mouse_template_arr,
1209+
uclogic_rdesc_ugee_v2_frame_mouse_template_size,
1210+
UCLOGIC_RDESC_V1_FRAME_ID);
1211+
return rc;
1212+
}
1213+
11921214
/**
11931215
* uclogic_params_ugee_v2_init() - initialize a UGEE graphics tablets by
11941216
* discovering their parameters.
@@ -1232,6 +1254,15 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
12321254

12331255
iface = to_usb_interface(hdev->dev.parent);
12341256
bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber;
1257+
1258+
if (bInterfaceNumber == 0) {
1259+
rc = uclogic_params_ugee_v2_init_frame_mouse(&p);
1260+
if (rc)
1261+
goto cleanup;
1262+
1263+
goto output;
1264+
}
1265+
12351266
if (bInterfaceNumber != 2) {
12361267
uclogic_params_init_invalid(&p);
12371268
goto output;

drivers/hid/hid-uclogic-rdesc.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,40 @@ const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[] = {
10011001
const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size =
10021002
sizeof(uclogic_rdesc_ugee_v2_frame_dial_template_arr);
10031003

1004+
/* Fixed report descriptor template for UGEE v2 frame reports (mouse) */
1005+
const __u8 uclogic_rdesc_ugee_v2_frame_mouse_template_arr[] = {
1006+
0x05, 0x01, /* Usage Page (Desktop), */
1007+
0x09, 0x02, /* Usage (Mouse), */
1008+
0xA1, 0x01, /* Collection (Application), */
1009+
0x85, 0x01, /* Report ID (1), */
1010+
0x05, 0x01, /* Usage Page (Pointer), */
1011+
0xA0, /* Collection (Physical), */
1012+
0x75, 0x01, /* Report Size (1), */
1013+
0x95, 0x02, /* Report Count (2), */
1014+
0x05, 0x09, /* Usage Page (Button), */
1015+
0x19, 0x01, /* Usage Minimum (01h), */
1016+
0x29, 0x02, /* Usage Maximum (02h), */
1017+
0x14, /* Logical Minimum (0), */
1018+
0x25, 0x01, /* Logical Maximum (1), */
1019+
0x81, 0x02, /* Input (Variable), */
1020+
0x95, 0x06, /* Report Count (6), */
1021+
0x81, 0x01, /* Input (Constant), */
1022+
0x05, 0x01, /* Usage Page (Generic Desktop), */
1023+
0x09, 0x30, /* Usage (X), */
1024+
0x09, 0x31, /* Usage (Y), */
1025+
0x75, 0x10, /* Report Size (16), */
1026+
0x95, 0x02, /* Report Count (2), */
1027+
0x16, 0x00, 0x80, /* Logical Minimum (-32768), */
1028+
0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */
1029+
0x81, 0x06, /* Input (Variable, Relative), */
1030+
0x95, 0x01, /* Report Count (1), */
1031+
0x81, 0x01, /* Input (Constant), */
1032+
0xC0, /* End Collection, */
1033+
0xC0 /* End Collection */
1034+
};
1035+
const size_t uclogic_rdesc_ugee_v2_frame_mouse_template_size =
1036+
sizeof(uclogic_rdesc_ugee_v2_frame_mouse_template_arr);
1037+
10041038
/* Fixed report descriptor for Ugee EX07 frame */
10051039
const __u8 uclogic_rdesc_ugee_ex07_frame_arr[] = {
10061040
0x05, 0x01, /* Usage Page (Desktop), */

drivers/hid/hid-uclogic-rdesc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ extern const size_t uclogic_rdesc_ugee_v2_frame_btn_template_size;
173173
extern const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[];
174174
extern const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size;
175175

176+
/* Fixed report descriptor template for UGEE v2 frame reports (mouse) */
177+
extern const __u8 uclogic_rdesc_ugee_v2_frame_mouse_template_arr[];
178+
extern const size_t uclogic_rdesc_ugee_v2_frame_mouse_template_size;
179+
176180
/* Fixed report descriptor for Ugee EX07 frame */
177181
extern const __u8 uclogic_rdesc_ugee_ex07_frame_arr[];
178182
extern const size_t uclogic_rdesc_ugee_ex07_frame_size;

0 commit comments

Comments
 (0)