I'm curious that if I want to use some custom sensor hardware (HID compatible) to act like gamepad. And then use gamepad API to work with it with js/html. What I won't be able to do?
Specifically, what could be done on HID api but cannot be with GamePad api? (and vice versa, if there is)
As far as the Gamepad API goes, it is originally a Read-Only API. Hence you could make your sensor as one which emits events
every few ticks
to hack your HID device into acting like a Gamepad.
The con of this method is that you would not be able to write back to the "sensor -> HID interface -> Gamepad Device" system via the APIs.
As long as that is not a requirement, feel free to use it in this combination.
BONUS: If you want duplex communication abilities, you might consider hosting a server on a machine that connects to the HID device and use Java/PHP/Node based serial communications protocol to read/write to the sensor.
Your frontend application where the JS is running can then poll your server via AJAX for reading/writing data.