Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Rogue Dragon

Scan Codes wont' work

This topic is 6172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Hmm, seems like you''ve got the wrong scan codes. Care to post the values you used?

quote:
From www.asciitable.com; IBM Scan Codes

Char Decimal Hexadecimal
UpArrw (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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!