Jump to content



Photo
- - - - -

Help With Iskeydown


  • Please log in to reply
1 reply to this topic

#1 AtomicSneakers

AtomicSneakers

    Newbie

  • Members
  • Pip
  • 1 posts

  • Calculators:
    fx-9860GII

Posted 19 April 2011 - 10:03 PM

Hey guys, I'm new to all this programming but I'm making a bit of progress recently. One thing has had me stumped though. I'm working on a game for me to goof around with, but I keep running into the same bug. Posted Image

void WaitForExe(){    while (IsKeyDown(KEY_CTRL_EXE) != 1)    {        if (IsKeyUp(KEY_CTRL_EXIT) != 1 || IsKeyUp(KEY_CTRL_MENU) != 1)        {            Reset_Calc();        }    }}int AddIn_main(int isAppli, unsigned short OptionNum){    Bdisp_AllClr_DDVRAM();    CoolText(1, 1, FONT_FIVE, "HELLO", SDK_VRAM);    Bdisp_PutDisp_DD();    WaitForExe();    Bdisp_AllClr_DDVRAM();    CoolText(1, 1, FONT_FIVE, "WORLD", SDK_VRAM);    Bdisp_PutDisp_DD();    WaitForExe();    Reset_Calc();    return 0;}

Problem is, my program always runs right through the second WaitForExe without any input in the "WORLD" part, but not if I replace the WaitForExe with a different loop, like

while (IsKeyDown(KEY_CTRL_EXIT){}

The problem only occurs when I try to run IsKeyDown on the same key twice in a row. It can be any key.

I think that the functions aren't running correctly the second time, or that they're returning the same result for some reason, or perhaps the program is running too fast for the calculator to register the change in the state of the exe button. I've tried using Sleep(x) where x is 500 or 1000 or so but that always crashes the emulator for some reason. Can someone tell me what's wrong or how to fix this?

EDIT: CoolText() is a RevolutionFx function for those of you who are unfamiliar with it. But I've isolated the problem to IsKeyDown, so I know that CoolText isn't the problem.

EDIT #2: Found out that the text was being drawn so fast I couldn't let go of the exe button before it finished drawing. I added while (IsKeyUp(KEY_CTRL_EXE) != 1) {} to the end of the WaitForExe() command and now it's fixed. This thread can be deleted.

Edited by AtomicSneakers, 19 April 2011 - 10:19 PM.


#2 Eiyeron

Eiyeron

    Newbie

  • Members
  • Pip
  • 10 posts
  • Gender:Male

  • Calculators:
    Graph 35+Usb modded to G75
    Graph 25+
    Graph 100+

Posted 18 July 2011 - 12:32 PM

Hey guys, I'm new to all this programming but I'm making a bit of progress recently. One thing has had me stumped though. I'm working on a game for me to goof around with, but I keep running into the same bug. Posted Image

void WaitForExe(){    while (IsKeyDown(KEY_CTRL_EXE) != 1)    {        if (IsKeyUp(KEY_CTRL_EXIT) != 1 || IsKeyUp(KEY_CTRL_MENU) != 1)        {            Reset_Calc();        }    }}int AddIn_main(int isAppli, unsigned short OptionNum){    Bdisp_AllClr_DDVRAM();    CoolText(1, 1, FONT_FIVE, "HELLO", SDK_VRAM);    Bdisp_PutDisp_DD();    WaitForExe();    Bdisp_AllClr_DDVRAM();    CoolText(1, 1, FONT_FIVE, "WORLD", SDK_VRAM);    Bdisp_PutDisp_DD();    WaitForExe();    Reset_Calc();    return 0;}

Problem is, my program always runs right through the second WaitForExe without any input in the "WORLD" part, but not if I replace the WaitForExe with a different loop, like

while (IsKeyDown(KEY_CTRL_EXIT){}

The problem only occurs when I try to run IsKeyDown on the same key twice in a row. It can be any key.

I think that the functions aren't running correctly the second time, or that they're returning the same result for some reason, or perhaps the program is running too fast for the calculator to register the change in the state of the exe button. I've tried using Sleep(x) where x is 500 or 1000 or so but that always crashes the emulator for some reason. Can someone tell me what's wrong or how to fix this?

EDIT: CoolText() is a RevolutionFx function for those of you who are unfamiliar with it. But I've isolated the problem to IsKeyDown, so I know that CoolText isn't the problem.

EDIT #2: Found out that the text was being drawn so fast I couldn't let go of the exe button before it finished drawing. I added while (IsKeyUp(KEY_CTRL_EXE) != 1) {} to the end of the WaitForExe() command and now it's fixed. This thread can be deleted.



Use
while(IsKeyUp(KEY_CTRL_EXE));
while(IsKeyDown(KEY_CTRL_EXE));



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users