One possible solution would be an OS update that displays a security warning when a second keyboard or mouse is detected that asks the user to confirm that they connected a keyboard or mouse using the already connected keyboard/mouse. For example, if someone attaches a cordless mouse to a laptop for the first time, they would use the touchpad to click on 'Yes'.
If the user selects 'No', then it will disable any keyboard/mouse functionality of the attached device and a warning be displayed that this device is potentially infected.
In theory, most devices should work fine without providing keyboard/mouse functionality. The only exception I can think of is the 'Backup' button on some external hard disks which usually sends a key combination to launch the backup software (e.g. the old Maxtor OneTouch). Most printers and scanners on the other hand use the product driver for handling their device buttons.