Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding INPUT_BUTTONS
#1
Wink 
Hello! I need more keys for my application and wish to keep using the supplied Window.

For instance I needed to take control of ESC key so I asked mark and he pointed me towards Window.c, 663, I commented that and assigned INPUT_START to ESC and voila! TLN_DefineInputKey(PLAYER1,INPUT_START,SDLK_ESCAPE);

ESC is mine again.

So now I need more keys but I noticed bizarre errors when a certain number of buttons is reached. For instance:

Code:
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON7,SDLK_KP_7);
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON8,SDLK_KP_8);
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON9,SDLK_KP_9);
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON_KP_4,SDLK_KP_4);
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON_KP_5,SDLK_KP_5);
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON_KP_6,SDLK_KP_6);
TLN_DefineInputKey(PLAYER1,INPUT_BUTTON_KP_2,SDLK_KP_2);

The first buttons added worked great, but I started to have problems on INPUT_BUTTON_KP_4 (keypad), it didn't work, furthermore KEYPAD 2 took the behaviour of INPUT_BUTTON8 and ESC stopped working.

I think the culprit is here: (540 Window.c)

Code:
static void SetInput (TLN_Player player, TLN_Input input){
    player_inputs[player].inputs |= (1 << input);
    last_key = input;
}

I would like a little explanation of that shift << and the operator |= to get what is happening here and be able to add INPUT_BUTTONS add leisure and associate with the SDLK keys that I wish.

Thanks for your time and patience.
Reply


Messages In This Thread
Adding INPUT_BUTTONS - by JaumeAlcazo - 01-14-2019, 01:24 AM
RE: Adding INPUT_BUTTONS - by megamarc - 01-22-2019, 02:44 AM
RE: Adding INPUT_BUTTONS - by JaumeAlcazo - 01-25-2019, 07:05 AM
RE: Adding INPUT_BUTTONS - by megamarc - 01-25-2019, 09:13 AM
RE: Adding INPUT_BUTTONS - by JaumeAlcazo - 01-27-2019, 04:16 AM
RE: Adding INPUT_BUTTONS - by megamarc - 01-30-2019, 08:03 AM
RE: Adding INPUT_BUTTONS - by JaumeAlcazo - 01-31-2019, 04:02 AM
RE: Adding INPUT_BUTTONS - by megamarc - 02-02-2019, 09:28 PM
RE: Adding INPUT_BUTTONS - by JaumeAlcazo - 02-06-2019, 08:01 AM
RE: Adding INPUT_BUTTONS - by Richard Kain - 02-07-2019, 05:47 AM
RE: Adding INPUT_BUTTONS - by megamarc - 02-08-2019, 05:03 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)