Tilengine - The 2D retro graphics engine forum

Full Version: Feature request, input keys other than arrows
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, the TLN_Input enum doesn't allow us to use keys other than arrows for player movement

enum  TLN_Input { 
  INPUT_NONEINPUT_UP,INPUT_DOWNINPUT_LEFT
  INPUT_RIGHT,INPUT_BUTTON1,INPUT_BUTTON2,INPUT_BUTTON3
  INPUT_BUTTON4,INPUT_BUTTON5,INPUT_BUTTON6,INPUT_START
  INPUT_P1 = (PLAYER1 << 4),INPUT_P2 = (PLAYER2 << 4),INPUT_P3 = (PLAYER3 << 4),INPUT_P4 = (PLAYER4 << 4) 
}

I would like to use WASD in addition to arrows, so I request INPUT_W, INPUT_A, INPUT_S and INPUT_D ooooh boy,

OOOk, now I see this:

TLNAPI void TLN_DefineInputKey (TLN_Playerplayer, TLN_Input input, uint32_t keycode)

Ok, I'll check this.
TLN_DefineInputKey() is the way to assign the predefined functions to the keys you want
Thanks Marc.

I tried to override the default behaviour of esc key. By default it closes the program but I want it to close my current screen (map) so I've done:

TLN_DefineInputKey(PLAYER1,INPUT_BUTTON5,SDLK_ESCAPE);

and then check for input on BUTTON5 in the main loop. But it doesn't work. I see the default behavior for esc key.
Some keys such as Escape an Backspace are predefined. The windowing subsystem was implemented to provide a simple environment for testing because Tilengine is just a rendering library. If you need more inputs, custom filtering, function bindings, overlaying external pictures... have you considered discarding the built-in windowing and providing your own framework? It shouldn't be difficult, the Window.c source file that implements the window system is open source, you can use it as a working example.