Move slot-related initialization down

No real effects, but improves readability

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Peter Hutterer 2014-04-01 15:40:09 +10:00
parent f8fba5b588
commit 27df93737e

View file

@ -379,19 +379,27 @@ libevdev_set_fd(struct libevdev* dev, int fd)
goto out; goto out;
dev->abs_info[i] = abs_info; dev->abs_info[i] = abs_info;
}
}
dev->fd = fd;
/* devices with ABS_MT_SLOT - 1 aren't MT devices, /* devices with ABS_MT_SLOT - 1 aren't MT devices,
see the documentation for multitouch-related see the documentation for multitouch-related
functions for more details */ functions for more details */
if (i == ABS_MT_SLOT && if (!libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT - 1) &&
!libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT - 1)) { libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT)) {
dev->num_slots = abs_info.maximum + 1; const struct input_absinfo *abs_info;
abs_info = libevdev_get_abs_info(dev, ABS_MT_SLOT);
dev->num_slots = abs_info->maximum + 1;
dev->mt_slot_vals = calloc(dev->num_slots * ABS_MT_CNT, sizeof(int)); dev->mt_slot_vals = calloc(dev->num_slots * ABS_MT_CNT, sizeof(int));
if (!dev->mt_slot_vals) { if (!dev->mt_slot_vals) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
dev->current_slot = abs_info.value; dev->current_slot = abs_info->value;
dev->mt_sync.mt_state_sz = sizeof(*dev->mt_sync.mt_state) + dev->mt_sync.mt_state_sz = sizeof(*dev->mt_sync.mt_state) +
(dev->num_slots) * sizeof(int); (dev->num_slots) * sizeof(int);
@ -409,14 +417,9 @@ libevdev_set_fd(struct libevdev* dev, int fd)
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
}
}
}
dev->fd = fd;
if (!libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT - 1) &&
libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT))
sync_mt_state(dev, 0); sync_mt_state(dev, 0);
}
rc = init_event_queue(dev); rc = init_event_queue(dev);
if (rc < 0) { if (rc < 0) {