Refactor the internals of input handling

Basically move driver-specific code to the respective driver’s module
Fix inconsistencies and omissions in the public API