Re: [XFree86] XTestFakeKeyEvent() and key repetition
Hi I am sorry the answer took so long! I've just compiled your code and I get a lot 1 keys pressed dusrng 5 seconds, so your code does the job... or do I miss something? It generates a key press and five seconds later a key release. Nothing more, nothing less. No repetition at all. OK... I think you have to turn on autorepeat for the key(s). Take a look at the following man pages: XChangeKeyboardControl XAutoRepeatOn (and off) xev output: --8-- KeyPress event, serial 27, synthetic NO, window 0x221, root 0x89, subw 0x222, time 1828774, (37,45), root:(879,585), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 characters: 1 KeyRelease event, serial 27, synthetic NO, window 0x221, root 0x89, subw 0x222, time 1833774, (37,45), root:(879,585), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 characters: 1 --8-- I probably need to find another function... But it's working for you? It is! This is how I compiled (on GNU/Linux (Debian) + XFree86 + gcc): gcc testx.c -o testx -L/usr/X11R6/lib -lXtst -lX11 ./testx and yes, I called your snippet of code testx.c Yes, that's how I compile it too. Thanks for your time! :) */ Christoffer Sawicki [EMAIL PROTECTED] home.se -- Sweden I live in Gothenburg! ___ XFree86 mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/xfree86 ___ XFree86 mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/xfree86
Re: [XFree86] XTestFakeKeyEvent() and key repetition
Hallo To begin with, I let some other dudes test the program and I got different reports... :) It repeated for some, but not for all. You don't happen to be running 4.3? That could be an explanation. I think this has nothing to do with the version you/they are running. Someone has set you key to NOT be repeated. I think you should set your key(s) to autorepat. You can do it globally like this: #include X11/Xlib.h #include stdio.h int fake_me (Display *dpy) { XTestFakeKeyEvent(dpy, 10, True, 0); XFlush(dpy); sleep(2); XTestFakeKeyEvent(dpy, 10, False, 0); XFlush(dpy); } int main() { Display *dpy; dpy =XOpenDisplay(NULL); XAutoRepeatOn(dpy); fake_me(dpy); printf (-\n); fflush (stdout); XAutoRepeatOff(dpy); fake_me(dpy); printf (-\n); fflush (stdout); XAutoRepeatOn(dpy); fake_me(dpy); XCloseDisplay(dpy); } Which you can compile with: gcc -o autox autox.c -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXtst and yes, the file to save this crap into shalt be calleth: autox.c Does that work? Hi I am sorry the answer took so long! Oh, yes... I was beginning to get really mad at you! :) OK... I think you have to turn on autorepeat for the key(s). Take a look at the following man pages: XChangeKeyboardControl XAutoRepeatOn (and off) Thanks, I'll check them out. Well, get in with it;) ... and while you're at it: XGetKeyboardControl So why the hell are we writing in English? :) Vet ej! ___ XFree86 mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/xfree86
Re: [XFree86] XTestFakeKeyEvent() and key repetition
I've just compiled your code and I get a lot 1 keys pressed dusrng 5 seconds, so your code does the job... or do I miss something? It generates a key press and five seconds later a key release. Nothing more, nothing less. No repetition at all. xev output: --8-- KeyPress event, serial 27, synthetic NO, window 0x221, root 0x89, subw 0x222, time 1828774, (37,45), root:(879,585), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 characters: 1 KeyRelease event, serial 27, synthetic NO, window 0x221, root 0x89, subw 0x222, time 1833774, (37,45), root:(879,585), state 0x0, keycode 10 (keysym 0x31, 1), same_screen YES, XLookupString gives 1 characters: 1 --8-- I probably need to find another function... But it's working for you? This is how I compiled (on GNU/Linux (Debian) + XFree86 + gcc): gcc testx.c -o testx -L/usr/X11R6/lib -lXtst -lX11 ./testx and yes, I called your snippet of code testx.c Yes, that's how I compile it too. What X server etc are you running? XFree86 Version 4.2.1.1 (Debian 4.2.1-14 20031113215638 [EMAIL PROTECTED]) / X Window System (The latest in Debian Sid.) What is not working? Isn't the key repeated? Don't you want the key to repeat? It's not being repeated at all. I want it to be repeated just like if I had pressed the 1 button physically on my keyboard. Thanks for your time! */ Christoffer Sawicki [EMAIL PROTECTED] ___ XFree86 mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/xfree86
[XFree86] XTestFakeKeyEvent() and key repetition
Hello, I'm writing a program that turns joystick button presses and axis movements into X events via XTestFakeKeyEvent(). What I need to know is how to make the code snippet below act exactly like if I had held the 1 key (keycode 10) for 5 seconds. Any help appreciated. And yes, the code below is ugly. Please CC me, I'm not on the list. --8-- #include X11/Xlib.h #include X11/extensions/XTest.h int main() { Display *display = XOpenDisplay(NULL); XTestFakeKeyEvent(display, 10, True, 0); XFlush(display); sleep(5); XTestFakeKeyEvent(display, 10, False, 0); XFlush(display); XCloseDisplay(display); return 0; } --8-- */ Christoffer Sawicki [EMAIL PROTECTED] ___ XFree86 mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/xfree86