need help with keyboard input (sdl)
Posted: Mon Jun 21, 2010 6:19 pm
I am having a problem following lazy foos tutorial, I decided to use char instead of a string, the problem that I am encountering is that when I use event.key.keysym.unicode it does not update the array of chars, and the problem with event.key.keysym.sym is that it does not recognize capital letters. The only reason why I do not want to use string is because certain functions I want to use require chars, any one have any ideas on how to get unicode to work?
Code: Select all
//counter = 0;
//char writing[40]
if (event.type == SDL_KEYDOWN)
{
SDL_EnableUNICODE( SDL_ENABLE );
if (counter < 40)
{
if( ( event.key.keysym.sym == (Uint16)' ' ) ||
( event.key.keysym.sym >= (Uint16)'0' ) && ( event.key.keysym.sym <= (Uint16)'9' ) ||
( event.key.keysym.sym >= (Uint16)'A' ) && ( event.key.keysym.sym <= (Uint16)'Z' ) ||
( event.key.keysym.sym >= (Uint16)'a' ) && ( event.key.keysym.sym <= (Uint16)'z' ) )
{
writing[counter] = (char)event.key.keysym.sym ;
printf("sd\n");
counter++;
}
}
printf("char is %c\n",(char)event.key.keysym.unicode );
SDL_EnableUNICODE( SDL_DISABLE );
}