Input Library

Started by
8 comments, last by blanky 18 years, 7 months ago
Hey guys, I have already chosen all the cross platform liraries I like, OpenGL, OpenAL, rakkarsoft, and for window handling GLFW, but now I need one that supports input, I know there's direct input and I like it but it's only microsoft, I'd like to know if you guys know of/recommend any, I wouldn't like to go with SDL but if it's the best then of course I will, GLFW has input but I dont know if it's all taht great, has anyone tried it? Basically I want something as good as direct input but cross platform, thanks.
Advertisement
GLFW does provide input and it works quite well. The GLFW User Guide covers it. It actually is quite similar to SDL's event polling system. Another option for window handling and intput management is FreeGlut.
Rob Loach [Website] [Projects] [Contact]
Thanks, but I'm writting OS specific code, should I use OS input? Is GetAsyncKeyState fast? Or should I use GLFW, if I do, and I decide to use GLFW for window handling as well, will it be slower than OS specific? That's almost obvious, but would it be noticeable? Thanks guys.
The main reason why you'd be interested in using middleware like GLFW or FreeGlut is that they implement the OS specific code for you. Why write the OS specific code when it's already in your hands? These third party libraries are already writen and have been in maintainance for years now. They are very stable and work very well. It's your choice if you want to write you own, or use SDL/GLFW/FreeGlut/etc. They all accomplish pretty much the same thing in terms of window and input handling.
Rob Loach [Website] [Projects] [Contact]
Thanks, I printed out the GLFW users guide :P
otoh if you use directinput you can asynchronously poll all key states at once which is probably faster than doing it via events, glfw doesn't do that, is there any cross-platform input library that does this (or similar things for other platforms)?
I'm not sure, probably SDL? GLFW does this thing called a function callback so it calls a function each time it gets input, and yeah GLFW polls like every 10th of a second or something like that.
nope, glfw usually polls on buffer swap, so it only polls once per frame. and you can't use it if you want a separate input thread, because it isn't thread-safe. furthermore internally it just polls the normal windows events. sdl does the same iirc, but it is thread-safe though afaik.
What it all comes down to is what's easiest for you to use. Since you're already using GLFW in your application, what's wrong with using it for input as well? GLFW has been proven to work for input in games, so go ahead and use it.
Rob Loach [Website] [Projects] [Contact]
Thanks Rob and everyone else :)

This topic is closed to new replies.

Advertisement