I am trying to make sure that uinput is running/loaded and that it works.
I can not find the device with lsmod however I can find the file /dev/uinput, what does this mean?
I found some code through some googling which apparently tests uinput, it fails with “Unable to create UINPUT device.” printed to the terminal. The relevant code is the following:
if (ioctl(uinp_fd, UI_DEV_CREATE))
{
printf("Unable to create UINPUT device.");
return -1;
}
Full code can be read here: http://pastebin.com/tJdUgiDz
So my question goes something like this:
Is uinput loaded? If it is, why isn’t this code working properly?
Thanks.
It sounds like uinput is compiled into your kernel and is not a loadable module you’d see with lsmod. This is definitely the case on Ubuntu 12.04.
Your open is probably failing because of permissions problems.
You can run your program as root each time you run it
or create a udev rule to permanently allow any programs to use uinput. Copy paste commands below to create the correct rule on an ubuntu 12.04 system and restart the udev service to use it
If you care more about security you can setup rules for groups and setuid/setgid your executable.