On Sat, Jan 9, 2010 at 12:35 PM, Vijay Kumar wrote:
Saravanan S <dearsaravanan@...> writes:
Hi all,the
I used xmodmap to block few key strokes in my distro.
How to initiate/trigger a key combination like say (Ctrl+Shift+Y) as if
user has pressed those keys??
Keystrokes can be fed to the kernel using the uinput subsystem. The uinput
subsystem can be accessed through the device file /dev/uinput. But the
interface
is low-level. A wrapper library called libsuinput
http://codegrove.org/libsuinput/ makes things simpler. The code using the
wrapper library is given below. For the sake of simplicity error handling
code
has been omitted.
#include <suinput.h>
int main(void)
{
struct input_id id = {BUS_BLUETOOTH, 13, 3, 7};
int uinput_fd = suinput_open("HelloInput", &id);
suinput_press(uinput_fd, KEY_LEFTCTRL);
suinput_press(uinput_fd, KEY_LEFTSHIFT);
suinput_press(uinput_fd, KEY_Y);
suinput_release(uinput_fd, KEY_Y);
suinput_release(uinput_fd, KEY_LEFTSHIFT);
suinput_release(uinput_fd, KEY_LEFTCTRL);
return 0;
}
Note: You should have uinput module loaded into the kernel. You should have
sufficient privileges to access the device file.