[SDL] Reading text from keyboard

Daniel Phillips phillips at arcor.de
Tue Jan 21 19:29:01 PST 2003


On Friday 17 January 2003 23:04, ToyToy wrote:
> I now added unicode support with SDL_EnableUNICODE(1) and try to process
> the events like this:
>
> 	while(SDL_PollEvent(&Event))
> 	{
> 		switch(Event.type)
> 		{
> 			case SDL_KEYDOWN:
> 				if((Event.key.keysym.unicode & 0xFF80) == 0)
> 				{
> 					char ch = Event.key.keysym.unicode & 0x7F;
> 					if(ch)
> 						m_strText += ch;
> 				}
> 		}
> 	}
>
> The problem is that the variable ch is always zero whatever key I press. Do
> you have any idea what I'm doing wrong? (I've got WinXP)

Try making ch (unsigned) instead of (char).

Regards,

Daniel




More information about the SDL mailing list