On Mon, Sep 06, 2010 at 05:30:51PM +0200, Klaus Gradinger wrote: > On Mon, Sep 6, 2010 at 4:55 PM, Guillaume Bouchard < > [email protected]> wrote: > > > Hello, > > > > (HS: Sorry for answering this mail and not the original one from Klaus > > Gradinger, > > but I deleted his mail and feel attracted by the topic when reading that > > one.) > > > > But, I come with another solution, which may be possible now with the > > xinput2 > > protocol. It appear that X may be able to work with different inputs (I'm > > sure > > for mice, but what about keyboard support ?) and grab only one of them. > > > > So, if this works, the solution may be to grab your barcode keyboard with > > the > > main window of your application and let the other keyboard work as usuall > > with > > the rest of the system > > > > The only think you need is a toolkit which can handle that. There is a page > > about > > gtk support here http://live.gnome.org/GTK+/MPX > > > > I'm sure it may be possible to directly ask X for it, but I currently don't > > know how. > > > > Hope this (little) informations helps. If you comes with something, let me > > now, > > I have no need for that now (the /dev/input hacks works), but I'm still > > interested for a better solution. > > > > -- > > Guillaum > > > > Thanks for your response. > > When I've the time I'll definitely take a look at that possibility. I know > that mapping the key events isn't that hard but it's just... messy... > > I thought of a third solution: enabling and disabling the scanner using > xinput when it's needed / not needed. that way the user won't accidentally > scan barcodes when he's not supposed to. the down side of that is the need > for an input field that has the focus, but that's something i can manage > from within Java. i'm currently really thinking about sticking with that > solution because everything else seems just a little bit messy.. anything > "terrible wrong" with that idea?
If it wasn't Java, I'd say set the barcode scanner floating (XIChangeHierarchy) and grab the device (XIGrabDevice). that way you'll get all key events coming from that device and even when your app dies the scanner won't randomly add key events to text fields. then you need to look at the detail field in the XIDeviceEvents coming in and convert them to whatever number/key they represent. this is the proper solution, using xinput to en/disable the device is going to be a bit messy. Cheers, Peter _______________________________________________ [email protected]: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: [email protected]
