Reply
Thread Tools
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#1
Hi Guys!

Has anybody a idea how to send a keycode from my application in the background to the acutally running application in the foreground?

I would prefer a way that works similar at Maemo5 and MeeGo Tablet / Handset. It should feel for the target application like a normal hardware keyboard press.

What is the mostly common linux way to do this?
__________________
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.
 

The Following User Says Thank You to helex For This Useful Post:
Posts: 1,680 | Thanked: 3,685 times | Joined on Jan 2011
#2
Originally Posted by helex View Post
Hi Guys!

Has anybody a idea how to send a keycode from my application in the background to the acutally running application in the foreground?

I would prefer a way that works similar at Maemo5 and MeeGo Tablet / Handset. It should feel for the target application like a normal hardware keyboard press.

What is the mostly common linux way to do this?
xte maybe?
__________________
N900: One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die.
 

The Following User Says Thank You to vi_ For This Useful Post:
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#3
Originally Posted by vi_ View Post
xte maybe?
Yes, xte would be a good idea. But sadly not aviable at maemo or MeeGo.

I would if possible anyway prefer a proper working Qt class. But the only thing I found was QWSServer and sendKeyEvent. Sadly only for Qt Embedded.

Last edited by helex; 2011-07-19 at 19:05. Reason: Link added
 
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#4
No one?
__________________
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.
 
Posts: 1,680 | Thanked: 3,685 times | Joined on Jan 2011
#5
Originally Posted by helex View Post
No one?
xte is somwhere, qwerty12 used it in an early version of 'headphone-control'. It may not be in the repos, you just have to find it.

Maybe on that kumatux site?

At worst just get the debian armel package and extract the binary strait out of it.

Last edited by vi_; 2011-07-21 at 19:40.
 

The Following User Says Thank You to vi_ For This Useful 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.
 
Posts: 225 | Thanked: 105 times | Joined on May 2010
#7
Whats the difference to the non-extension XSendEvent?
 
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#8
I compiled xdotool before for the N900 - not .deb packaged let alone in the repositories, but I made a thread about it. (It does exactly what you want, if you're okay with doing it through the command line or having your app do it through the command line.)

Look under my account's statistics, all threads posted by me. It's called "[Announce] xdotool" or something like that.
 

The Following 2 Users Say Thank You to Mentalist Traceur For This Useful Post:
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#9
Originally Posted by Mentalist Traceur View Post
I compiled xdotool before for the N900 - not .deb packaged let alone in the repositories, but I made a thread about it. (It does exactly what you want, if you're okay with doing it through the command line or having your app do it through the command line.)
THANKS A LOT!
My small application works now. Not perfect, but rudimentary. Glad to see that I got my idea working. Will try to package your bin into my package. But I'm still searching for a better solution that accepts keycodes directly and not thru Characters. Preferential without using the commandline. Many combinations are still not working and I expect many language settings related problems in the near future...

Will create a new Thread as soon as I have the packaging done.
__________________
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.

Last edited by helex; 2011-07-29 at 21:09.
 
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#10
Originally Posted by helex View Post
THANKS A LOT!
My small application works now. Not perfect, but rudimentary. Glad to see that I got my idea working. Will try to package your bin into my package. But I'm still searching for a better solution that accepts keycodes directly and not thru Characters. Preferential without using the commandline. Many kombinations are still not working and I expect many language settings related problems in the near future...

Will create a new Thread as soon as I have the packaging done.
If you'd like, I'll just package xdotool and put it up in the repository - I don't think the autobuilder will let you put your app without all the source code in the normal way into the repos anyway, so one of us will have to do it eventually anyway - I might as well figure out how to package it and put it into the repos. It'll take a few days though, most likely.
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:32.