Vishnu V
April 3rd, 2010, 10:25 AM
Hi
I am trying to make a virtual keyboard. For that i want to insert values to keyboard buffer .How can i insert value into keyboard buffer of Linux using c/c++ or java
Thanks in advance
Have a nice day
heikaman
April 3rd, 2010, 09:59 PM
I don't think you can directly access the keyboard buffer, and don't think you should, however, you can use xlib to fake keyboard events, there's a good example here (http://www.doctort.org/adam/nerd-notes/x11-fake-keypress-event.html)
you can also use the XTest extension and let it handle all the low-level XEvent setup for you, here's a quick example:
1 #include <X11/Xlib.h>
2 #include <X11/keysym.h>
3 #include <X11/extensions/XTest.h>
4
5 int main(int argc, char **argv)
6 {
7 //open display
8 Display *display = XOpenDisplay(NULL);
9
10 //press and release
11 XTestFakeKeyEvent(display, XKeysymToKeycode(display, XK_A), True, CurrentTime);
12 XTestFakeKeyEvent(display, XKeysymToKeycode(display, XK_A), False, CurrentTime);
13
14 //flush and close
15 XFlush(display);
16 XCloseDisplay(display);
17 return 0;
18 }
compile:
gcc xtest.c -o xtest -lXtst
dependencies:
sudo apt-get install libxtst-dev
Vishnu V
April 4th, 2010, 01:03 PM
Thank you very much .
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.