jcs's openbsd hax
openbsd

Allow usage item counts up to 2048, matching FreeBSD. This reportedly helps with some touchscreens and gaming keyboards as described here: https://reviews.freebsd.org/D16357

ok jcs@

jmatthew 4e97034b 8cf36292

+9 -9
+9 -9
sys/dev/hid/hid.c
··· 1 - /* $OpenBSD: hid.c,v 1.9 2025/10/28 15:36:46 jcs Exp $ */ 1 + /* $OpenBSD: hid.c,v 1.10 2025/11/03 01:41:22 jmatthew Exp $ */ 2 2 /* $NetBSD: hid.c,v 1.23 2002/07/11 21:14:25 augustss Exp $ */ 3 3 /* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */ 4 4 ··· 47 47 #define MAXUSAGE 64 48 48 #define MAXPUSH 4 49 49 #define MAXID 16 50 + #define MAXLOCCNT 2048 50 51 51 52 struct hid_pos_data { 52 53 int32_t rid; ··· 64 65 uint32_t usage_last; /* last seen usage */ 65 66 uint32_t loc_size; /* last seen size */ 66 67 uint32_t loc_count; /* last seen count */ 68 + uint32_t ncount; /* end usage item count */ 69 + uint32_t icount; /* current usage item count */ 67 70 enum hid_kind kind; 68 71 uint8_t pushlevel; /* current pushlevel */ 69 - uint8_t ncount; /* end usage item count */ 70 - uint8_t icount; /* current usage item count */ 71 72 uint8_t nusage; /* end "usages_min/max" index */ 72 73 uint8_t iusage; /* current "usages_min/max" index */ 73 74 uint8_t ousage; /* current "usages_min/max" offset */ ··· 298 299 switch (bTag) { 299 300 case 8: /* Input */ 300 301 c->kind = hid_input; 301 - c->flags = dval; 302 302 ret: 303 + c->flags = dval; 303 304 c->loc.count = s->loc_count; 304 305 c->loc.size = s->loc_size; 305 306 306 307 if (c->flags & HIO_VARIABLE) { 307 308 /* range check usage count */ 308 - if (c->loc.count > 255) { 309 + if (c->loc.count > MAXLOCCNT) { 309 310 DPRINTF("Number of " 310 - "items truncated to 255\n"); 311 - s->ncount = 255; 311 + "items truncated to %u\n", 312 + MAXLOCCNT); 313 + s->ncount = MAXLOCCNT; 312 314 } else 313 315 s->ncount = c->loc.count; 314 316 ··· 324 326 325 327 case 9: /* Output */ 326 328 c->kind = hid_output; 327 - c->flags = dval; 328 329 goto ret; 329 330 case 10: /* Collection */ 330 331 c->kind = hid_collection; ··· 335 336 return (1); 336 337 case 11: /* Feature */ 337 338 c->kind = hid_feature; 338 - c->flags = dval; 339 339 goto ret; 340 340 case 12: /* End collection */ 341 341 c->kind = hid_endcollection;