I figured this out after some reading.<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 11:28 PM, Scott Sibley <span dir="ltr"><<a href="mailto:sisibley@gmail.com">sisibley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>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.<div><div></div>
<div class="h5"><br><div class="gmail_quote">
<br>static Window GetCurrWindow(Display *d) {<br>
    Window foo;<br>    Window win;<br>    int bar;<br><br>    do{<br>        (void) XQueryPointer(d, DefaultRootWindow(d), &foo, &win,<br>            &bar, &bar, &bar, &bar, (unsigned int *)&bar);<br>


    } while(win <= 0);<br>    return(win);<br>}<br><br>void PluginKeyboard::PluginPoll() {<br>    Display *dpy = XOpenDisplay(NULL);<br>    if(!dpy) {<br>        LCDError("PluginKeyboard: Unable to open display.");<br>


        return;<br>    }<br><br>    Window w = GetCurrWindow(dpy);<br>    XSelectInput(dpy, w, FocusChangeMask|KeyPressMask|KeyReleaseMask);<br>    while(started_) {<br><br>        if(!XPending(dpy))<br>            continue;<br>


<br>        XEvent event;<br>        char str[256+1];<br>        KeySym ks;<br>        char keycode;<br>        int c;<br><br>        XNextEvent(dpy, &event);<br><br>        if(event.type == KeyPress) {<br>            c = XLookupString((XKeyEvent *)&event, str, 256, &ks, NULL);<br>


<br>            LCDError("KeyPressed");<br>            if(c!=0)<br>                continue;<br><br>            keycode = XKeysymToKeycode(dpy, ks);<br><br>            emit _KeyPressed(keycode);<br>            LCDError("Keypressed: %d", keycode);<br>


        }<br><br>        if(event.type == KeyRelease) {<br>            c = XLookupString((XKeyEvent *)&event, str, 256, &ks, NULL);<br><br>            if(c!=0)<br>                continue;<br><br>            keycode = XKeysymToKeycode(dpy, ks);<br>


<br>            emit _KeyReleased(keycode);<br>        }<br><br>        if(event.type == FocusOut) {<br>            LCDError("FocusOut");<br>            XSelectInput(dpy, w = GetCurrWindow(dpy),<br>                FocusChangeMask|KeyPressMask|KeyReleaseMask);<br>


        }<br><br>    }<br>}<br><br>
</div><br>
</div></div></blockquote></div><br>