Basically, I've been dealing with a String Input Problem in SDL for some time now, I was browsing the forums for help on gamedev.net and I found this function, which makes sure a key is some printable char and then returns the actual char associated with this unicode number, upon compilation in Code Blocks 10.04 I get the following compilation error: cannot convert 'const SDL_KeyboardEvent' to 'SDLKey' for argument 1 to 'char*..... Any help would be very appreciated.
char getUnicodeValue( const SDL_KeyboardEvent &key )
{
assert( SDL_EnableUNICODE(SDL_QUERY) == SDL_ENABLE );
// magic numbers courtesy of SDL docs :)
constint INTERNATIONAL_MASK = 0xFF80, UNICODE_MASK = 0x7F;
int uni = key.keysym.unicode;
if( uni == 0 ) // not translatable key (like up or down arrows)
{
// probably not useful as string input
// we could optionally use this to get some value
// for it:
SDL_GetKeyName( key );
return 0;
}
elseif( ( uni & INTERNATIONAL_MASK ) == 0 )
{
returnstatic_cast<char>(uni & UNICODE_MASK);
}
else
// we have a funky international character. one we can't read :(
{
// return 0 to inform the caller that we can't deal with this key.
return 0;
}
}