@@ -209,7 +209,7 @@ static const __u8 pensketch_t609a_control_rdesc[] = {
209
209
0xC0 /* End Collection */
210
210
};
211
211
212
- /* Fix indexes in kye_tablet_fixup if you change this */
212
+ /* Fix indexes in kye_tablet_fixup() if you change this */
213
213
static const __u8 kye_tablet_rdesc [] = {
214
214
0x06 , 0x00 , 0xFF , /* Usage Page (FF00h), */
215
215
0x09 , 0x01 , /* Usage (01h), */
@@ -262,12 +262,16 @@ static const __u8 kye_tablet_rdesc[] = {
262
262
0x27 , 0xFF , 0x07 , 0x00 , 0x00 , /* Logical Maximum (2047), */
263
263
0x81 , 0x02 , /* Input (Variable), */
264
264
0xC0 , /* End Collection, */
265
- 0xC0 , /* End Collection, */
266
- 0x05 , 0x0D , /* Usage Page (Digitizer), */
267
- 0x09 , 0x21 , /* Usage (Puck), */
265
+ 0xC0 /* End Collection, */
266
+ };
267
+
268
+ /* Fix indexes in kye_tablet_fixup() if you change this */
269
+ static const __u8 kye_tablet_mouse_rdesc [] = {
270
+ 0x05 , 0x01 , /* Usage Page (Desktop), */
271
+ 0x09 , 0x02 , /* Usage (Mouse), */
268
272
0xA1 , 0x01 , /* Collection (Application), */
269
273
0x85 , 0x11 , /* Report ID (17), */
270
- 0x09 , 0x21 , /* Usage (Puck), */
274
+ 0x09 , 0x01 , /* Usage (Pointer), */
271
275
0xA0 , /* Collection (Physical), */
272
276
0x05 , 0x09 , /* Usage Page (Button), */
273
277
0x19 , 0x01 , /* Usage Minimum (01h), */
@@ -280,7 +284,7 @@ static const __u8 kye_tablet_rdesc[] = {
280
284
0x95 , 0x04 , /* Report Count (4), */
281
285
0x81 , 0x01 , /* Input (Constant), */
282
286
0x05 , 0x0D , /* Usage Page (Digitizer), */
283
- 0x09 , 0x32 , /* Usage (In Range), */
287
+ 0x09 , 0x37 , /* Usage (Data Valid), */
284
288
0x95 , 0x01 , /* Report Count (1), */
285
289
0x81 , 0x02 , /* Input (Variable), */
286
290
0x05 , 0x01 , /* Usage Page (Desktop), */
@@ -317,7 +321,7 @@ static const struct kye_tablet_info {
317
321
__s32 y_physical_maximum ;
318
322
__s8 unit_exponent ;
319
323
__s8 unit ;
320
- bool has_punk ;
324
+ bool has_mouse ;
321
325
unsigned int control_rsize ;
322
326
const __u8 * control_rdesc ;
323
327
} kye_tablets_info [] = {
@@ -402,7 +406,7 @@ static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc,
402
406
static __u8 * kye_tablet_fixup (struct hid_device * hdev , __u8 * rdesc , unsigned int * rsize )
403
407
{
404
408
const struct kye_tablet_info * info ;
405
- unsigned int newsize ;
409
+ __u8 * newdesc = rdesc ;
406
410
407
411
if (* rsize < sizeof (kye_tablet_rdesc )) {
408
412
hid_warn (hdev ,
@@ -420,36 +424,45 @@ static __u8 *kye_tablet_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int
420
424
return rdesc ;
421
425
}
422
426
423
- newsize = info -> has_punk ? sizeof (kye_tablet_rdesc ) : 112 ;
424
- memcpy (rdesc , kye_tablet_rdesc , newsize );
425
-
426
- put_unaligned_le32 (info -> x_logical_maximum , rdesc + 66 );
427
- put_unaligned_le32 (info -> x_physical_maximum , rdesc + 72 );
428
- rdesc [77 ] = info -> unit ;
429
- rdesc [79 ] = info -> unit_exponent ;
430
- put_unaligned_le32 (info -> y_logical_maximum , rdesc + 87 );
431
- put_unaligned_le32 (info -> y_physical_maximum , rdesc + 92 );
432
- put_unaligned_le32 (info -> pressure_logical_maximum , rdesc + 104 );
433
-
434
- if (info -> has_punk ) {
435
- put_unaligned_le32 (info -> x_logical_maximum , rdesc + 156 );
436
- put_unaligned_le32 (info -> x_physical_maximum , rdesc + 162 );
437
- rdesc [167 ] = info -> unit ;
438
- rdesc [169 ] = info -> unit_exponent ;
439
- put_unaligned_le32 (info -> y_logical_maximum , rdesc + 177 );
440
- put_unaligned_le32 (info -> y_physical_maximum , rdesc + 182 );
427
+ memcpy (newdesc , kye_tablet_rdesc , sizeof (kye_tablet_rdesc ));
428
+
429
+ put_unaligned_le32 (info -> x_logical_maximum , newdesc + 66 );
430
+ put_unaligned_le32 (info -> x_physical_maximum , newdesc + 72 );
431
+ newdesc [77 ] = info -> unit ;
432
+ newdesc [79 ] = info -> unit_exponent ;
433
+ put_unaligned_le32 (info -> y_logical_maximum , newdesc + 87 );
434
+ put_unaligned_le32 (info -> y_physical_maximum , newdesc + 92 );
435
+ put_unaligned_le32 (info -> pressure_logical_maximum , newdesc + 104 );
436
+
437
+ newdesc += sizeof (kye_tablet_rdesc );
438
+
439
+ if (info -> has_mouse ) {
440
+ if (newdesc + sizeof (kye_tablet_mouse_rdesc ) > rdesc + * rsize )
441
+ hid_err (hdev , "control desc unexpectedly large\n" );
442
+ else {
443
+ memcpy (newdesc , kye_tablet_mouse_rdesc , sizeof (kye_tablet_mouse_rdesc ));
444
+
445
+ put_unaligned_le32 (info -> x_logical_maximum , newdesc + 44 );
446
+ put_unaligned_le32 (info -> x_physical_maximum , newdesc + 50 );
447
+ newdesc [55 ] = info -> unit ;
448
+ newdesc [57 ] = info -> unit_exponent ;
449
+ put_unaligned_le32 (info -> y_logical_maximum , newdesc + 65 );
450
+ put_unaligned_le32 (info -> y_physical_maximum , newdesc + 70 );
451
+
452
+ newdesc += sizeof (kye_tablet_mouse_rdesc );
453
+ }
441
454
}
442
455
443
456
if (info -> control_rsize ) {
444
- if (newsize + info -> control_rsize > * rsize )
445
- hid_err (hdev , "control rdesc unexpectedly large" );
457
+ if (newdesc + info -> control_rsize > rdesc + * rsize )
458
+ hid_err (hdev , "control desc unexpectedly large\n " );
446
459
else {
447
- memcpy (rdesc + newsize , info -> control_rdesc , info -> control_rsize );
448
- newsize += info -> control_rsize ;
460
+ memcpy (newdesc , info -> control_rdesc , info -> control_rsize );
461
+ newdesc += info -> control_rsize ;
449
462
}
450
463
}
451
464
452
- * rsize = newsize ;
465
+ * rsize = newdesc - rdesc ;
453
466
return rdesc ;
454
467
}
455
468
0 commit comments