void AutonomousPeriodic() { /*if(!done && !autonomousMode) { Auto("Move", -.2, 100, 1.0, .975); Auto("Move", -0.6, 600, 1.0, .975); Auto("Move", .2, 100, .85, 1.0); Auto("Move", 0.6, 600, .85, 1.0); Auto("Move", -.2, 100, 1.0, .975); Auto("Move", -0.6, 600, 1.0, .975); done = true; }*/ if(!done/* && autonomousMode*/) { Auto("Move", -.2, 100, 1.0, 1.0); Auto("Move", -.6, 725, 1.0, 1.0); done = true; } else { frontLeft->Set(0.0); backLeft->Set(0.0); frontRight->Set(0.0); backRight->Set(0.0); } }
S32 CNetObj::SndMsg(ADP::Msg_t& Msg, S32 mSec) { CAutoDoT<CLock> Auto(m_SndMsgLock); if (m_SndBuf.DataLen() > 0) { S32 Sent = SndData(m_SndBuf.GetRdPos(), m_SndBuf.DataLen(), 0); if (Sent < 0) { DEBUG_ERROR("%s(err)[ %s(%d)]\n", __FUNCTION__, __FILE__, __LINE__); } m_SndBuf.Clear(); } Msg.Magic = ADP_MSG_MAGIC; Msg.Live = GET_TICKS(); Msg.Id = m_SndBuf.FreeLen(); S32 Size = m_pAdapter->Fill(Msg, m_SndBuf.GetWrPos(), Msg.Id); if (Size < 0) { DEBUG_ERROR("Snd msg cmd = %d failed, adapter fill", Msg.Type); return Size; } m_SndBuf.IncLen(Size); Size = SndData(m_SndBuf.GetRdPos(), m_SndBuf.DataLen(), 300); if (Size < 0) { m_SndBuf.Clear(); DEBUG_ERROR("Snd msg cmd = %d failed, senddata", Msg.Type); return NET_MSG_SEND_ERR; } m_SndBuf.DecLen(Size); return MW_SUCC; }
/*********************************************************************************************************************** Function: QTaskBody Description: Called By: Input: Output: Return: Others: ************************************************************************************************************************/ S32 CNetServer::QTaskBody() { //S32 flag; //S32 ReuseAddr = 1; while( true ) { do { Socket_t sHandle; do { CAutoDoT<CLock> Auto(m_QTaskLock); while (QTaskEmpty()) { m_QTaskCond.Wait(m_QTaskLock); } sHandle = QTaskPop(); } while (0); if (!SOCK_HANDLE_OK(sHandle)) { continue; } //U32 Mode = SOCK_CTL_NOBLOCK; //SOCK_CTL(sHandle, SOCK_CTL_CMD, &Mode); if ( MW_SUCC != m_pThreadPool->TaskAdd(TaskCb, sHandle, this) ) { DoSrvBusy(sHandle); } } while( 0 ); } return MW_SUCC; }
static bool usb_endpoint_iterate(libusb_device_handle* handle, const Callback& callback) { struct libusb_config_descriptor* config; int rc = libusb_get_active_config_descriptor(libusb_get_device(handle), &config); if (rc != 0) { error("failed to get active config descriptor"); return false; } Auto(libusb_free_config_descriptor(config)); for (size_t i = 0; i < config->bNumInterfaces; ++i) { const libusb_interface& interface = config->interface[i]; for (ssize_t j = 0; j < interface.num_altsetting; ++j) { const libusb_interface_descriptor& interface_descriptor = interface.altsetting[j]; for (size_t k = 0; k < interface_descriptor.bNumEndpoints; ++k) { const libusb_endpoint_descriptor& endpoint = interface_descriptor.endpoint[k]; switch (callback(interface_descriptor, endpoint)) { case usb_endpoint_iterate_result::proceed: continue; case usb_endpoint_iterate_result::terminate: return true; } } } } return true; }
/*********************************************************************************************************************** Function: QTaskPush Description: Called By: Input: Output: Return: Others: ************************************************************************************************************************/ S32 CNetServer::QTaskPush(Socket_t sHandle) { do { CAutoDoT<CLock> Auto(m_QTaskLock); m_QTask.push(sHandle); } while (0); m_QTaskCond.Wake(); return MW_SUCC; }
static libusb_device_handle* open_device_timeout(std::vector<int> accepted_pids, std::chrono::milliseconds timeout) { int rc; auto start = std::chrono::steady_clock::now(); // TODO: Make this less dumb. while (std::chrono::steady_clock::now() - start < timeout) { libusb_device** devices; ssize_t device_count = libusb_get_device_list(nullptr, &devices); Auto(libusb_free_device_list(devices, true)); if (device_count < 0) { error("failed to get connected devices: %s", libusb_error_name(device_count)); return nullptr; } for (int i = 0; i < device_count; ++i) { libusb_device* device = devices[i]; struct libusb_device_descriptor descriptor; rc = libusb_get_device_descriptor(device, &descriptor); if (rc != 0) { error("failed to get device descriptor: %s", libusb_error_name(rc)); return nullptr; } if (descriptor.idVendor == VID_GOOGLE) { info("found device %x:%x", descriptor.idVendor, descriptor.idProduct); auto it = std::find(accepted_pids.cbegin(), accepted_pids.cend(), descriptor.idProduct); if (it != accepted_pids.cend()) { libusb_device_handle* handle; rc = libusb_open(device, &handle); if (rc != 0) { error("failed to open device: %s", libusb_error_name(rc)); return nullptr; } return handle; } else { info("failed to match device to accepted PIDs"); } } } std::this_thread::sleep_for(100ms); } debug("timeout elapsed while waiting for device"); return nullptr; }
void Scene::setbg_3(){ QString load; if(difficulty==4) load=":/pics/pics/bg_oni.png"; else if(difficulty==3) load=":/pics/pics/bg_hard.png"; else if(difficulty==2) load=":/pics/pics/bg_normal.png"; else load=":/pics/pics/bg_easy.png"; QImage bg; bg.load(load); bg = bg.scaled(770,400); this->setBackgroundBrush(bg); text1->setText(title[s]); text1->setPos(488,9); addItem(text1); Map.setSongPlay(title[s]); track = new QMediaPlayer(this); track->setMedia(QUrl::fromLocalFile(QDir::toNativeSeparators(Map.trackPath))); VOL=(Map.map["SONGVOL"]-Map.map["SEVOL"])>0?(Map.map["SONGVOL"]-Map.map["SEVOL"]+50):70; track->setVolume(VOL); BPM=Map.map["BPM"]; Map.getMap(title[s],Map.star[difficulty-1]); Map.convert(setRandom); if(setRandom==true){ QPixmap ran; ran.load(":/pics/pics/optionicon_random.png"); randomTag = new QGraphicsPixmapItem; randomTag->setPos(199,83); randomTag->setPixmap(ran); addItem(randomTag); } if(setAuto==true){ QPixmap au; au.load(":/pics/pics/optionicon_auto.png"); autoTag = new QGraphicsPixmapItem; autoTag->setPos(394,72); autoTag->setPixmap(au); addItem(autoTag); } if(set30secMode==true){ QPixmap ctd; ctd.load(":/pics/pics/optionicon_demo.png"); countdownTag = new QGraphicsPixmapItem; countdownTag->setPos(294,72); countdownTag->setPixmap(ctd); addItem(countdownTag); countdown = new QTimer(this); QObject::connect(countdown , SIGNAL(timeout()) , this , SLOT(secondsLeft())); } songMap=Map.songMap; foreach (QString i, songMap) { qDebug()<<i<<endl; } RD = new QTimer(this); LD = new QTimer(this); RK = new QTimer(this); LK = new QTimer(this); rdp = new QGraphicsPixmapItem;ldp = new QGraphicsPixmapItem; rkp = new QGraphicsPixmapItem;lkp = new QGraphicsPixmapItem; QPixmap res; res.load(":/pics/pics/rd.png"); rdp->setPixmap(res);rdp->setPos(147,123); res.load(":/pics/pics/ld.png"); ldp->setPixmap(res);ldp->setPos(106,123); res.load(":/pics/pics/rk.png"); rkp->setPixmap(res);rkp->setPos(147,124); res.load(":/pics/pics/lk.png"); lkp->setPixmap(res);lkp->setPos(105,124); for(int i=0;i<4;i++){ add[i]=false; } QObject::connect(this , SIGNAL(PlayRdong()) , this , SLOT(playRdong())); QObject::connect(this , SIGNAL(PlayLdong()) , this , SLOT(playLdong())); QObject::connect(this , SIGNAL(PlayRka()) , this , SLOT(playRka())); QObject::connect(this , SIGNAL(PlayLka()) , this , SLOT(playLka())); QObject::connect(RD , SIGNAL(timeout()) , this , SLOT(playRdong())); QObject::connect(LD , SIGNAL(timeout()) , this , SLOT(playLdong())); QObject::connect(RK , SIGNAL(timeout()) , this , SLOT(playRka())); QObject::connect(LK , SIGNAL(timeout()) , this , SLOT(playLka())); AniTimer1 = new QTimer(this); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(moveJudgement())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(FlySoul())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(MidSoul())); QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(WalkSoul())); QObject::connect(this , SIGNAL(Great()) , this , SLOT(GenGreat())); QObject::connect(this , SIGNAL(Good()) , this , SLOT(GenGood())); QObject::connect(this , SIGNAL(Miss()) , this , SLOT(GenMiss())); QObject::connect(this , SIGNAL(Combo()) , this , SLOT(ShowCombo())); QObject::connect(this , SIGNAL(Score()) , this , SLOT(ShowScore())); QObject::connect(this , SIGNAL(Jump()) , this , SLOT(donJump())); QObject::connect(this , SIGNAL(SoulF()) , this , SLOT(GenFlySoul())); QObject::connect(this , SIGNAL(SoulM()) , this , SLOT(GenMidSoul())); QObject::connect(this , SIGNAL(SoulW()) , this , SLOT(GenWalkSoul())); ex1.load(":/pics/pics/explosion_s4.png"); AniTimer2 = new QTimer(this); QObject::connect(AniTimer2 , SIGNAL(timeout()) , this , SLOT(RemoveExplode())); QObject::connect(this , SIGNAL(Explode()) , this , SLOT(GenExplode())); AniTimer3 = new QTimer(this); QObject::connect(AniTimer3 , SIGNAL(timeout()) , this , SLOT(Jumper())); jumper = new QGraphicsPixmapItem; jumper->setPos(0,0); addItem(jumper); AniTimer4 = new QTimer(this); QObject::connect(AniTimer4 , SIGNAL(timeout()) , this , SLOT(Dance())); loadDancerPic(); createDanceItem(); great=0;good=0;miss=0; combo=0;maxcombo=0;soul=0,score=0; secLeft=30;jumpPicNum=1; msec=60000/BPM/4+2; test=60000/BPM/16; waitfor=109*test/2+Map.map["OFFSET"]*1000; for(int i=0;i<10;i++){ numberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png"); } for(int i=0;i<10;i++){ ctdnumberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png"); } for(int i=0;i<10;i++){ scorenumberPic[i].load(":/pics/pics/scorenumber_"+QString::number(i)+".png"); } for(int i=50;i<1000;i+=100){ QSound *so; QString c; c=QString::number(i); so = new QSound(":/sound/sound/voice_"+c+"combo.wav"); comTrack.push_back(so); if(i==50)i+=50; } for(int i=0;i<3;i++){ jumpPic[i].load(":/pics/pics/playerchar_normal"+QString::number(i+1)+".png"); jumpPic[i] = jumpPic[i].scaled(jumpPic[i].width()*1.48,jumpPic[i].height()*1.48); } //Etimer = new QElapsedTimer; //Etimer->start(); timer = new QTimer(this); QObject::connect(timer , SIGNAL(timeout()) , this , SLOT(stopWait())); timer1 = new QTimer(this); timer2 = new QTimer(this); timer3 = new QTimer(this); cout<<"msec: "<<msec<<endl; cout<<"waitfor: "<<waitfor<<endl; QObject::connect(timer2 , SIGNAL(timeout()) , this , SLOT(Generate())); if(setAuto==false) QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Move())); else QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Auto())); QObject::connect(timer3 , SIGNAL(timeout()) , this , SLOT(startWave())); if(waitfor<0){ track->play(); timer->start(-waitfor); waitfor=0; } else timer->start(0); }
virtual bool generate(OutputIterator& sink, Context& context, no_delimiter) { return generate_main(sink, context, unused, Auto()); }
virtual bool generate(OutputIterator& sink, Context& context, delimiter_type const& delim) { return generate_main(sink, context, delim, Auto()); }