}
int
-libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code)
+libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type,
+ unsigned int code, const void *data)
{
int rc;
int uinput_bit;
}
rc = ioctl(dev->fd, uinput_bit, type);
- if (rc != -1)
- libevdev_enable_event_type(dev, type);
+ if (rc == -1)
+ goto out;
+ rc = libevdev_enable_event_type(dev, type);
+ if (rc == -1)
+ goto out;
+
+ /* FIXME: can't back out of this if it fails */
+ if (type == EV_ABS)
+ rc = libevdev_kernel_set_abs_value(dev, code, (const struct input_absinfo*)data);
+
+out:
return (rc != -1) ? 0 : -errno;
}
* This cannot be undone, the kernel only allows to enable axes, not disable
* them.
*
+ * The last argument depends on the type and code:
+ * - If type is EV_ABS, the vararg must be a pointer to a struct input_absinfo
+ * containing the data for this axis.
+ * - For all other types, the argument is ignored.
+ *
* This function calls libevdev_kernel_enable_event_type() if necessary.
*
* @param type The event type to enable (EV_ABS, EV_KEY, ...)
* @param code The event code to enable (ABS_X, REL_X, etc.)
+ * @param data Axis/key data, depending on type and code
*/
-int libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
+int libevdev_kernel_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
/**
* @ingroup kernel