[SDL] Numeric Keyboard

Jonathan Atkins jcatki at jcatki.no-ip.org
Sat Jul 13 14:03:01 PDT 2002


Bruno Martínez wrote:

> Hi:
> I'm programming a BangBang clone, so I need to ask the user the angle and speed. However, I can't make 
> the numeric keyboard work. Here's a fragment of code about what I'm trying to achieve:
> 
> case SDL_KEYDOWN:
> 	char ch;
> 	if ( (event.key.keysym.unicode & 0xFF80) == 0 ) {
> 		ch = event.key.keysym.unicode & 0x7F;
> 		cout << ch;
> 		if(isdigit(ch))
> 			MessageBeep(0);
> 	}
> It beeps with the numbers over the letter keys, but it doesn't with the rightmost numbers. Unicode 
> translation is ON, NumLock doesn't make a difference and the sym path (assuming ascii) doesn't work 
> either. 
> 
> Thanks, Bruno Martínez
> 

SDL_EnableUNICODE(1);
then use the keysym.unicode for the character...
read the SDL_keysym docs for how to trim the 16bit unicode down to ASCII.

then with numlock on you should get numbers...

-- 
              -=<Long Island Man>=-
                    Jon Atkins
              http://jonatkins.org/





More information about the SDL mailing list