test: fix uinput creation for the slotted devices with too many slots

Kernel commit 206f533a0a7c
       "Input: uinput - reject requests with unreasonable number of slots"
limits the number of slots to 99 - let's manually adjust that so we can
keep creating uinput devices.

Since these are just a test device and we don't use the slots here
anyway (they're all fake MT devices) we can manually work around this.
The real devices won't be affected by this since this is a limitation
in uinput, not the input subsystem.

Also move the comment one line up in the ms-surface device, the previous
comment referred to the wrong event code.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1061>
This commit is contained in:
Peter Hutterer 2024-10-14 19:29:15 +10:00
parent c123a76b0d
commit aecfcf3d1b
5 changed files with 29 additions and 6 deletions

View file

@ -193,7 +193,10 @@ static struct input_absinfo absinfo[] = {
{ 0x2c, 0, 255, 0, 0, 0 },
{ 0x2d, 0, 255, 0, 0, 0 },
{ 0x2e, 0, 255, 0, 0, 0 },
{ ABS_MT_SLOT, 0, 255, 0, 0, 0 },
/* Note: slot count artificially reduced for kernel
* commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
*/
{ ABS_MT_SLOT, 0, 64, 0, 0, 0 },
{ ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0, 0 },
{ ABS_MT_TOUCH_MINOR, 0, 255, 0, 0, 0 },
{ ABS_MT_WIDTH_MINOR, 0, 255, 0, 0, 0 },

View file

@ -309,7 +309,10 @@ static struct input_absinfo absinfo[] = {
{ 0x2c, 0, 255, 0, 0, 0 },
{ 0x2d, 0, 255, 0, 0, 0 },
{ 0x2e, 0, 255, 0, 0, 0 },
{ 0x2f, 0, 255, 0, 0, 0 },
/* Note: slot count artificially reduced for kernel
* commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
*/
{ 0x2f, 0, 64, 0, 0, 0 },
{ 0x30, 0, 255, 0, 0, 0 },
{ 0x31, 0, 255, 0, 0, 0 },
{ 0x32, 0, 255, 0, 0, 0 },

View file

@ -307,7 +307,10 @@ static struct input_absinfo absinfo[] = {
{ 0x2c, 0, 255, 0, 0, 0 },
{ 0x2d, 0, 255, 0, 0, 0 },
{ 0x2e, 0, 255, 0, 0, 0 },
{ 0x2f, 0, 255, 0, 0, 0 },
/* Note: slot count artificially reduced for kernel
* commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
*/
{ 0x2f, 0, 64, 0, 0, 0 },
{ 0x30, 0, 255, 0, 0, 0 },
{ 0x31, 0, 255, 0, 0, 0 },
{ 0x32, 0, 255, 0, 0, 0 },

View file

@ -63,9 +63,12 @@ static struct input_absinfo absinfo[] = {
{ 44, -127, 127, 0, 0, 0 },
{ 45, -127, 127, 0, 0, 0 },
{ 46, -127, 127, 0, 0, 0 },
{ 47, -127, 127, 0, 0, 0 },
/* ABS_MT range overlap starts here */
{ 48, -127, 127, 0, 0, 0 }, /* ABS_MT_SLOT */
/* Note: slot count artificially reduced for kernel
* commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots")
*/
{ 47, 0, 64, 0, 0, 0 }, /* ABS_MT_SLOT */
{ 48, -127, 127, 0, 0, 0 },
{ 49, -127, 127, 0, 0, 0 },
{ 50, -127, 127, 0, 0, 0 },
{ 51, -127, 127, 0, 0, 0 },

View file

@ -3451,6 +3451,15 @@ litest_create_uinput(const char *name,
.flat = 0,
.resolution = 100
};
/* See kernel commit 206f533a0a7c ("Input: uinput - reject requests with unreasonable number of slots") */
const struct input_absinfo default_abs_mt_slot = {
.value = 0,
.minimum = 0,
.maximum = 64,
.fuzz = 0,
.flat = 0,
.resolution = 100
};
char buf[512];
dev = libevdev_new();
@ -3483,8 +3492,10 @@ litest_create_uinput(const char *name,
if (type == INPUT_PROP_MAX) {
rc = libevdev_enable_property(dev, code);
} else {
const struct input_absinfo *abs =
(code == ABS_MT_SLOT) ? &default_abs_mt_slot : &default_abs;
rc = libevdev_enable_event_code(dev, type, code,
type == EV_ABS ? &default_abs : NULL);
type == EV_ABS ? abs : NULL);
}
litest_assert_int_eq(rc, 0);
}