Raw Input: Read multiple USB keyboards on Windows

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Raw Input: Read multiple USB keyboards on Windows

Post by tepples »

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?
2600
Posts: 96
Joined: Tue Aug 07, 2007 10:28 am

Re: Raw Input: Read multiple USB keyboards on Windows

Post by 2600 »

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.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Raw Input: Read multiple USB keyboards on Windows

Post by zeroone »

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.
Post Reply