Closed aforren1 closed 6 years ago
Another (orthogonal) issue is how to handle polling of high-frequency input devices. I have a few examples floating around using the multiprocessing
module, but there's also ioHub, which covers the whole polling-on-another-process angle.
Writing our own pros:
cons:
ioHub pros:
cons:
Note re: keyboards & mice: there's https://github.com/boppreh/keyboard which provides hooks to keyboard & mice events on Windows, Mac, and linux. I was thinking of using the ioHub
mice/keyboards initially, but the pyHook/pywin32 dependency is annoying (no pypi package for pyHook).
Using keyboard
also makes debugging easier, as mouse/keyboard can exist without a pyglet window.
Just another note re: polling - toon/input/hand.py implements polling on a separate process (and toon/examples/scratch_mp.py is an earlier, but I think simpler, example of the same concept).
As of 0.1.0, there's a generic input/base_input.py
that takes care of the multiprocessing bits. Both the HAND and Flock of Birds have been re-implemented using this.
The dream (for me, at least) would be to have a single common API for input devices.
Then inherit:
We could probably even do a factory pattern for device instantiation, e.g.:
so that the particular device can be chosen at runtime (or from a config file, etc.).