Skip to content

Commit 7fa5d1e

Browse files
committed
HID: uclogic: Refactor UGEEv2 probe magic data
A fututure patch will need to use the array of magic data that the UGEEv2 devices expect on probe and the endpoint number. Move them to a common place. Refactor, no functional changes. Tested-by: Mia Kanashi <chad@redpilled.dev> Tested-by: Andreas Grosse <andig.mail@t-online.de> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 44e29ba commit 7fa5d1e

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

hid-uclogic-params.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
10191019
* Returns:
10201020
* Zero, if successful. A negative errno code on error.
10211021
*/
1022-
static int uclogic_probe_interface(struct hid_device *hdev, u8 *magic_arr,
1023-
int magic_size, int endpoint)
1022+
static int uclogic_probe_interface(struct hid_device *hdev, const u8 *magic_arr,
1023+
size_t magic_size, int endpoint)
10241024
{
10251025
struct usb_device *udev;
10261026
unsigned int pipe = 0;
@@ -1309,9 +1309,6 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
13091309
__u8 *rdesc_pen = NULL;
13101310
s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM];
13111311
enum uclogic_params_frame_type frame_type;
1312-
__u8 magic_arr[] = {
1313-
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1314-
};
13151312
/* The resulting parameters (noop) */
13161313
struct uclogic_params p = {0, };
13171314

@@ -1342,7 +1339,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
13421339
* The specific data was discovered by sniffing the Windows driver
13431340
* traffic.
13441341
*/
1345-
rc = uclogic_probe_interface(hdev, magic_arr, sizeof(magic_arr), 0x03);
1342+
rc = uclogic_probe_interface(hdev, uclogic_ugee_v2_probe_arr,
1343+
uclogic_ugee_v2_probe_size,
1344+
uclogic_ugee_v2_probe_endpoint);
13461345
if (rc) {
13471346
uclogic_params_init_invalid(&p);
13481347
goto output;

hid-uclogic-rdesc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,12 @@ const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
859859
const size_t uclogic_rdesc_v2_frame_dial_size =
860860
sizeof(uclogic_rdesc_v2_frame_dial_arr);
861861

862+
const __u8 uclogic_ugee_v2_probe_arr[] = {
863+
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
864+
};
865+
const size_t uclogic_ugee_v2_probe_size = sizeof(uclogic_ugee_v2_probe_arr);
866+
const int uclogic_ugee_v2_probe_endpoint = 0x03;
867+
862868
/* Fixed report descriptor template for UGEE v2 pen reports */
863869
const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = {
864870
0x05, 0x0d, /* Usage Page (Digitizers), */

hid-uclogic-rdesc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ extern const size_t uclogic_rdesc_v2_frame_dial_size;
164164
/* Report ID for tweaked UGEE v2 battery reports */
165165
#define UCLOGIC_RDESC_UGEE_V2_BATTERY_ID 0xba
166166

167+
/* Magic data expected by UGEEv2 devices on probe */
168+
extern const __u8 uclogic_ugee_v2_probe_arr[];
169+
extern const size_t uclogic_ugee_v2_probe_size;
170+
extern const int uclogic_ugee_v2_probe_endpoint;
171+
167172
/* Fixed report descriptor template for UGEE v2 pen reports */
168173
extern const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[];
169174
extern const size_t uclogic_rdesc_ugee_v2_pen_template_size;

0 commit comments

Comments
 (0)