v3.4 was released in 2012, every kernel since has that ioctl. So instead of
assuming you're running new libevdev on an 8 year old kernel, let's assume
that any error from the ioctl() is an actual error and handle it accordingly.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
struct input_absinfo abs_info;
int rc;
int axis, slot;
struct input_absinfo abs_info;
int rc;
int axis, slot;
int last_reported_slot = 0;
struct mt_sync_state *mt_state = dev->mt_sync.mt_state;
unsigned long *slot_update = dev->mt_sync.slot_update;
int last_reported_slot = 0;
struct mt_sync_state *mt_state = dev->mt_sync.mt_state;
unsigned long *slot_update = dev->mt_sync.slot_update;
mt_state->code = axis;
rc = ioctl(dev->fd, EVIOCGMTSLOTS(dev->mt_sync.mt_state_sz), mt_state);
mt_state->code = axis;
rc = ioctl(dev->fd, EVIOCGMTSLOTS(dev->mt_sync.mt_state_sz), mt_state);
- if (rc < 0) {
- /* 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 (slot = 0; slot < dev->num_slots; slot++) {
-
- if (*slot_value(dev, slot, axis) == mt_state->val[slot])
- continue;
+ if (rc < 0)
+ goto out;
- if (axis == ABS_MT_TRACKING_ID &&
- *slot_value(dev, slot, axis) != -1 &&
- mt_state->val[slot] != -1) {
- set_bit(tracking_id_changes, slot);
- need_tracking_id_changes = 1;
- }
+ for (slot = 0; slot < dev->num_slots; slot++) {
- *slot_value(dev, slot, axis) = mt_state->val[slot];
+ if (*slot_value(dev, slot, axis) == mt_state->val[slot])
+ continue;
- set_bit(slot_update, AXISBIT(slot, axis));
- /* note that this slot has updates */
- set_bit(slot_update, AXISBIT(slot, ABS_MT_SLOT));
+ if (axis == ABS_MT_TRACKING_ID &&
+ *slot_value(dev, slot, axis) != -1 &&
+ mt_state->val[slot] != -1) {
+ set_bit(tracking_id_changes, slot);
+ need_tracking_id_changes = 1;
+ *slot_value(dev, slot, axis) = mt_state->val[slot];
+
+ set_bit(slot_update, AXISBIT(slot, axis));
+ /* note that this slot has updates */
+ set_bit(slot_update, AXISBIT(slot, ABS_MT_SLOT));