SDL2:Weird Double Arrow Key Press With SDL_TEXTINPUT

Hi,

We recently added proper SDL_TEXTINPUT for printable characters.
We now have a weird issue with keyboard input:
When the game is first run the first time the user presses [Arrow] key it registers twice?
(after the double 1st key press the [Arrow] keys work as expected.

Can someone look at our current source code on GitHub?


(code is clean and code is current and project is stable)

Thanks!

Jesse
www.FallenAngelSoftware.com

Applied this “Bandaid”:

const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
if ( (screens->ScreenToDisplay != PlayingGameScreen)
 || (screens->ScreenToDisplay == PlayingGameScreen && usingCustomKeys == false) )
{
  if (keyboardState[SDL_SCANCODE_Z] && screens->ScreenToDisplay != NameInputMouseKeyboardScreen)  JoystickButtonOne[Keyboard] = ON;
  else if (keyboardState[SDL_SCANCODE_X] && screens->ScreenToDisplay != NameInputMouseKeyboardScreen)  JoystickButtonTwo[Keyboard] = ON;

    if      (keyboardState[   SDL_SCANCODE_UP])
    {
        if (ArrowKeyFirstPressed == true)  JoystickDirectionVertical[Keyboard] = UP;
        else  ArrowKeyFirstPressed = true;
    }
    else if (keyboardState[ SDL_SCANCODE_DOWN])
    {
        if (ArrowKeyFirstPressed == true)  JoystickDirectionVertical[Keyboard] = DOWN;
        else  ArrowKeyFirstPressed = true;
    }

    if      (keyboardState[ SDL_SCANCODE_LEFT])
    {
        if (ArrowKeyFirstPressed == true)  JoystickDirectionHorizonal[Keyboard] = LEFT;
        else  ArrowKeyFirstPressed = true;
    }
    else if (keyboardState[SDL_SCANCODE_RIGHT])
    {
        if (ArrowKeyFirstPressed == true)  JoystickDirectionHorizonal[Keyboard] = RIGHT;
        else  ArrowKeyFirstPressed = true;
    }
}
else if (screens->ScreenToDisplay == PlayingGameScreen && usingCustomKeys == true)
{
  if (keyboardState[UserDefinedKeyButtonOne] && screens->ScreenToDisplay != NameInputMouseKeyboardScreen)  JoystickButtonOne[Keyboard] = ON;
  else if (keyboardState[UserDefinedKeyButtonTwo] && screens->ScreenToDisplay != NameInputMouseKeyboardScreen)  JoystickButtonTwo[Keyboard] = ON;

    if      (keyboardState[       UserDefinedKeyUP])  JoystickDirectionVertical[Keyboard] = UP;
    else if (keyboardState[     UserDefinedKeyDOWN])  JoystickDirectionVertical[Keyboard] = DOWN;

    if      (keyboardState[     UserDefinedKeyLEFT])  JoystickDirectionHorizonal[Keyboard] = LEFT;
    else if (keyboardState[    UserDefinedKeyRIGHT])  JoystickDirectionHorizonal[Keyboard] = RIGHT;
}

But still wondering about it…

Jesse