Raw Input: Read multiple USB keyboards on Windows

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Raw Input: Read multiple USB keyboards on Windows
by on (#205561)
The Raw Input API in Windows allows a program to read multiple distinct keyboards, such as two USB keyboards or a USB keyboard and a laptop's internal keyboard, and take different actions for (say) Space on one and Space on the other. It reportedly works for mice as well, and I imagine it'd be the only viable way to emulate two Zappers, two Arkanoid Controllers, two Super NES Mouse controllers, or one of each. Which emulators support Raw Input, and which plan to?
Re: Raw Input: Read multiple USB keyboards on Windows
by on (#205583)
tepples wrote:
The Raw Input API in Windows allows a program to read multiple distinct keyboards, such as two USB keyboards or a USB keyboard and a laptop's internal keyboard, and take different actions for (say) Space on one and Space on the other. It reportedly works for mice as well, and I imagine it'd be the only viable way to emulate two Zappers, two Arkanoid Controllers, two Super NES Mouse controllers, or one of each. Which emulators support Raw Input, and which plan to?


MAME has for quite a while. I'm not aware of any other emulators that do, but only because I haven't followed the release notes as much with other emulators.
Re: Raw Input: Read multiple USB keyboards on Windows
by on (#205587)
There are several input APIs that serve as abstraction layers on top of lower level APIs like Windows Raw Input; so, if the keyboard mapping within an emulator is able to discern between multiple keyboards, then it might be using it indirectly.

One of the strange things that I discovered about the lower level keyboard APIs is that some keyboards have non-default key codes for certain keys. If the user is forced to map all the buttons to keyboard keys in a setup screen before ever using the emulator, then the user will never experience this effect. It's only when the emulator tries to establish default keyboard codes that some problems might arise.

Also, lower level keyboard APIs also exhibit different key auto-repeat behaviors; meaning, after a period of holding a key down, the sequence of events that follow may vary.

I should also point out that higher level keyboard APIs do not necessarily remedy these effects. Dealing with the wide range of keyboard craziness is a pain.