I am playing with uinput by creating a virtual keyboard/mouse. I have no problem to set up the virtual device.
int fd;
struct uinput_user_dev uidev;
struct input_event ev;
int dx, dy;
int i;
fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
if(fd < 0)
die("error: open");
if(ioctl(fd, UI_SET_EVBIT, EV_KEY) < 0)
die("error: ioctl");
if(ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) < 0)
die("error: ioctl");
if(ioctl(fd, UI_SET_EVBIT, EV_REL) < 0)
die("error: ioctl");
if(ioctl(fd, UI_SET_RELBIT, REL_X) < 0)
die("error: ioctl");
if(ioctl(fd, UI_SET_RELBIT, REL_Y) < 0)
die("error: ioctl");
memset(&uidev, 0, sizeof(uidev));
snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "test");
uidev.id.bustype = BUS_USB;
uidev.id.vendor = 0x1;
uidev.id.product = 0x1;
uidev.id.version = 1;
write(fd, &uidev, sizeof(uidev))
ioctl(fd, UI_DEV_CREATE)
And I can write events in /dev/uinput. It is working like a charm, the mouse is moving or the keyboard is working.
However I don't understand where I can read the inputed events. I can read on /dev/input/mice the mouse and see the data of the virtual mouse. but /dev/input/mice is for all mice...
In which /dev/input/eventX should I read? I've tried to read all of them but there is nothing.
I read event0 for my usb mouse, event1 for the keyboard... but where can I read about my virtual device?