Capturing keyboard events without window focus
Chris Weiland
hobbiticus at gmail.com
Sat Jun 2 12:53:23 PDT 2007
I'm writing a cross-platform voice communication application similar to
teamspeak or ventrilo. One of the key features for such an application is
the ability to hold down a key to transmit. However, the application won't
usually have focus while it is in use but still needs to capture key up/down
events so that it knows when to transmit.
It seems as though I can query wxGetKeyState() for my transmit key in order
to accomplish this, but it doesn't quite get me there. First of all,
wxGetKeyState does not handle toggle buttons like capslock in the same way
as other keys. It returns true when capslock is on and false when capslock
is off, regardless if the actual key is pressed or not. Second, if I call
wxGetKeyState in my recording callback function (which is the simplest, but
perhaps not the best implementation), it works just fine on windows. But on
linux, I get a line (once) on the console that says:
Xlib: unexpected async reply (sequence 0x948)!
and my program becomes unresponsive.
I could create a separate thread that queries wxGetKeyState every so often,
which might solve that problem (assuming it fails because of how often the
recording callback runs), but still wouldn't solve the problem of toggle
keys.
So, is there another/better way of doing this within wxWidgets, or will I
have to find another (likely platform-dependent) solution to this?
Specifically, I'm looking for an implementation that would work on linux, as
I know that DirectInput can do this for me on windows.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070602/80d=
d62c2/attachment.htm
More information about the wx-users
mailing list