Keyhit library update
#13
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.
Reply


Messages In This Thread
Keyhit library update - by SMcNeill - 11-23-2022, 01:16 PM
RE: Keyhit library update - by TempodiBasic - 02-08-2023, 10:07 AM
RE: Keyhit library update - by PhilOfPerth - 02-08-2023, 11:30 PM
RE: Keyhit library update - by SMcNeill - 02-08-2023, 11:51 PM
RE: Keyhit library update - by PhilOfPerth - 02-09-2023, 12:35 AM
RE: Keyhit library update - by johannhowitzer - 02-10-2023, 04:17 AM
RE: Keyhit library update - by PhilOfPerth - 02-10-2023, 05:56 AM
RE: Keyhit library update - by johannhowitzer - 02-10-2023, 06:28 AM
RE: Keyhit library update - by PhilOfPerth - 02-10-2023, 06:51 AM
RE: Keyhit library update - by johannhowitzer - 02-10-2023, 01:39 PM
RE: Keyhit library update - by SMcNeill - 02-10-2023, 02:16 PM
RE: Keyhit library update - by SpriggsySpriggs - 02-10-2023, 03:21 PM
RE: Keyhit library update - by johannhowitzer - 02-10-2023, 08:31 PM



Users browsing this thread: 5 Guest(s)