How can i detect presence of USB keyboard from user space program ?

Hi all,

I have written a user space program which traps keyboard input from several input sources using select() function on the /dev/input/eventX files.

It works nicely, but how can i detect from that same program if user decides to pull-out a USB connected keyboard or insert another in the USB port of the embedded Linux system ?

B.Rgds. Peter Denmark

Reply to
pweichel
Loading thread data ...

Take a look at libusb

--
Marco Cavallini
=====================================================
 Click to see the full signature
Reply to
Marco Cavallini

The kernel is running the /sbin/hotplug executable in such a case. Do whatever yo need to do in this executabole which could be any kind of executable (bash-script,ELF-binary, etc.). You could simply send a signal from /sbin/hotplug to your Process which causes it to reopen devices e.g.

Sven

--
"If you continue running Windows, your system may become unstable."
(Windows 95 BSOD)
 Click to see the full signature
Reply to
Sven Geggus

Hi Sven,

Thank you for your input.

The /sbin/hotplug is not default installed on my ARM board running embedded Linux version 2.6.13.2. Is it a shell program or a binary executable ? Can it be cross compiled if binary ?

How can it "signal" my process ? Can it for example send a message or is it by calling another binary program ? Does hotplug tell mee which device i.e. keyboard, barcode scanner or other USB device has been changed ?

Peter

Reply to
pweichel

Ummm... Google for hotplug - 1st hit.

formatting link

Reply to
Captain Dondo

Whatever you wand it to be. The Standard Linux hotplug script is written in bash and is somewhat slow for this reason. Have a look at

formatting link
for details.

I use a very small script in one of my applications for detecting USB events instead of the Standard script.

Using kill from whithin a shell-script or corresponding system-call from C.

Sven

--
Der "normale Bürger" ist nicht an der TU Dresden und schreibt auch
nicht mit mutt. (Ulli Kuhnle in de.comp.os.unix.discussion)
 Click to see the full signature
Reply to
Sven Geggus

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.