bool Pad::waitReady() { int state; char stateString[16]; state = padGetState(m_port, m_slot); int lastState = -1; while ((state != PAD_STATE_STABLE) && (state != PAD_STATE_FINDCTP1)) { if (state != lastState) { padStateInt2String(state, stateString); //printf("Please wait, pad(%d,%d) is in state %s\n",m_port, m_slot, stateString); } lastState = state; state = padGetState(m_port, m_slot); } // Were the pad ever 'out of sync'? if (lastState != -1) { //printf("Pad OK!\n"); } return true; }
static int wait_pad(int port, int slot, int tries) { int state, last_state; char state_string[16]; state = padGetState(port, slot); if (state == PAD_STATE_DISCONN) { /* printf("SDL_Joystick: pad (%d, %d) is disconnected\n", port, slot); */ return -1; } last_state = -1; while ((state != PAD_STATE_STABLE) && (state != PAD_STATE_FINDCTP1)) { if (state != last_state) { padStateInt2String(state, state_string); printf("SDL_Joystick: pad (%d,%d) is in state %s\n", port, slot, state_string); } last_state = state; state = padGetState(port, slot); tries--; if (tries == 0) { printf("waited too long! giving up\n"); break; } } return 0; }
static int waitPadReady(int port, int slot) { int state; int lastState; char stateString[16]; state = padGetState(port, slot); lastState = -1; while((state != PAD_STATE_STABLE) && (state != PAD_STATE_FINDCTP1)) { if (state != lastState) { padStateInt2String(state, stateString); } lastState = state; state=padGetState(port, slot); } // Were the pad ever 'out of sync'? if (lastState != -1) { } return 0; }