How can you take ownership of a hid device?

前端 未结 1 415
慢半拍i
慢半拍i 2021-01-31 09:59

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.

1条回答
  •  走了就别回头了
    2021-01-31 10:17

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

    0 讨论(0)
提交回复
热议问题