mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2026-05-04 17:37:59 +02:00
Work around missing EVIOCGMTSLOTS ioctl
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
ae738d29ea
commit
306f856f67
1 changed files with 12 additions and 2 deletions
|
|
@ -498,11 +498,14 @@ sync_mt_state(struct libevdev *dev, int create_events)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
|
int ioctl_success = 0;
|
||||||
struct mt_state {
|
struct mt_state {
|
||||||
int code;
|
int code;
|
||||||
int val[MAX_SLOTS];
|
int val[MAX_SLOTS];
|
||||||
} mt_state[ABS_MT_CNT];
|
} mt_state[ABS_MT_CNT];
|
||||||
|
|
||||||
|
memset(&mt_state, 0, sizeof(mt_state));
|
||||||
|
|
||||||
for (i = ABS_MT_MIN; i <= ABS_MT_MAX; i++) {
|
for (i = ABS_MT_MIN; i <= ABS_MT_MAX; i++) {
|
||||||
int idx;
|
int idx;
|
||||||
if (i == ABS_MT_SLOT)
|
if (i == ABS_MT_SLOT)
|
||||||
|
|
@ -514,8 +517,15 @@ sync_mt_state(struct libevdev *dev, int create_events)
|
||||||
idx = i - ABS_MT_MIN;
|
idx = i - ABS_MT_MIN;
|
||||||
mt_state[idx].code = i;
|
mt_state[idx].code = i;
|
||||||
rc = ioctl(dev->fd, EVIOCGMTSLOTS(sizeof(struct mt_state)), &mt_state[idx]);
|
rc = ioctl(dev->fd, EVIOCGMTSLOTS(sizeof(struct mt_state)), &mt_state[idx]);
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
goto out;
|
/* if the first ioctl fails with -EINVAL, chances are the kernel
|
||||||
|
doesn't support the ioctl. Simply continue */
|
||||||
|
if (errno == -EINVAL && !ioctl_success) {
|
||||||
|
rc = 0;
|
||||||
|
} else /* if the second, ... ioctl fails, really fail */
|
||||||
|
goto out;
|
||||||
|
} else if (ioctl_success == 0)
|
||||||
|
ioctl_success = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < dev->num_slots; i++) {
|
for (i = 0; i < dev->num_slots; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue