I figured this out after some reading. On Mon, Nov 16, 2009 at 11:28 PM, Scott Sibley <sisib...@gmail.com> wrote:
> > Hello. I'm writing an LCD controller, and one feature I'd like is the > ability to interact with an LCD via the keyboard. I have the following code, > but only the FocusOut/FocusIn events are firing. > > > static Window GetCurrWindow(Display *d) { > Window foo; > Window win; > int bar; > > do{ > (void) XQueryPointer(d, DefaultRootWindow(d), &foo, &win, > &bar, &bar, &bar, &bar, (unsigned int *)&bar); > } while(win <= 0); > return(win); > } > > void PluginKeyboard::PluginPoll() { > Display *dpy = XOpenDisplay(NULL); > if(!dpy) { > LCDError("PluginKeyboard: Unable to open display."); > return; > } > > Window w = GetCurrWindow(dpy); > XSelectInput(dpy, w, FocusChangeMask|KeyPressMask|KeyReleaseMask); > while(started_) { > > if(!XPending(dpy)) > continue; > > XEvent event; > char str[256+1]; > KeySym ks; > char keycode; > int c; > > XNextEvent(dpy, &event); > > if(event.type == KeyPress) { > c = XLookupString((XKeyEvent *)&event, str, 256, &ks, NULL); > > LCDError("KeyPressed"); > if(c!=0) > continue; > > keycode = XKeysymToKeycode(dpy, ks); > > emit _KeyPressed(keycode); > LCDError("Keypressed: %d", keycode); > } > > if(event.type == KeyRelease) { > c = XLookupString((XKeyEvent *)&event, str, 256, &ks, NULL); > > if(c!=0) > continue; > > keycode = XKeysymToKeycode(dpy, ks); > > emit _KeyReleased(keycode); > } > > if(event.type == FocusOut) { > LCDError("FocusOut"); > XSelectInput(dpy, w = GetCurrWindow(dpy), > FocusChangeMask|KeyPressMask|KeyReleaseMask); > } > > } > } > > >
_______________________________________________ xorg mailing list xorg@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/xorg