uint8_t XBOXUSB::Poll() { if (!bPollEnable) return 0; uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; pUsb->inTransfer(bAddress, epInfo[ XBOX_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 readReport(); #ifdef PRINTREPORT printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller #endif return 0; }
uint8_t PS3USB::Poll() { if(!bPollEnable) return 0; if(PS3Connected || PS3NavigationConnected) { uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 if(millis() - timer > 100) { // Loop 100ms before processing data readReport(); #ifdef PRINTREPORT printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers #endif } } else if(PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB if(millis() - timer > 4000) { // Send at least every 4th second Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on timer = millis(); } } return 0; }
/*------------------------------------------------------------------------- Run n copies of the test. Return value is 0 on success. -------------------------------------------------------------------------*/ int /* */ run_n_nodes( char *exe, /* */ int loops) /* */ { char *childArgs[7] = {NULL, NULL, "nhosts", "nloops", "childnum", "nextadr.possibly.internet.address:maybeWithPortNumber", NULL}; int* procs = NULL; int* result = NULL; int i; childArgs[0] = exe; childArgs[1] = results.driver; if ((procs = (int *) malloc(results.n_hosts * sizeof(int))) == NULL) abortTest(logFile, 3, "Unable to allocate process handle storage.\n", NULL); if((result = (int *) malloc(results.n_hosts * sizeof(int))) == NULL) abortTest(logFile, 3, "Unable to allocate result storage.\n", NULL); /* Start tests */ for (i=0; i < results.n_hosts; i++) { sprintf(childArgs[2], "%d", results.n_hosts); sprintf(childArgs[3], "%d", loops); sprintf(childArgs[4], "%d", i); #if LOOPBACK_ADDRESS sprintf(childArgs[5], "%d.0.0.0", ((i+1) % results.n_hosts) + 1); #elif INTERNET_ADDRESS sprintf(childArgs[5], "207.82.188.88:%d", ((i+1) % results.n_hosts) + PORT_OFFSET); #else Warning: Must choose one of the above defines. #endif printf("Launching %s %s %s %s %s %s\n", childArgs[0], childArgs[1], childArgs[2], childArgs[3], childArgs[4], childArgs[5]); procs[i] = _spawnv(_P_NOWAIT, exe, childArgs); if(procs[i] == -1) { sprintf(buf, "Unable to start process %d: %s\n", i, strerror(errno)); abortTest(logFile, 4, buf, NULL); } } /* Wait for tests to finish */ for (i=0; i < results.n_hosts; i++) { _cwait(&(result[i]), procs[i], 0); printf("Node %d returned %d\n", i, result[i]); } /* Get test results */ { FILE* fp; char fname[256]; sprintf(fname, LOGNAME, 0); if ((fp = fopen(fname, "r")) != NULL) { readReport(fp, &results); } else fprintf(logFile, "Can't read client %d's logfile %s\n", 0, fname); } writeReport(logFile, &results); return 0; }