Sign in to follow this  
Lightstrike

Is there no SDL input library?

Recommended Posts

I've been searching The Internet and these forums for a more complete input system for sdl for a couple of hours now and there doesn't seem to exist much more than the basic joystick example tutorials. I found the object oriented input system (ois) but it didn't really seem to do enough or be especially well integrated with SDL as it required directinput to compile. it didn't even have a compiled binary. Here's what I'm looking for: A wrapper library that integrates nicely with SDL apps and gives easy access to input events from keyboard, mouse and multiple joysticks. There are a few keyboard/mouse only ones, I even wrote one myself pretty fast with SDLs event system, but there is nothing more advanced that takes care of joysticks, action->control mappings, sets of controls or provide a unified interface to use in player classes and so on. Basically I'm looking for a more advanced game input library that is easily and ready to use in any sdl-app. Preferably it should be platform-independent/open-source but if its based on sdl events that comes naturally. Surely someone must have built something like this in the open-source/free license world?

Share this post


Link to post
Share on other sites
well I'm already using the sdlevents for keyboard and mouse. thats basics. I'm rather looking for something more high-level similar to ois but with even more features for games like keeping track of different control mappings.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lightstrike
but there is nothing more advanced that takes care of joysticks, action->control mappings, sets of controls or provide a unified interface to use in player classes and so on.


Thats because that stuff is faily basic and easy to write and usually game specific. All you need is a list of key codes and a list of gamecodes to map them to. Every SDL event just checks the lists and converts the keycode into a gamecode and pass it onto the game. Usually takes an hour at most to get that done and dusted and you never have to look at it again*. Which keys you want to log, how many and what they relate to are all game specific and changing them through your menu (or config file) is again very game specific. If you were to write a lib for it I fail to see that it'd be much more helpful that the SDL events you get ... they pretty much tell you all, just need to store the values somewhere and your done.


* stl maps work wonders here:

if ((itr = keys.find(nKeyCode)) != keys.end())
{
game->keyDown(*itr);
}

Share this post


Link to post
Share on other sites
yeah I already made that too for keyboard input using maps. What complicates it is when you want to wrap all types of controllers in this system and make it possible to map any controller movement to any action from any controller in an input options screen.

Maybe I'm too ambitious but it was nice to have in our previous directx-based game. That system was based on polling rather than events so rewriting it would be from scratch anyway so I thought maybe someone had made something similar around SDL.

I guess at this point the best solution is to start with openinput or ois and build the mapping system on top of it. Or what do you think?

Share this post


Link to post
Share on other sites
I've been thinking about writing such a library, specifically the bit that generically maps different input types (buttons, axes, keys, etc) to in-game ranges or switches, and maybe events. But I wasn't sure how much demand for such a thing there was. Maybe I'll take another look at it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this