If you are looking for keyboard output (keyboard meaning a computer keyboard, not a robot one?), I think what you’re looking for are scan codes (wiki article), which is what the keyboard sends as a number when a key is pressed. Are you trying to use a keyboard to control a robot instead of a joystick?
Here is a very simple routine I did once to test C (not C++) keyboard output:
void stream (void) //type out info
{
int ch;
while ( (ch=getch()) != '\r') //loop until ENTER key pressed
{
if (ch==0xE0) //signals 2 char arrow code
{
RShow(ch);
//printf("%c=%d] or %X] ", ch, ch, ch);
ch=getch(); //get second character
RShow(ch);
//printf("%c=%d] or %X]
", ch, ch, ch);
}
else if (ch==0x00) //signals 2 char function key
{
printf("%c=%d] or %X] ", ch, ch, ch);
ch=getch(); //get second character
printf("%c=%d] or %X]
", ch, ch, ch);
}
else //regular old ASCII code (single character)
{
printf("%c=%d] or %X]
", ch, ch, ch);
}
//putch(ch); //display char
}
printf("%c=%d] or %X]
", ch, ch, ch);
}
void RShow ( char ch )
{
printf("%c", ch);
printf("=%-3d]",ch);
printf(" or [0x%-2X]",ch);
printf("
");
}
Most keys are sent as ASCII codes, but the special keys (arrows and function keys) are, well, special, and sent as two numbers. For arrows, the first number is 0XE0 (hexidecimal number); the second key indicates the arrow type. For Function keys, first number is a zero.
Come to think of it, these might not be true “scan codes”, but are actually semi-processed numbers. True scan codes I think send the actual keyboard key and you have to figure out what key that represents (depending on hardware), and then mix in the shift/ctrl/alt key(s) separately. (Making a Dvorak keyboard from a QWERTY, for example, back in DOS days.) That’s more assembler than C code, so don’t worry about it.
What whitetiger0990 has are the codes the robot controller gives you for joystick output. Normally joysticks and keyboards don’t mix, so I too am curious on what you may be trying to do.
“If it weren’t for electricity we’d all be watching television by candlelight.” - George Gobel