Problems with XTestFakeKeyEvent()

Sid Kapoor sidkapoor2000 at gmail.com
Fri May 15 00:15:35 PDT 2009


Hi,

I am trying to run a small code to turn ON the CAPS LOCK on my keyboard. I
have written a small code for this in xsetcapslock.c file.

/************************************************************* Code Starts
Here ****************************************/

#include <X11/extensions/XTest.h>

#include <X11/keysym.h>

#include <unistd.h>

int main(void)

{

Display* disp = XOpenDisplay(NULL);

if (disp == NULL) return 1;

XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Caps_Lock), True,
CurrentTime);

XTestFakeKeyEvent(disp, XKeysymToKeycode(disp, XK_Caps_Lock), False,
CurrentTime);

XCloseDisplay(disp);

return 0;

}
/************************************************************* Code Ends
Here ****************************************/

I am compiling the code as :

gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o xsetcapslock xsetcapslock.c
-lX11 -lXtst
 The normal behaviour of the binary as seen in the code, is to turn ON the
Caps Lock feature and the CAPS LOCK LED on the keyboard by sending a fake
key event of Caps Lock. This binary xsetcapslock works fine with Xorg-1.2.0
or Xorg 1.6.0, but with Xorg-1.5.1 the feature of CAPS LOCK is turned ON in
my keyboard, but the LED for Caps Lock is not glowing.

The problem is same for all the other LEDs, i.e., NUM LOCK and SCROLL LOCK.
Is this a bug in Xorg-1.5.1 ? Please help.

Thanks,

Siddharth Kapoor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20090515/f4ab245f/attachment.html>


More information about the xorg mailing list