Page 1 of 1

getKeyText Issue

PostPosted: Thu Jan 05, 2006 7:54 pm
by RobH
I am trying to code a feedback which evaluates the keyboard input. I have searched the forums and the tutorial and have made it nearly work, but am now stumped.

This is supposed to play a cheering sound if you press A and an oops sound if you press any other key. I can only get oops to run. I pirated code from the turorial and created a txtguy actor to see what the return data looks like and the key names appear on screen as expected.

I am new to C and am guessing this is a data type issue. Thanks for any help!

Rob

The code is:
Code: Select all
int keyCode = getLastKey();

if(getKeyText(keyCode) == "A"){
PlaySound2("data/cheer.wav", 1.000000, 1, 0.000000);
           }
else{
PlaySound2("data/oops.wav", 1.000000, 1, 0.000000);
    }


strcpy(textguy.text, getKeyText(keyCode));

PostPosted: Thu Jan 05, 2006 8:07 pm
by makslane
You can use getLastKey to test without use getKeyText:

Code: Select all
if(getLastKey() == KEY_a)
{
   //Your code here
}


If you need test the string, use the strcmp function:

Code: Select all
if(strcmp(getKeyText(keyCode), "A") == 0)
{
   //Your code here
}

getKeyText Issue

PostPosted: Thu Jan 05, 2006 9:20 pm
by RobH
Excellent - thanks for the help!