Sign in to follow this  
RavenITA

Linux input model, compared to Windows

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
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
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