Jump to content
  • Advertisement
Sign in to follow this  
njpaul

Handling input in Linux

This topic is 2202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm about to begin work on the Linux portion of my input system. For keyboard/mouse input, I'm undecided if I should use XCB/Xlib or if I should use the kernel input directly (/dev/input/...). Does anyone have any experience as to which method is preferred? I would like to support joysticks and gamepads in the future as well. From what I've been reading, it seems I'll need to use the kernel input directly for those, so would it make sense to just use it for everything? The only thing I don't really like is the lack of permissions by default to open files in /dev/input, but that's easily solvable using groups.

Thanks

Share this post


Link to post
Share on other sites
Advertisement
I would use X11 only. The X server can be configured to handle the input sources. And you have a uniform interface to everything concerning user interaction.

Share this post


Link to post
Share on other sites
It's unlikely that XInput will not give you everything you need, except maintenance headaches. The current version (XI2.2) support joysticks, gamepads, and multitouch devices. There are a few devices, like accelerameters and video capture, that may not work well through X, but they will not work any better if you try to handle them through the kernel event device interface, too.

If your game needs to run as root, you're definitely doing something wrong.

Share this post


Link to post
Share on other sites
Thanks for the input everyone. I guess I will use X, as least as far as it will take me, and if I do hit any limitations I may rethink the decision. Does XI2.2 support force feedback? That's the only limitation I'm really worried about at the moment.


If your game needs to run as root, you're definitely doing something wrong.

Well it wouldn't have to run as root if I create an input group and a udev rule, but that might be asking too much out of users.

Share this post


Link to post
Share on other sites

Does XI2.2 support force feedback?

From what I can tell, XI2 does not support force feedback. Additionally, I haven't even been able to get XI2 to recognize the joystick as an input device. evtest and fftest work fine though. I found a bug report describing a similar problem, although that person was able to get the device to be recognized by modifying a configuration file. However, I did discover that joysticks (in /dev/input/eventX) can be used in user space, even though the mouse and keyboard cannot. I think my solution will be to have X handle the mouse/keyboard input, and use the eventX file for joysticks. I don't have any touch devices lying around, so I can't test those. I guess I'll cross that hurdle when I get to it.

Share this post


Link to post
Share on other sites
I've been working with Xlib lately but I've just run into a problem with KeyPress and KeyRelease. It seems that KeyRelease either doesn't detect an actual key release and my program thinks a key is being held down when it's not, or it signals a false release, followed by a false press, ad nauseum. Has anyone else run into and overcome this problem? Should I try something other than Xlib? Any advice for yet another newbie-aspiring-to-be game programmer?

Share this post


Link to post
Share on other sites

Try OIS
http://sourceforge.net/projects/wgois/


Thanks for the link! Judging by a quick look at the source, it seems as though OIS is built upon (at least to some extent) X11 and Xlib. I'll have to study this and hopefully gain some insight as to how they overcame the problem I've been having. Perhaps I can even craft my own input system after studying this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!