Jump to content

Not processing keypress

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Christoph

Christoph

    Newbie

  • Members
  • PipPip
  • 10 posts
I have a little issue, this is for a barcode scanner, this is the function that is being called to gather the data to be scanned.

The problem I am having is that after the keypress is made it records it and doesn't process it until after the scanner scans something. I have it doing something very similar in another function that works just fine, it takes the keypress and processes it right then but for the life of me I cannot figure out why it is not working here. The code itself works, it just works wrong.


int GetScanData()
{
    int readKeypad;
    BOOL scKey;
    BOOL scanAgain;
    do{
    scKey = NGS_Kbhit(); // Returns TRUE/FALSE
    if(scKey == TRUE)
    {
        readKeypad = NGS_rKeypad(); // Gets int value of key pressed
        if (readKeypad == KEY1)
        {
            scanAgain = FALSE;
            return 0;
            
        } else if (readKeypad == KEY2)
        {
            scanAgain = FALSE;
            return 0;
        }

    }else if(scKey == FALSE)
    {
        NGS_rScanner(equip, 1, 0 ,0); // Collects barcode and stores it in an array
        scanData[e] = str; // Add string to the array
        printf("\n%s", scanData[e]);
        e = e + 1;
        scanAgain = TRUE;
    }
    }while(scanAgain == TRUE);
    return 0;
}
Please tell me what I'm doing that is stupid, I know it is something stupid. :mad:

#2
Ancient Dragon

Ancient Dragon

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 400 posts
Is it possible that the value of readKeypad is something other than KEY1 or KEY2? Put an else statement there to find out.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.

#3
Christoph

Christoph

    Newbie

  • Members
  • PipPip
  • 10 posts
I've actually tried that, I even wrote it to give me the integer value of the key pressed and ran it across that value. This is just one of many ways that I have tried to get around this problem.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users