Numeric Keyboard

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

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

Which characters DOES it return when you press the numpad keys?

RK.

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…–
-==-
Jon Atkins
http://jonatkins.org/