/* * Get current pad state * Wait until state == 6 (Ready) before trying to access the pad */ int padGetState(int port, int slot) { struct pad_data *pdata; unsigned char state; pdata = padGetDmaStr(port, slot); state = pdata->state; if (state == PAD_STATE_ERROR) { if (pdata->findPadRetries) { return PAD_STATE_FINDPAD; } } if (state == PAD_STATE_STABLE) { // Ok if (padGetReqState(port, slot) == PAD_RSTAT_BUSY) { return PAD_STATE_EXECCMD; } } return state; }
void padWait(int port) { /* Wait for request to complete. */ while(padGetReqState(port, 0) != PAD_RSTAT_COMPLETE) wait_vsync(); /* Wait for pad to be stable. */ while(padGetState(port, 0) != PAD_STATE_STABLE) wait_vsync(); }