문제

I'm using this code to to determine keyboard inputs as unicode character:

while(SDL_PollEvent(&event))
{
    switch (event.type)
    {
        case SDL_KEYDOWN:
        {
            SDL_KeyboardEvent* keyboard = (reinterpret_cast<SDL_KeyboardEvent*> (&event));

            //unicode input
            std::cout << (int)keyboard->keysym.unicode << std::endl;

            //conversion
            ...

            break;
        }
    }
}

My problem is that keysym.unicode has also a value if I would only press the Shift-key (printed value is 1249).

But I only need valid unicode-charactars (e.g.: pressing Shift+A)

Any hints?

도움이 되었습니까?

해결책

I fixed it using: SDL_StartTextInput(); to enable textinput-events with:

SDL_TEXTINPUT-event instead of SDL_KEYDOWN is working fine.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top