Skip to content

Instantly share code, notes, and snippets.

@mmn80
mmn80 / detect_kbd_devices.c
Created December 19, 2012 14:43 — forked from anonymous/detect_kbd_devices.c
Uses libudev to detect all keyboard input event devices (/dev/input/eventX). Based on the /usr/lib/udev/findkeyboards script.
#include <libudev.h>
#define MAX_KBD_DEVICES 10
const char** detect_kbd_devices()
{
const char **devnodes = calloc(MAX_KBD_DEVICES, sizeof(char*));
struct udev *udev;
struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device *dev;