Although I see you've done an impressive job containing this program, I think it's possible to do even better, at least, on Linux. Instead of setuid root, perhaps setgid input for handling /dev/input/*? As for /dev/uinput, I'm not sure - this article adds a new group uinput as well as udev rules, but I don't think you can setgid a program for multiple groups, correct? I don't think assigning /dev/uinput to group input would be the best choice - isn't it for reading from input devices, and not writing?
Any thoughts?