Quote Originally Posted by vgo
Basically what I did for my cross-platform input code was that I first made a unit with the generic input codes and classes. Then I derived new classes (for SDL, DirectInput and Windows) from this, for example in the OnKeyUp the SDL input is "translated" to the generic input codes with a simple table lookup and passed on to the actual OnKeyUp for doing the input handling.

The lookup table is read from a file or created on the fly with the default configuration and the key assignment is easy to do. I made generic input codes for mouse and joystick buttons too and now I can map any (key press) action to keyboard, mouse button or joystick button.

For example, I have TInputHandler class and the TSDLInputHandler is derived from this, when the game engine initializes it chooses which input handler to use. All the input handler classes have the Poll() method that does the actual key polling etc. In the game engine I have another input class TGameInput which has public OnKeyUp etc. events that are triggered for handling the game input.

The simplest way is to have just the generic input class that is used to handle the game input with public events and the platform dependent classes are derived from this. The base class does all the event triggering, the derived classes only translate the input to the generic input codes to pass on to the game (MyInput.Poll(); MyInput.TriggerEvents(); ). Don't know if that makes any sense, but that's how it works.
Hi vgo, thanks for the explanation

I THINK it makes sense, but just in case do you have a code snippet or example you can show me?

cheers,
Paul