Operating a USB-HID Barcode Scanner

Guillaume Bouchard guillaume.bouchard at insa-lyon.fr
Mon Sep 6 07:55:02 PDT 2010


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.)

> On 09/06/10 13:50, Klaus Gradinger wrote:
> The Problem is that everything that is scanned just gets written (in plain
> text) do stdin. I'm currently developing a Java Application where that
> behavior is unacceptable (because of the lack of an input field). A solution,
> which i would prefer, would be if all text  (already translated from events
> to plain text) coming from the reader would get redirected into a named pipe
> or something similar. Is there any way to achieve this? The second solution
> which I don't prefer at all would be to open the /dev/input/... scanner
> device within Java, read the byte stream and parse the key down / key up
> events myself.
> 
> Target Platform is Ubuntu 10.04 Desktop.
> 
> I'd highly appreciate it, if someone could point me in the right direction.

I had the same issues some years ago. At this time I wanted to be able to use
the keyboard and the barecode reader "at the same time" to do different stuffs
and more specifically, I do not want to force the user to focus the input field
for the barcode reader. 

At that time, the only solution I found was to use raw data from /dev/input.
It's not too hard and I may found you the code I used at that time if you wish.
But I agree it's really crappy.

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



More information about the xorg mailing list