02-10-2023, 08:31 PM
Quote:What you've got looks a whole lot like my keyhit library, except it's not quite as advanced. What you're tracking is a single button's up/down state, to see when it might be pressed, while the keyhit code here does that and applies key modifiers to it.
The difference in a nutshell?
You report Shift-A as two key presses -- "Shift" is down, "A" is down.
This library reports Shift-A as two modified key presses -- "Shift" is down (it doesn't modify), "A" might be down, or "a" might be down (depending on CapsLock state).
What you are describing as "advanced" is exactly why _keydown and _keyhit ended up being completely unusable for my purposes, and why I had to turn to _button instead. In fact, what I proved conclusively in a test - and also submitted in a bug report a year or two ago - was that _keydown has an issue where a modified key will "stick." If you do the following:
1. Start holding shift
2. Start holding A
3. Stop holding shift
4. Stop holding A
...Then _keydown actually thinks the uppercase A was never released, since what was released on step 4 was lowercase a. The end result of this for my game was that if modifier keys were bound by the user, the controls would stick when more than one thing was done at once. So if you used shift for "boost," and A for "shoot," then sometimes you would enter a state where you would be pressing nothing but still shooting endlessly.
As for _devices, I can't really say, I do know that my game can't use the alt keys - if you look through the list of keys in my library, you can see all the ones I considered "safe" in my testing. _devices does read my USB controller, although I have not yet tested the game on multiple hardware setups and peripherals.