View Single Post
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#6
Originally Posted by vi_ View Post
xte is somwhere
I'm currently able to send "strings" using xvkbd
Sadly, it seems, it supports exactly as xte only strings. So I have to translate from the keycode to the string and call the shell command afterwards.

It works but feels very ugly, is very slow and resource hungry.

I found this piece of code:

Code:
#include <X11/extensions/XTest.h>
#include <stdio.h>

#define KEY_DOWN True
#define KEY_UP   False

#define KEY_MOD 37

int main(int argc, char *argv[]) {
  int i;
  char c;

  Display *dpy = XOpenDisplay(NULL);
  if (!dpy) return 1;
  for (i=1; i<argc; i++) {
    c=atoi (argv[i]);
    printf ("<%u>\n", c);
    XTestFakeKeyEvent(dpy, c, KEY_DOWN, CurrentTime);
    XTestFakeKeyEvent(dpy, c, KEY_UP, CurrentTime);
  }
  XCloseDisplay(dpy);
  return 0;
}
The "X11/extensions/XTest.h" is breaking my neck immediately in the first line.

I guess my C++ skills are still to weak. (learing since several months) Am I able to include this and XTestFakeKeyEvent in my Qt Project without bending over backwards?

At MeeGo there is a elegant way to send keycodes using DBus: maliit.org
But it seems this works only on MeeGo, not Fremantle maemo5.
__________________
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.