evdev: Combine evdev_handle_device() and evdev_configure_device()
We split the device probing and idenfication somewhat arbitrarily between these two functions. This commit combines them into one. Return of -1 indicates error, 0 success, but succesful probing can return a device with device->caps == 0, which means we don't handle the device.
This commit is contained in:
+7
-11
@@ -437,7 +437,7 @@ evdev_device_data(int fd, uint32_t mask, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
evdev_handle_device(struct evdev_device *device)
|
evdev_configure_device(struct evdev_device *device)
|
||||||
{
|
{
|
||||||
struct input_absinfo absinfo;
|
struct input_absinfo absinfo;
|
||||||
unsigned long ev_bits[NBITS(EV_MAX)];
|
unsigned long ev_bits[NBITS(EV_MAX)];
|
||||||
@@ -498,6 +498,7 @@ evdev_handle_device(struct evdev_device *device)
|
|||||||
if (!TEST_BIT(abs_bits, ABS_MT_SLOT)) {
|
if (!TEST_BIT(abs_bits, ABS_MT_SLOT)) {
|
||||||
device->mtdev = mtdev_new_open(device->fd);
|
device->mtdev = mtdev_new_open(device->fd);
|
||||||
if (!device->mtdev) {
|
if (!device->mtdev) {
|
||||||
|
device->caps = 0;
|
||||||
weston_log("mtdev required but failed to open for %s\n",
|
weston_log("mtdev required but failed to open for %s\n",
|
||||||
device->devnode);
|
device->devnode);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -557,15 +558,10 @@ evdev_handle_device(struct evdev_device *device)
|
|||||||
weston_log("input device %s, %s "
|
weston_log("input device %s, %s "
|
||||||
"ignored: unsupported device type\n",
|
"ignored: unsupported device type\n",
|
||||||
device->devname, device->devnode);
|
device->devname, device->devnode);
|
||||||
|
device->caps = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
evdev_configure_device(struct evdev_device *device)
|
|
||||||
{
|
|
||||||
if ((device->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL)) &&
|
if ((device->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL)) &&
|
||||||
(device->caps & EVDEV_BUTTON)) {
|
(device->caps & EVDEV_BUTTON)) {
|
||||||
weston_seat_init_pointer(device->seat);
|
weston_seat_init_pointer(device->seat);
|
||||||
@@ -625,14 +621,14 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
|
|||||||
devname[sizeof(devname) - 1] = '\0';
|
devname[sizeof(devname) - 1] = '\0';
|
||||||
device->devname = strdup(devname);
|
device->devname = strdup(devname);
|
||||||
|
|
||||||
if (!evdev_handle_device(device)) {
|
if (evdev_configure_device(device) == -1)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (device->seat_caps == 0) {
|
||||||
evdev_device_destroy(device);
|
evdev_device_destroy(device);
|
||||||
return EVDEV_UNHANDLED_DEVICE;
|
return EVDEV_UNHANDLED_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evdev_configure_device(device) == -1)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
/* If the dispatch was not set up use the fallback. */
|
/* If the dispatch was not set up use the fallback. */
|
||||||
if (device->dispatch == NULL)
|
if (device->dispatch == NULL)
|
||||||
device->dispatch = fallback_dispatch_create();
|
device->dispatch = fallback_dispatch_create();
|
||||||
|
|||||||
Reference in New Issue
Block a user