FYI, here is a complete device implementation using this technique, feel free to copy and adapt for your own purposes:
Generic Devices: Philips Footcontrol ACC2330