Client/server implementation idea
- as each instance loads, it registers its own object pointer to a linked list
- The first instance to run reads the events from the OS, then calls hidio_output_events() for each object pointer in the linked list
- using each event's timestamp, each output call could be scheduled using clock_delay() so that the events are output with the same timing that they were received with.
- this might use a lot of CPU power.
- Maybe there is a way to find when the HID polls are happening, then start a 10ms clock using that. Then it would only have to poll every 10ms, but would be more or less in sync with the HID polls.
Getting plug/unplug events
- GNU/Linux: dbus provides this info, a la input_noticer
- Mac OS X: I found how to do the USB plug/unplug notifications on Mac OS X. Check out registerForUSBNotifications() and unregisterForUSBNotifications() in this source file: http://www.opensource.apple.com/darwinsource/10.4.8.ppc/IOUSBFamily-258.4.1/USBProberV2/IORegInfoGatherer.m
- GNU/Linux: on replug, the device gets assigned a new /dev/input/event?, leaving the old one in place, but non-functional. So that means it just adds one to the list, but now there's a non-functional device in the list.
- Mac OS X: HID Utilities - the device list would need to be rebuilt. The device list is based on the order that things were plugged in, so the newest last, IIRC (otherwise first).