Problems with XTestFakeKeyEvent()

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


Actually I want to tun ON CAPS LOCK and NUM LOCK feature in my keyboard (of
course with LEDs glowing) at the system start-up. Is there any other
alternative method to do that ?

Thanks,
Siddharth Kapoor

On Fri, May 15, 2009 at 12:45 PM, Sid Kapoor <sidkapoor2000 at gmail.com>wrote:

> 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
>



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


More information about the xorg mailing list