Mouse/keyboard libraries for Linux -suggestions needed

Started by
10 comments, last by Drag0n 18 years, 10 months ago
Hello I have been recently looking at topics related to glx and X programming. Mouse and keyboard handling in X seems to be done largly trough XEvents (a feature present also in MS Windows). I am sure this is fine but I am was thinking: Is there another way of handling mouse and keybaord? I know about libraries such as SDL, SVGAlib but I am looking for something that would be the equivalent of (or similar to) DirectInput from MS. Does anybody know what recent 3D games (Doom3, Quake 3) ported to Linux used for mouse/keyboard? Any ideas? FimDan
Advertisement
I used curses.h for console keyboard input. I'm not sure how relevent it is with OGL etc though,

ace
Most games ported to Linux use SDL as the input layer.
you could also give glfw a shot if you are about to use ogl on X. it is similar to glut but a lot better imho.
You can't separate input from Window management. X handles the window management, hence X will be handling the input.

SDL and GLFW wrap the X events for you in the same way as they do in Windows and other OS - thus sparing you the need to write platform-specific code.

It is pretty low level, and should do what you want. Ultimately, it's the same as on Windows - you get a message when keys go up, down, mouse buttons are pressed, move etc.

Mark
Thanks

That was very helpful. I am going to check out the glfw library for now.

FimDan
Another thing maybe worth a look is the DGA X extension (XF86DGA or simply XDGA --> man XF86DGA). I stumbled over it by chance, when trying to find out how to chance the bit depth on a running X server. The Direct Graphics Access extension doesn't only allow you to mess with the frame buffer, but it also allows you to access a keyboard and mouse event queue, which is not dependant on your window (I hope I got that right).

Another thing: Afterwards I found out that Quake III Arena uses the DGA extension at least for mouse access, I don't know what it uses for keyboard access, though.

Hope that helps!

Cheers,
Drag0n
-----------------------------"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich Cook"...nobody ever accused English pronounciation and spelling of being logical." -- Bjarne Stroustrup"...the war on terror is going badly because, if you where to compare it to WWII, it's like America being attacked by Japan, and responding by invading Brazil." -- Michalson
Another framework/engine you might want to try is Daedalus (direct download here). It's built on top of GLFW and add a C++ layer over it. In addition to allowing you to get a window up and running with minimal code (see here for an example) it also has a task queue, and a resource system. More functionality is added to this every week. It currently runs on Windows and on Linux, but other platforms are planned.
Quote:Original post by Drag0n
Another thing maybe worth a look is the DGA X extension (XF86DGA or simply XDGA --> man XF86DGA).
Cheers,
Drag0n


Hey

Actually, I was looking at that too. What I discovered was that the fglx driver from ATI needs to have this extension disabled (look at xorg.conf). I am using an ATI card with my Emachines 6810 and the driver has been working ok for me (about 2000 fps on glxgears).

Overall DGA looks like an interesting piece to work with. Let me know if you have any idea how to make DGA and fglx coexist peacefully:)

Thanks

FimDan
Hi,

I have a NVIDIA card, so no trouble at all. What I read in the DGA manual though is:

Quote:
Most of the reasons for the XFree86-DGA extension's existence are now
better served in other ways. Further development of this extension is
not expected, and it may be deprecated in a future release. The fea-
tures that continue to be useful will either be provided through other
existing mechanisms, or through an extension that address those needs
more specifically.


I don't need the graphics stuff anyways, all I need is to access the X servers keyboard and mouse event queue directly (that is, not through the normal event mechanism). :)

Cheers,
Drag0n
-----------------------------"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich Cook"...nobody ever accused English pronounciation and spelling of being logical." -- Bjarne Stroustrup"...the war on terror is going badly because, if you where to compare it to WWII, it's like America being attacked by Japan, and responding by invading Brazil." -- Michalson

This topic is closed to new replies.

Advertisement