C++: Correct ownership of InputDevice objects.