Detect hardware button events on a USB camera
I'm trying to develop a desktop app with QML on Qt 5.2 that controls a USB-attached camera. I can already control the camera with software buttons, but want to have access to the camera's hardware button (it has one for shutter) too.
Since there are no hardware-related functionalities in Qt's camera API (either QCamera and the QML Camera element), my first thought was to read the button myself. I put together some simple C++ that reads the device on LibUSB, and it worked well enough—on its own. I found that when I tried to integrate the two parts together, Qt's camera API would spit out "Failed to create video device input" and stop working altogether.
I'm not very familiar with LibUSB, to be honest. Is this caused by some ownership problem between Qt and my LibUSB code? If so, how do I resolve this? Or is there a completely different way of doing this without digging into raw USB communication on my own?
Thanks in advance.
I'm by no means an expert on this, but have been trying essentially the same thing. Only one process can access the USB device at one time, from my understanding, and thus you need to incorporate a mutex or some polling function that releases control of the video stream to check the button status. This does mean that you're going to be writing your own custom driver for the camera if it didn't come with one. If anyone with better understanding of QCamera and USB controls can chime in with assistance it'd be appreciated.