Skip to content

Commit 0edf31f

Browse files
author
Mel
committed
Generify the xppen pro init function for general use.
1 parent 28fb702 commit 0edf31f

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

hid-uclogic-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static int uclogic_raw_event(struct hid_device *hdev,
475475
223, 231, 239, 247, 257, 266, 277
476476
};
477477
// sqrt(8) / 4 = 0.7071067811865476
478-
const s32 discriminant = 7071068;
478+
const s32 discriminant = 707106781;
479479
s8 tx = data[8];
480480
s8 ty = data[9];
481481
s8 abs_tilt;

hid-uclogic-params.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,17 +1007,22 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
10071007
* @params: Parameters to fill in (to be cleaned with
10081008
* uclogic_params_cleanup()). Not modified in case of error.
10091009
* Cannot be NULL.
1010+
* @init_packet: Magic packet to send on usb to activate device.
1011+
* @packet_size: Size of the init packet.
1012+
* @rdesc_pen_arr: Pen report descriptor array.
1013+
* @rdesc_pen_size: Size of the pen array.
1014+
* @rdesc_frame_arr: Frame report descriptor array.
1015+
* @rdesc_frame_size: Size of the frame array.
10101016
*
10111017
* Returns:
10121018
* Zero, if successful. A negative errno code on error.
10131019
*/
10141020
static int uclogic_params_init_ugee_xppen_pro(struct hid_device *hdev,
1015-
struct uclogic_params *p)
1021+
struct uclogic_params *p,
1022+
const u8 init_packet[], const size_t packet_size,
1023+
const u8 rdesc_pen_arr[], const size_t rdesc_pen_size,
1024+
const u8 rdesc_frame_arr[], const size_t rdesc_frame_size)
10161025
{
1017-
static const u8 init_packet[] = {
1018-
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1019-
};
1020-
const size_t packet_size = sizeof(init_packet);
10211026
const size_t str_desc_len = 12;
10221027
struct usb_device *udev = hid_to_usb_dev(hdev);
10231028
u8 *buf = kmemdup(init_packet, packet_size, GFP_KERNEL);
@@ -1096,18 +1101,18 @@ static int uclogic_params_init_ugee_xppen_pro(struct hid_device *hdev,
10961101
);
10971102

10981103
p->pen.desc_ptr = uclogic_rdesc_template_apply(
1099-
uclogic_rdesc_xppen_a156p_pen_arr,
1100-
uclogic_rdesc_xppen_a156p_pen_size,
1104+
rdesc_pen_arr,
1105+
rdesc_pen_size,
11011106
desc_params,
11021107
ARRAY_SIZE(desc_params)
11031108
);
1104-
p->pen.desc_size = uclogic_rdesc_xppen_a156p_pen_size;
1109+
p->pen.desc_size = rdesc_pen_size;
11051110
p->pen.id = 0x02;
11061111

11071112
rc = uclogic_params_frame_init_with_desc(
11081113
&p->frame_list[0],
1109-
uclogic_rdesc_xppen_a156p_frame_arr,
1110-
uclogic_rdesc_xppen_a156p_frame_size,
1114+
rdesc_frame_arr,
1115+
rdesc_frame_size,
11111116
UCLOGIC_RDESC_V1_FRAME_ID
11121117
);
11131118
if (rc < 0) {
@@ -1419,13 +1424,22 @@ int uclogic_params_init(struct uclogic_params *params,
14191424
break;
14201425
case VID_PID(USB_VENDOR_ID_UGEE,
14211426
USB_DEVICE_ID_UGEE_XPPEN_TABLET_A156P):
1427+
static const u8 init_packet[] = {
1428+
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1429+
};
1430+
const size_t packet_size = sizeof(init_packet);
1431+
14221432
/* Only use the uniform interface */
14231433
if (bInterfaceNumber != 2) {
14241434
uclogic_params_init_invalid(&p);
14251435
break;
14261436
}
14271437

1428-
rc = uclogic_params_init_ugee_xppen_pro(hdev, &p);
1438+
rc = uclogic_params_init_ugee_xppen_pro(hdev, &p, init_packet, packet_size,
1439+
uclogic_rdesc_xppen_a156p_pen_arr,
1440+
uclogic_rdesc_xppen_a156p_pen_size,
1441+
uclogic_rdesc_xppen_a156p_frame_arr,
1442+
uclogic_rdesc_xppen_a156p_frame_size);
14291443
if (rc != 0) {
14301444
hid_err(hdev, "a156p init failed: %d\n", rc);
14311445
goto cleanup;

0 commit comments

Comments
 (0)