Hi all !
I'm writing a simple 2d game using SDL. I would like my game has got a changeable input from user. For the example: left arrow on the keyboard moves sth to the left. User change it, now Joystick axis motion moves sth to the left. I have no idea how do that. Can anybody help me ?

Exact details depend on what programming language you are using, but there are a number of ways to do this. One way is to create a map or associative array of event objects to function pointers or function objects. Then in each event handling block invoke the functor for the received events. Alternately you can use a map of events to tokens and then have your input handling functionality dispatch tokens to game state objects.

Thanks, but how can I do it for SDL_Event structure ?I'd like to use joystick too, it seems that is for keyboard only.

Exact details depend on what programming language you are using, but there are a number of ways to do this. One way is to create a map or associative array of event objects to function pointers or function objects. Then in each event handling block invoke the functor for the received events. Alternately you can use a map of events to tokens and then have your input handling functionality dispatch tokens to game state objects.

Could you write how to use a map of events ? I tried it myself but it doesn't work.

Thanks, but how can I do it for SDL_Event structure ?I'd like to use joystick too, it seems that is for keyboard only.

Exact details depend on what programming language you are using, but there are a number of ways to do this. One way is to create a map or associative array of event objects to function pointers or function objects. Then in each event handling block invoke the functor for the received events. Alternately you can use a map of events to tokens and then have your input handling functionality dispatch tokens to game state objects.

Could you write how to use a map of events ? I tried it myself but it doesn't work.

The key part of the map has to have a comparison operator defined (the < operator in this case) which SDL_Event doesn't have, You could write your own EventKey(ok, maybe not the best name) class that stores the necessary information and which overloads the < operator or you can pass a comparison function to the map.

I don't suffer from insanity, I'm enjoying every minute of it.The voices in my head may not be real, but they have some good ideas!

Having a general event mapping system is a little more difficult. For most games, you might want to map key presses or releases, and mouse clicks. Mapping complicated, stateful actions like mouse dragging will take a bit more thought.