Dashboard January 2007 Issue
Mehul Patel
Using uinput driver in Linux-
2.6.x to send user input
Dashboard January 2007 Issue
Using uinput driver in Linux-2.6.x to send user
input
Introduction:
The Linux 2.6.x provides a “uinput” driver, which helps users to inject data to the Linux kernel.
This is very useful while writing applications to interface customized input devices like wireless
joystick, keyboard etc.
The driver uses /dev/uinput device to send data to kernel space which in turn send data to Xwindows
OR active shell. This feature can be used to perform automated shell scripts which
involve graphical user inputs.
Uinput is configured as a loadable module in most of the Linux kernels. You can load uinput
driver by giving the following commands.
$ modprobe uinput
$ lsmod
The “lsmod” command lists all the drivers loaded in the Linux system. You should see “uinput”
driver in the list.
The next step is to develop a sample application. This application will send the user key
sequence to kernel which is in turn sent to X-Windows or shell.
Opening an input device:
// Open the input device
uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
if (uinp_fd == NULL)
{
printf("Unable to open /dev/uinput/n");
return -1;
}
After opening device you have to configure