Hello, I am using GLFW for my graphics/OpenGL stuff, and I want to use a separate library for input. I don’t expect support for an external library here, but my questions can either be answered in terms of GLFW’s relation in general to external libraries or simply answered in terms of GLFW itself.
My first question is: using an external library, I can respond to gamepad inputs just fine but I cannot see any response to the keyboard. Is there a fundamental reason why gamepad information would be available but keyboard would be swallowed by GLFW? Is there anything necessary to pass along the “context” of the window with relation to keyboard, or something like this? Specifically I would like to use raw keyboard input.
On the note of raw keyboard input, my understanding is that for games getting the raw state of the keyboard is better than using events etc. But it appears that GLFW uses keyboard events instead of raw input. Am I misunderstanding this? Let’s say I was to just drop the external library altogether - does GLFW’s input system support reading raw keyboard input?
Since GLFW handles input events it’s tricky to add an input handler on top of it without modifying GLFW code.
GLFW has raw mouse input but not raw keyboard or gamepad/joystick.
Raw input is still event based. For mouse input it makes a lot of sense as it gives finer grained resolution and potentially more frequent updates depending on the hardware. For keyboard input the main use would be to able to know which keyboard a given input came from with multiple keyboards.
Unless you need to handle multiple keyboards as if they are separate input devices the input in GLFW will probably be sufficient for your needs if you use raw mouse input when available.
One disadvantage of RawInput is that it cannot be used for text input. Because translation of scancodes to characters happens depending on user keyboard layout settings in OS.
So you either use regular keyboard messages always, or manually switch between handling messages or RawInput depending on whether your game/software needs text input or key presses.
OK thank you for confirming my concerns, and I had seen some examples of other kinds of input being forwarded from GLFW onward. That being said, do you mind weighing in on why gamepad input seems to get through, or if there are any lurking concerns there?
With regards to raw input being event based, am I correct in my understanding that it is still better for video games for keyboard input? Or is it not faster? If it is not significantly faster then I don’t particularly mind just handling keyboard with GLFW, but either way this was very helpful and I think my two paths forward are:
Forget about raw input, simply handle keyboard input separately via GLFW rather than using my separate library.
Try to forward on events from GLFW to my library, and this is true even for raw input.
Again the only concern being if there is any lurking issue with the gamepad input itself, in which case I have to rethink more broadly. And I appreciate the callout re: text vs “regular input”, I am mostly wanting to offer keyboard as an input system for debug commands during development and as a last-ditch option for gamers who do not have a pad.
Using RawInput is not faster for keyboard. It may make sense for mouse input, but you cannot press keys physically more faster where window message input would be any slowdown. You will sooner hit keyboard hw limitations (rollover & stuff)
OK awesome, thank you I am not sure how I got the impression otherwise. That definitely influences my decision and makes things easier.