Once upon a time, a protocol was created so all Human Interface Devices could communicate using the same language. What a beautiful world it was… One where keyboards, mice and gamepads were all using the same HID protocol ! Then on a bright morning VR came in the way, bringing with her all its new hardware. You could have thought, just like I did, that it would all be nice and compatible with this previous protocol, or at least bring one and only protocol that would rule them all…
We were fools ! No hardware communicated the same way !
And the good old HID protocol couldn’t come to the rescue, mainly because its implementation in our common platforms like Unity or Mozilla Gamepad API were scrapped. One could only access access a very small part of all the functionalities offered by HID protocol.
Let me explain !
HID protocol allows you try describe almost any kind of controller using an HID descriptor. It can be used over USB of course, but also over Bluetooth 4.0, it is called “HID over Gatt”
I started using HID over Gatt with Torrus. You can find the descriptor below. The trackpad axis was acting as a joystick, and the IMU would send its orientation (Rx, Ry, Rz) and its acceleration (Vx, Vy, Vz).
I tried to connect Torrus to my phone, it appeared as a Gamepad, so far so good, then launched the “Gamepad Tester” application for Android, and started received data ! All the data I expected ! Nothing was wrong with using the HID protocol… at first sight…
What is really wrong wit HID ?
After a few hours of research I end up loosing faith : apparently Unity didn’t handle those axis. It was only designed to handle a very limited part of HID…
Not loosing all hope, I continue with HID and try Mozilla Gamepad API, thinking I would still be able to use Torrus HID protocol in WebVR… Boy I was wrong ! The Gamepad API cannot handle more than 4 axis !
To sum up
HID protocol is a very good protocol, perfect to use over Bluetooth. The problem is that it is not well handled by the game engines like Unity, nor the Gamepad API for WebVR. To my mind, the good solution would be to have a better implementation of HID protocol in those software, but it is complicated and not a quick fix. During that time we need to find something else like a Bluetooth service.
If you have experience with Unity Input Manager, or Mozilla Gamepad API, maybe you could help solve the HID problem, and that would be AWESOME !!!!