Skip to main content
GameDev.net gamedev.net
🔒 Locked

Is there no SDL input library?

Started by Lightstrike Aug 15, 2008 at 12:42 PM 7 replies 3k views
Original Post
Lightstrike
Lightstrike
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?
nathandelane
nathandelane
It looks like you use the SDL Event system http://gpwiki.org/index.php/SDL:Tutorials:Practical_Keyboard_Input
Lightstrike
Lightstrike
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.
TMichael
TMichael
There really aren't very many generic input libraries out there, but one other worth a look might be OpenInput.
GameDeveloperTools.comA comprehensive library of game development resources.
Lightstrike
Lightstrike
Looks interesting, thanks for the tip. Although it doesn't fit the requiremesnt of extra game features or sdl integration but thats not so important. Just trying to save some dev-time here :)
Pto
Pto
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);
}
Lightstrike
Lightstrike
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?
Kylotan
Kylotan
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.
Lightstrike
Lightstrike
I think for people that want to get going fairly quick without bothering with input details that would be awesome. I might end up doing it myself too though.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.