void WaitForPress(void) { int cmd1, cmd2; do { GetPlayerCmd(&cmd1, &cmd2); //SoundTick(); } while (((cmd1 | cmd2) & (CMD_BUTTON1 | CMD_BUTTON2)) == 0 && !AnyKeyDown()); }
void GetEvent(int *key, int *x, int *y, int *buttons) { static int scaling = 1; static int wasDown = 0; static int isRepeating = 0; int xPrev = -1, yPrev = -1; int drawn = 0; //void *old = GetDstScreen(); Mouse(x, y, buttons); if (*buttons != 0 && wasDown) SDL_EnableKeyRepeat(isRepeating ? 100 : 500, 250); //SetDstScreen(new); *buttons = *key = 0; do { //if (kbhit()) if (AnyKeyDown()) { *key = GetKey(); } Mouse(x, y, buttons); *x /= scaling; if (*x > 319) scaling++; if (!(*buttons) && !(*key) && (*x != xPrev || *y != yPrev)) { if (drawn) ; //RestoreBkg(xPrev, yPrev, old); DrawCursor(*x, *y); xPrev = *x; yPrev = *y; drawn = 1; } } while (!(*buttons) && !(*key)); if (drawn) ; //RestoreBkg(xPrev, yPrev, old); isRepeating = wasDown && (buttons != 0); wasDown = (*buttons != 0); //SetDstScreen(old); }
void WaitForRelease(void) { int cmd1, cmd2; int releaseCount = 0; do { GetPlayerCmd(&cmd1, &cmd2); if (((cmd1 | cmd2) & (CMD_BUTTON1 | CMD_BUTTON2)) != 0 || AnyKeyDown()) releaseCount = 0; else releaseCount++; // SoundTick(); // vsync(); } while (releaseCount < 4); }