Lossy Keypress events: how would I reliably check the current hardware state of a key on mac?

I'm working on a game for mac, windows, and linux. It's currently in pretty early stages and libraries are flexible, though it's currently using glfw 3. Almost all games I've played on mac have issues with keys sticking; presumably this is because edge-triggered events are frequently dropped by the OSX apis.

My primary question: is there a way to get the current pressed state of a key, independent of any events, such that we can work around this problem?

A secondary question is what is dropping these events, and why it doesn't happen with text input. But I'm really interested in whether there are any options that guarantee that they're the true pressed state even events get dropped. I don't think this is as bad of a problem for keydown as it is for keyup, and I'm pessimistic about that route for fixing it.

(More notes about our code: we're basing it on Craft, the c cubic voxel renderer implementation, and we're moving over to c++. I don't think that's relevant, though, as I've experienced this on most mac games I've played, including Glorkian Warrior, Metro: Last Light, Terraria, Luftrausers, Bit Blaster XL, Race The Sun, Steel Storm: Burning Retribution, Crosscode, etc.)

1 answer