Jump to content
  • Advertisement
Sign in to follow this  
RavenITA

Linux input model, compared to Windows

This topic is 3093 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

Hi everyone, I hope this is the correct place for my question. I am going to create an input library (language is C++) to provide abstraction from the actual input devices and translate keystrokes into actions. My default development environment is Windows, so I've looked into the Raw Input model in order to be able to get input from multiple keyboards, mice and various peripherals. But I intend to make my game cross-platform, and so I need to make a Linux version of the input library that has a similar interface: basically, initialization, frame-time update, notification and handling of new/removed devices. Is there a [module|interface|model|whatever] in Linux (or more generally in Unix) to do that? Thanks everyone!

Share this post


Link to post
Share on other sites
Advertisement
The X Window system should handle that, assuming you're on a desktop or MID system running X11. If you're on a, say, Linux system on a phone running on top of the frame buffer you will have to talk to the various devices directly (say, a softkey app or USB device) unless Android provides some service for this. If you're on, say, a BSD-based system running on, maybe, an iPhone, then you'll have to go through a completely different toolkit to intercept the OS stuff.

Latter-day Linux kernels provide the /dev/input system to consolidate most input devices into a single interface, and you can use udev or dBus to monitor hotplugs. Interpreting /dev/input gets pretty hairy: a good set of example code is found in the x.org evdev source base.

Share this post


Link to post
Share on other sites
Kwizatz: uber-cool! I'll browse through the documentation to learn more, but this may even stop me from using Raw Input on Windows.

Bregma: I plan to stay in the desktop Linux realm. I'm doing this for a game project which will be aimed at personal computers and not at mobile devices, so I can pretty much assume there will be X11 (I'll also use that to create the window itself, I think).

Thanks to both!

Share this post


Link to post
Share on other sites
You could also use SDL (I've also read good things about SFML) to set up your window in a cross platform way on top of input, that would leave out dealing with X11 and WinApi/GDI altogether, is there a reason you're avoiding such libraries or did you just didn't now? [smile].

Share this post


Link to post
Share on other sites
I knew about SDL, but I wanted to have as much control as possible. Also, since I've read in several places of difficulty in setting up specific configurations when using SDL, I preferred to use Win32 APIs - it's not that hard anyway.

Share this post


Link to post
Share on other sites
Oh, Ok. A lot of good, new things are coming with SDL 1.3, OpenGL 3.x and up support as well as multiple windows and multiple input devices (mouse and keyboards), but no date on when there will be a stable release of that yet.

Anyway, you may want to take a look at SFML, I think I might myself, perhaps its already taken care of SDL's shortcomings.

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!