mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 18:30:07 +01:00
test: write resolution for uinput devices after creating the device
EVIOCSABS allows us to set the device's abs axes to the desired resolution. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0fde598ef5
commit
a05b1880e1
1 changed files with 24 additions and 3 deletions
|
|
@ -185,7 +185,7 @@ inotify_setup()
|
|||
int
|
||||
uinput_device_create(struct uinput_device* d)
|
||||
{
|
||||
int type;
|
||||
int type, code;
|
||||
struct uinput_user_dev dev;
|
||||
int rc;
|
||||
int fd;
|
||||
|
|
@ -203,7 +203,6 @@ uinput_device_create(struct uinput_device* d)
|
|||
dev.id = d->d.ids;
|
||||
|
||||
for (type = 0; type < EV_MAX; type++) {
|
||||
int code;
|
||||
int max;
|
||||
int uinput_bit;
|
||||
const unsigned long *mask;
|
||||
|
|
@ -246,7 +245,8 @@ uinput_device_create(struct uinput_device* d)
|
|||
dev.absmax[code] = d->d.abs_info[code].maximum;
|
||||
dev.absfuzz[code] = d->d.abs_info[code].fuzz;
|
||||
dev.absflat[code] = d->d.abs_info[code].flat;
|
||||
/* FIXME: uinput has no resolution */
|
||||
/* uinput has no resolution in the device struct, we use
|
||||
* EVIOCSABS below */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -274,6 +274,27 @@ uinput_device_create(struct uinput_device* d)
|
|||
if (d->dev_fd == -1)
|
||||
goto error;
|
||||
|
||||
/* write abs resolution now */
|
||||
if (bit_is_set(d->d.bits, EV_ABS)) {
|
||||
for (code = 0; code < ABS_MAX; code++ ) {
|
||||
struct input_absinfo *abs;
|
||||
|
||||
/* can't change slots */
|
||||
if (code == ABS_MT_SLOT)
|
||||
continue;
|
||||
|
||||
if (!bit_is_set(d->d.abs_bits, code))
|
||||
continue;
|
||||
|
||||
abs = &d->d.abs_info[code];
|
||||
rc = ioctl(d->dev_fd, EVIOCSABS(code), abs);
|
||||
if (rc < 0) {
|
||||
printf("error %s for code %d\n", strerror(-rc), code);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue