ratbagd: ignore anything but event devices

We are only interested in evdev, so ignore anything but input-event
devices.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
David Herrmann
2015-09-25 15:57:14 +02:00
parent 8ca0c11154
commit 17d66153b0
2 changed files with 20 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ static void ratbagd_process_device(struct ratbagd *ctx,
*/
name = udev_device_get_sysname(udevice);
if (!name)
if (!name || !startswith(name, "event"))
return;
device = ratbagd_find_device(ctx, name);

View File

@@ -185,6 +185,25 @@ static inline bool streq_ptr(const char *a, const char *b)
return (a && b) ? streq(a, b) : (!a && !b);
}
/*
* startswith() - test prefix of a string
* @s: string to test
* @prefix: prefix to test for
*
* This returns a pointer to the first character in @s that follows @prefix. If
* @s does not start with @prefix, NULL is returned.
*/
static inline char *startswith(const char *s, const char *prefix)
{
size_t l;
l = strlen(prefix);
if (strncmp(s, prefix, l) == 0)
return (char*) s + l;
return NULL;
}
/*
* now() - returns current time in nano-seconds
* @clock: clock to use