Scan Codes wont' work
I''m tryin to get the arrow keys to work for my RPG, and when i use the scan codes for them, it ends up using the I,L,J and M keys instead. any help on this one?
Hmm, seems like you''ve got the wrong scan codes. Care to post the values you used?
Those appear to be high_word, low_word.
quote:From www.asciitable.com; IBM Scan Codes
Char Decimal HexadecimalUpArrw (00,72) (0x00,0x48)LftArrw (00,75) (0x00,0x4b)RtArrw (00,77) (0x00,0x4d)DwnArrw (00,80) (0x00,0x50)
Those appear to be high_word, low_word.
i''m trying to use the scan codes like this:
#define RtArrw 0x4d
#define LfArrw 0x4b
#define UpArrw 0x48
#define DnArrw 0x50
...
if (kbhit() == RtArrw)
...etc.
i''m assuming there is another way to use hex codes, but dont know too much about C++ yet.
#define RtArrw 0x4d
#define LfArrw 0x4b
#define UpArrw 0x48
#define DnArrw 0x50
...
if (kbhit() == RtArrw)
...etc.
i''m assuming there is another way to use hex codes, but dont know too much about C++ yet.
quote:Original post by Rogue Dragon
if (kbhit() == RtArrw)
It would behove you to peruse the documentation pertaining to kbhit(). It is specified as returning a non-zero value if the keyboard has been hit, and explicitly suggests the use of getch() or getche() to acquire the actual key:
...if(kbhit()){ switch(getch()) // get character without echoing to console { case UpArrw: // do up arrow stuff break; case RtArrw: // do right arrow stuff break; case DnArrw: // ...and so on default: // stuff to do if/when key hit is none of the arrow keys break; }}...
quote:i''m assuming there is another way to use hex codes, but dont know too much about C++ yet.
Has nothing to do with C++ per se. kbhit() is a standard C library function for the DOS/Windows platform.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement