Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you take ownership of a hid device?

Tags:

What I would like to take ownership of a hid device that may already have been plugged in, consume it's output, while preventing others(X11 or terminal) from consuming it.

If I can help it, I don't want to pretend to be a terminal, but rather to monopolize a particular hid or character device. The idea is that some hid devices may be recognized as mice/keyboards by x/terminal, but a second mouse or keyboard could be used for something else, but to do that you need to make sure they aren't sending spurious input into an open terminal.

Does anyone have any insight as to how this might be done?

like image 823
Catskul Avatar asked Nov 08 '09 23:11

Catskul


People also ask

What is HID compliance?

Universal Serial Bus devices are used to connect various components to a computer. A HID (Human Interface Device) compliant USB follows a specific protocol for communication that allows it to be used with virtually any system.

How do I find my HID number?

Use *67 to hide your phone number This trick works for smartphones and landlines. Open your phone's keypad and dial * – 6 – 7, followed by the number you're trying to call. The free process hides your number, which will show up on the other end as “Private” or “Blocked” when reading on caller ID.

How does HID device work?

In the HID protocol, there are 2 entities: the "host" and the "device". The device is the entity that directly interacts with a human, such as a keyboard or mouse. The host communicates with the device and receives input data from the device on actions performed by the human.

What is USB HID protocol?

In computing, the USB human interface device class (USB HID class) is a part of the USB specification for computer peripherals: it specifies a device class (a type of computer hardware) for human interface devices such as keyboards, mice, game controllers and alphanumeric display devices.


1 Answers

I have done this - my specific application was a daemon that read events from a USB HID barcode reader (which presents as a USB HID keyboard device).

To do this I used the event device interface, opening the /dev/input/event* device corresponding to the device I was after. You can then issue the EVIOCGRAB ioctl on the device, which grabs it for exclusive use, and read events (which represent keypresses, mouse movements etc) from the device as they become available.

(When the device is grabbed for exclusive use, only your application will see events from it).

like image 144
caf Avatar answered Oct 03 '22 11:10

caf