Previous return value was the straight ioctl, we should try to avoid errno
mangling.
This changes the API, if not the ABI. Callers with code along the lines of
if (libinput_device_get_keys() == -1) will now break.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
int
evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size)
{
+ int len;
+
memset(keys, 0, size);
- return ioctl(device->fd, EVIOCGKEY(size), keys);
+ len = ioctl(device->fd, EVIOCGKEY(size), keys);
+
+ return (len == -1) ? -errno : len;
}
const char *
* @param device A current input device
* @param keys An array filled with the bitmask for the keys
* @param size Size of the keys array
+ *
+ * @return The number of valid bytes in keys, or a negative errno on failure
*/
int
libinput_device_get_keys(struct libinput_device *device,