View Single Post
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#15
Eureka!


I got the XTestFakeKeyEvent working at Qt:

First, this works only at the Maemo target, not the Simulator. So:

Code:
#ifdef Q_WS_MAEMO_5
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#endif
Now you are able to send a keycode:

Code:
unsigned int ukeycode = XKeysymToKeycode(QX11Info::display(), KeySym);
bool ret = XTestFakeKeyEvent(QX11Info::display(), ukeycode, state, 0);
state is the press state: true = pressed / false = released

And finally this was the reason I lost some hairs - Include this into your *.pro file:
Code:
LIBS = -lX11 -lXtst
It works a lot faster and less recource hungry than calling the external binary xdotool.

Sadly I got a lot of problems to translate keycodes from a windows desktop pc to a linux maemo 5 device. And sometimes it suddenly stops working. I still have to figure out why.

If someone has some tipps, I would be glad to read it.

Ah, and by the way. How to disable the keyboard repeat rate at Qt QML? Any Ideas?
__________________
I was a Qt Ambassador!

Please DONATE if you like my work!
It's the best way to motivate me to create more stuff for your Device.