[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    Re: using uinput connect X to proprietary (TCP based) keyboard endpoint
From:       Aaron Plattner <aplattner () nvidia ! com>
Date:       2014-10-23 15:24:27
Message-ID: 54491DAB.2080501 () nvidia ! com
[Download RAW message or body]

On 10/16/2014 08:12 AM, Peter Hutterer wrote:
> On Thu, Oct 16, 2014 at 04:48:37AM +0200, Arne.Adams@t-online.de wrote:
> > Hi,
> > I am trying to integrate a proprietary keyboard, sending linux scancodes via TCP.
> > My idea is to use uinput to forward the received keycodes to locally running \
> > applications (including the x server). In my xorg.conf I have the following \
> > section: 
> > Section "InputDevice"
> > # to enable user defined virtual keyboard
> > Identifier     "Keyboard1"
> > Option         "Device" "/dev/input/event14"
> > Driver         "evdev"
> > EndSection
> > where event14 is the event queue associated to the uinput simulated "device".
> > I do see the scancodes sent from my device with both commands:
> > - xinput test-xi2 --root
> > -  showkey -s
> > However I am not able to intercept the keyboard events in this simple X \
> > application 
> > int main(int argc, char** argv)
> > {
> > Display* display = XOpenDisplay(NULL);
> > Window window = XCreateSimpleWindow(display, RootWindow(display, 0), 1, 1, 500, \
> > 500, 0, BlackPixel(display, 0), BlackPixel(display, 0));
> > XSelectInput(display, window, KeyPressMask | KeyReleaseMask);
> > XMapWindow(display, window);
> 
> 
> add a XFlush() here, that should do the trick.

XNextEvent implicitly flushes.

> Cheers,
> Peter
> 
> > XEvent report;
> > while (1)
> > {
> > XNextEvent(display, &report);
> > switch (report.type)
> > {
> > case KeyRelease:
> > printf("got a KeyRelease event: %d, %d\n", report.xkey.keycode, \
> > report.xkey.state); break;
> > case KeyPress:
> > printf("got a KeyPress event: %d, %d\n", report.xkey.keycode, report.xkey.state);
> > break;
> > default:
> > printf("got a %d event\n", report.type);
> > break;
> > 
> > }
> > }
> > XFlush(display);
> > sleep(5);
> > return (EXIT_SUCCESS);
> > }

-- 
Aaron
_______________________________________________
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic