On Sunday, 15 September 2019 at 10:52:43 UTC, rikki cattermole
wrote:
On 15/09/2019 12:16 PM, Joel wrote:
What is a good keyboard input handler or so? Just need one
that picks up that a key is down, but not like a word
processor.
Are you referring to when you hold down a key and multiple
characters gets added to the text area?
If so, this feature is called auto-repeat and is implemented by
the kernel on input from keyboard.
This is easily detected for Windows and can be disabled with
X11.
Windowing libraries like GLFW offer telling you if an event was
an auto-repeat GLFW_REPEAT[0]. SDL[1] has it too under the
repeat field, and so does Allegro in the event
ALLEGRO_EVENT_KEY_CHAR[2].
If you have a windowing library that forces auto-repeat on you,
then you can use a map (with a lookup table to optimize for
ASCII as that will be mostly what you will get with it) to
check if the key is currently down.
If you have a windowing library that forces auto-repeat to be
off, then you can use a map (with a lookup table to optimize
for ASCII) and then use a timer and trigger your own internal
to program auto repeat event.
[0] https://www.glfw.org/docs/latest/group__input.html
[1] https://wiki.libsdl.org/SDL_KeyboardEvent
[2] https://www.allegro.cc/manual/5/ALLEGRO_EVENT
I was using DSFML 2.1.1[0] for keyboard input, but with the last
macOS update, it just crashes my programs, (it was unstable
anyway). I have my own wrapper[0] for handling key pressers. I
just need to know when (a) key(s) is/are down (and what key(s)).
I still want to use DSFML for other stuff (like graphics).
I've had the whole macOS crash, with trying to get Allegro
working on it with code that works on Windows OS. I haven't got
any SDL program working - DLangUI programs compile and work
though.
[0] https://code.dlang.org/packages/dsfml
[1] https://github.com/joelcnz/JecLib