list<Entity*> OverheadPlayer::update(float diff) { list<Entity*> result; orientPlayer(); Entity::update(diff); cooldown -= diff; if(cooldown<0) cooldown = 0; bool xflag = false; bool yflag = false; if(Keyboard::isKeyPressed(application->controls.getKey("Move Up"))) { yflag = true; accelerateCenter(b2Vec2(0, -5.f)); } if(Keyboard::isKeyPressed(application->controls.getKey("Move Down"))) { yflag = true; accelerateCenter(b2Vec2(0, 5.f)); } if(Keyboard::isKeyPressed(application->controls.getKey("Move Right"))) { xflag = true; accelerateCenter(b2Vec2(5.f, 0.f)); } if(Keyboard::isKeyPressed(application->controls.getKey("Move Left"))) { accelerateCenter(b2Vec2(-5.f, 0.f)); xflag = true; } if(Mouse::isButtonPressed(application->controls.getMouseButton("Shoot"))) { if(cooldown==0) result.push_back(shoot()); } if(!xflag && !yflag) { idle(); } if(!xflag) decelerateX(); if(!yflag) decelerateY(); return result; }
int main(int argc, char *argv[]) { init(); glfwInit(); window = glfwCreateWindow(1024, 1024, "OpenGL", nullptr, nullptr); // Windowed glfwMakeContextCurrent(window); glfwSwapInterval(1); glClearColor(0.8f, 0.8f, 0.8f, 0.8f); while(!glfwWindowShouldClose(window)){ float ratio; int width, height; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-50.0, 562.0, -50.0, 562.0, -1, 1); box.DrawBox(show_grid); drawText(); calculateAcceleration(); handleInputs(); display(); idle(); //Swap front and back buffers glfwSetWindowSizeCallback(window, reshape_window); glfwSwapBuffers(window); //Poll for and process events glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); return EXIT_SUCCESS; }
/* ARGSUSED1 */ void keyboard(unsigned char ch, int x, int y) { switch (ch) { case 27: /* escape */ exit(0); break; case ' ': if (!moving) { idle(); glutPostRedisplay(); } } }
/** * RSID function for use during testing. Not for flight */ void rsid_test(void) { while (1) { telemetry_start_rsid(RSID_CONTESTIA_32_1000); // Sleep wait for RSID while (telemetry_active()) { idle(IDLE_TELEMETRY_ACTIVE); } for (int i = 3*200*1000; i; i--); } }
//////////////////////////////////////////////////////////////////////////////// // delay // PURPOSE: Blocks for a given number of seconds. // PARAMS: (IN) int time - number of seconds to delay. // RETURNS: Nothing. // NOTES: Unreliable before init_timer is run. //////////////////////////////////////////////////////////////////////////////// void delay(int time){ u32 now = 0; now = get_time_timer(); while(time--) { while(now == get_time_timer()) { idle(); } now = get_time_timer(); } }
s32 sys_exit() { u32 eflags; _local_irq_save(eflags); if (task_list[current].pwait != 0) task_wakeup(task_list[current].pwait); task_list[current].state = TASK_STOPED; _local_irq_restore(eflags); /* 等待0号任务清空 */ while(1){idle();}; }
// seg001:04D3 void __pascal far time_expired() { disable_keys = 1; set_hourglass_state(7); hourglass_sandflow = -1; play_sound(sound_36_out_of_time); // time over if (fade_in_1()) return; if (proc_cutscene_frame(2)) return; if (proc_cutscene_frame(100)) return; fade_out_1(); while (check_sound_playing()) { idle(); do_paused(); } }
int win32_windowed_app::run() { MSG msg = { 0 }; msg.message = WM_NULL; while (msg.message != WM_QUIT) { if (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) != 0) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } else { idle(); } } return msg.wParam; }
void suspend_power_down(void) { #ifdef NO_SUSPEND_POWER_DOWN ; #elif defined(SUSPEND_MODE_NOPOWERSAVE) ; #elif defined(SUSPEND_MODE_STANDBY) standby(); #elif defined(SUSPEND_MODE_IDLE) idle(); #else power_down(WDTO_15MS); #endif }
void NOD_Idle::onEnter( const BTInputParam &input ) { const BlackBoard &inputData = input.getRealData<BlackBoard>(); auto self = inputData.self; self->idle(); this->finish(); /* self->runAction(Sequence::create(DelayTime::create(1.0f), CallFunc::create([=]() { this->finish(); }), nullptr)); */ }
void MadsPlayer::nextFrame() { if (_madsVm->_currentTimer >= (_priorTimer + _ticksAmount)) { _priorTimer = _madsVm->_currentTimer; if (_moving) move(); else idle(); // Post update logic if (_moving) { ++_frameNum; if (_frameNum > _frameCount) _frameNum = 1; _forceRefresh = true; } else if (!_forceRefresh) { idle(); } // Final update update(); } }
void cpu_idle (void) { while (1) { while (!need_resched()) { void (*idle)(void); idle = pm_idle; if (!idle) idle = default_idle; idle(); } schedule_preempt_disabled(); } }
void DW1000Class::softReset() { byte pmscctrl0[LEN_PMSC_CTRL0]; readBytes(PMSC, PMSC_CTRL0_SUB, pmscctrl0, LEN_PMSC_CTRL0); pmscctrl0[0] = 0x01; writeBytes(PMSC, PMSC_CTRL0_SUB, pmscctrl0, LEN_PMSC_CTRL0); pmscctrl0[3] = 0x00; writeBytes(PMSC, PMSC_CTRL0_SUB, pmscctrl0, LEN_PMSC_CTRL0); delay(10); pmscctrl0[0] = 0x00; pmscctrl0[3] = 0xF0; writeBytes(PMSC, PMSC_CTRL0_SUB, pmscctrl0, LEN_PMSC_CTRL0); // force into idle mode idle(); }
int32_t Engine::run() { is_running_ = true; while(is_running_) { chapter_manager().current_chapter().frame_start(); is_running_ = window().update(); chapter_manager().current_chapter().frame_finish(); idle().execute(); timed().execute(); } return 0; }
bool SignalHandler::waitForEvent(pdvector<EventRecord> &events_to_handle) { assert(waitLock); signal_printf("%s[%d]: waitForEvent, events_to_handle(%d), idle_flag %d\n", FILE__, __LINE__, events_to_handle.size(), idle()); while (idle()) { // Our eventlocks are paired mutexes and condition variables; this // is actually _not_ what we want because we want to be able to // wait on different things but have the same global mutex. So we fake it // by carefully unlocking and relocking things. // We now wait until _we_ are signalled by the generator; so we grab // our signal lock, give up the global mutex lock, and then wait; after // we're signalled we take the global mutex before giving up our own // waitLock. waitingForWakeup_ = true; signal_printf("%s[%d]: acquiring waitLock lock...\n", FILE__, __LINE__); waitLock->_Lock(FILE__, __LINE__); signal_printf("%s[%d]: releasing global mutex...\n", FILE__, __LINE__); assert(eventlock->depth() == 1); eventlock->_Unlock(FILE__, __LINE__); signal_printf("%s[%d]: sleeping for activation\n", FILE__, __LINE__); waitLock->_WaitForSignal(FILE__, __LINE__); signal_printf("%s[%d]: woken, reacquiring global lock...\n", FILE__, __LINE__); eventlock->_Lock(FILE__, __LINE__); signal_printf("%s[%d]: woken, releasing waitLock...\n", FILE__, __LINE__); waitLock->_Unlock(FILE__, __LINE__); waitingForWakeup_ = false; } return true; }
/* * The idle thread. There's no useful work to be * done, so just try to conserve power and have a * low exit latency (ie sit in a loop waiting for * somebody to say that they'd like to reschedule) */ void cpu_idle (void) { /* endless idle loop with no priority at all */ while (1) { while (!need_resched()) { void (*idle)(void) = pm_idle; if (!idle) idle = default_idle; idle(); } schedule_preempt_disabled(); } }
// Modbus Master State Machine void modbus_update() { switch (state) { case IDLE: idle(); break; case WAITING_FOR_REPLY: waiting_for_reply(); break; case WAITING_FOR_TURNAROUND: waiting_for_turnaround(); break; } }
extern void USO_transform (void (*run) (void), USO_stack_t * stack, int stack_size) { USO_list_init (&interrupt_threads); USO_list_init (&system_threads); USO_list_init (&user_threads); USO_thread_init (&idle_thread, NULL, stack, stack_size, USO_IDLE, USO_FIFO, "idle"); USO_thread_in_init (&idle_thread, NULL); USO_thread_out_init (&idle_thread, NULL); USO_thread_work_set (&idle_thread, NULL); current_thread = &idle_thread; old_thread = &idle_thread; run (); idle (); }
void Plant::update(float delta) { if(m_hp > 0) { CCPoint direction = ccp(0, 0); if( findAim(direction) ) { attack(direction); } else { idle(); } } }
void AbstractDb::asyncQueryFinished(AsyncQueryRunner *runner) { // Extract everything from the runner SqlQueryPtr results = runner->getResults(); quint32 asyncId = runner->getAsyncId(); delete runner; if (handleResultInternally(asyncId, results)) return; emit asyncExecFinished(asyncId, results); if (isReadable() && isWritable()) emit idle(); }
uint8_t m0110_send(uint8_t data) { m0110_error = 0; request(); WAIT_MS(clock_lo, 250, 1); // keyboard may block long time for (uint8_t bit = 0x80; bit; bit >>= 1) { WAIT_US(clock_lo, 250, 3); if (data&bit) { data_hi(); } else { data_lo(); } WAIT_US(clock_hi, 200, 4); } _delay_us(100); // hold last bit for 80us idle(); return 1; ERROR: print("m0110_send err: "); phex(m0110_error); print("\n"); _delay_ms(500); idle(); return 0; }
void MyArduboy::beginNoLogo(void) { boot(); if (pressed(UP_BUTTON)) { sendLCDCommand(OLED_ALL_PIXELS_ON); setRGBled(255, 255, 255); power_timer0_disable(); while (true) { idle(); // infinite loop } } pTunes->initChannel(PIN_SPEAKER_1); pinMode(PIN_SPEAKER_2, OUTPUT); // trick myAudio.begin(); }
static inline int psdapl_recvlook_block(psdapl_con_info_t *ci, void **buf) { int len; while (1) { len = psdapl_recvlook(ci, buf); if (len >= 0) return len; if (len != -EAGAIN) { printf("receive returned an error : %s\n", strerror(-len)); exit(1); } idle(); } }
void main(void) { // initialize AD1836 start_AD1836(); // loop forever while(1) { idle(); // go asleep and wake up when external interrupt and ISR have been if (cNewSample) { cNewSample = 0; process_data(); } } }
void Role::start() { #if GAME_DEBUG_MODE <= DBG_SHOW_CHGSTATE CONLOG("ptr=%p Role::start()", this); #endif if (mAIManager) return; mAIManager = AIManager::create(); mAIManager->retain(); mAIManager->setHolder(this); mMovingState = MOVING_UNKNOW; idle(); schedule(schedule_selector(Role::updater)); }
ucci_comm_enum boot_line() { char line_str[LINE_INPUT_MAX_CHAR]; open_pipe(); while (!line_input(line_str)) { idle(); } if (strcmp(line_str, "ucci") == 0) { return UCCI_COMM_UCCI; } else { return UCCI_COMM_NONE; } }
void Player::nextFrame() { Scene &scene = _vm->_game->_scene; uint32 newTime = _priorTimer + _ticksAmount; if (scene._frameStartTime >= newTime) { _priorTimer = scene._frameStartTime; if (_moving) { move(); } else { idle(); } setFrame(); update(); } }
//角色根据属性立即更新 void MyCharacter::UpdateByProperty() { //更新hp显示 //统计hp百分比 s32 per=100*((float)property.HP/(float)property.MAX_HP); //设置血条进度 m_pgHealthBar->setProgress(per); if(property.HP<=0 || property.isDeath){ //只执行一次死亡倒地动作 OneTimeDie(); return; } m_charClothMgr->setPosition(property.pos); m_charClothMgr->setRotation(property.rot); if(property.currState==cRun){ isArrived=false; laststate=cRun; setRunAnimation(); }else if(property.currState== cIdle ){ laststate=cIdle; runstate=false; // printf("角色停止移动,state:%d\n",property.currState); property.currState=cRun; idle(true); }else if(property.currState== cReadyAttack ){ laststate=cReadyAttack; runstate=false; // printf("角色停止移动,state:%d\n",property.currState); readyAttack(false); }else if(property.currState== cAttack){ runstate=false; // printf("角色攻击,state:%d\n",property.currState); if(laststate==cAttack)return; m_charClothMgr->Animate(ANIMATION_SPEED,81,90,true); laststate=cAttack; } }
void run() { if(idle()) { return; } unsigned long new_time = millis(); unsigned long delta = new_time - last_time; last_time = new_time; // If it's a time command (8bx000 0xxx) if((cmds[cmd_at] & 0x78) == 0x00) { uint16_t *data = cmdArg(1, uint16_t); if((cmds[cmd_at] & 0x7f) == BRAKE) { for(uint8_t i = 0; i < 4; i++) { if(io::motor_positions[i] < -3) { io::forward(i + 1, 0x7f); } else if(io::motor_positions[i] > 3) { io::backward(i + 1, 0x7f); } else { io::brake(i + 1); } } } if(delta >= *data) { *data = 0; finish(true); } else { *data -= delta; } } else if((cmds[cmd_at] & 0x7f) == STRAIT || (cmds[cmd_at] & 0x7f) == ARC) { int16_t data = *cmdArg(1, int16_t); if(io::dist() >= abs(data)) { finish(true); } else { io::motorSet( data > 0 ? MOVE_RIGHT : MOVE_LEFT, (cmds[cmd_at] & 0x7f) == STRAIT ? io::adjustedMotorPowers(1, 1) : io::adjustedMotorPowers( *cmdArg(3, uint16_t), *cmdArg(5, uint16_t))); } } else if((cmds[cmd_at] & 0x7f) == SPIN) { int16_t data = *cmdArg(1, int16_t); if(io::rotDist() >= abs(data)) { finish(true); } } }
unsigned char ftDigital (unsigned short port) { unsigned char result = 0; #ifdef _WIN32 unsigned short status = port+1; int enabled = ftDisable && _disable(); #endif #ifdef SC12 unsigned short status = port; #endif int bit = 8; int data = triggerX|triggerY|loadIn; if (ftLoadOut) data |= loadOut; trace(8, ("digital %03x", port)); trace(32, (" >%02x", data)); _outp(port, data); idle(ftIdle); data |= clock; trace(32, (" >%02x", data)); _outp(port, data); while (bit-- > 0) { idle(ftIdle); result |= ((_inp(status) & busy) != 0) << bit; trace(16, (" <%02x", result)); data = triggerX|triggerY; if (ftLoadOut) data |= loadOut; trace(32, (" >%02x", data)); _outp(port, data); idle(ftIdle); data |= clock; trace(32, (" >%02x", data)); _outp(port, data); } trace(8, (" %02x\n", result)); #ifdef _WIN32 if (enabled) _enable(); #endif return result; }