7

I want to read the input of (up to 4) keyboards attached the a computer in my own application.

My situation

For a small event I'd like to attach three USB barcode scanners to a laptop (having a keyboard)

By default, a barcode scanner simply work like a keyboard. If it scans a barcode it just enters the number and presses the "return" key. That's great and works out of the box.

For my application three barcode scanner will work simultaneous and might get in conflict with a default application. Also there should be an opinion to enter the barcode manually on the laptops keyboard.

The goal

Therefore I need to read the input of the four keyboards with my custom application (C++ or python) and handle them separately.

The environment

My specific environment is Ubuntu 11.04 on a laptop having three barcode scanners attached. The application is written either in C++ or python (depending on the answers to this question).

Thanks in advance for any hint or answer

1
  • the simplest approach might be to read the /dev filesystem and get data directly from the devices. I don't know the format or the exact files they are exposed through, so I'm not posting this as an answer, just a pointer to a direction to follow. Here for example I can see input from my mouse by doing sudo cat /dev/usb/hiddev0 | hexdump. Commented Apr 18, 2012 at 12:29

1 Answer 1

4

Why dont go to the device node

maybe found here cat /dev/input/by-path/yourDevice

and read the code here

like they do here

(Note: original link is broken but content may be found on web.archive.org)

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. Sounds good so far. I don't have the laptop here to test it immediately. I guess that this solution might work. The only problem which may occur, is that PS/2 keyboards are not listed there and I don't know what type the laptops own keyboard is (USB or PS/2). But in the worst case I simple attach a default USB keyboard for manually inputs. Thank you so far! I'll give feedback as soon as I tested it. :)
Works perfectly. Even the laptop keyboard can be found as device node.
The link in the answer is broken.
@ProgrammerPaul - updated answer with web.archive.org link to original content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.