void __ISR(_TIMER_1_VECTOR, IPL5AUTO) Timer1INTHandler(void) { int a; double perc; if(d1 == 25) { state = CheckButtons(); if(state_init[3] == 1) { ReadADC(&adc1,&adc2); perc = (double)(adc1)/1023.00; SetPWMDutyCycle(3,perc); } else { perc = 1.00; SetPWMDutyCycle(3,perc); } d1 = 0; } else d1++; if(d2 == 1000) { if(state_init[1] == 0 && state_init[2] == 0) { LED1 = 1; LED2 = 1; } else if(state_init[1] == 1 && state_init[2] == 0) { LED1 = !LED1; LED2 = 1; } else if(state_init[2] == 1 && state_init[1] == 0) { LED2 = !LED2; LED1 = 1; } else if(state_init[2] == 1 && state_init[1] == 1) { a = LED1; LED1 = !LED1; LED2 = !a; } d2 = 0; } else d2++; // Clear the interrupt flag IFS0bits.T1IF = 0; }
void DvtListSelector::removeAllData() { for(unsigned i=0;i<list_dest_box->count();i++) { list_source_box-> insertItem(list_dest_box->text(i)); } list_dest_box->clear(); list_source_box->sort(); CheckButtons(); }
void DvtListSelector::removeData() { if(list_dest_box->currentItem()>=0) { list_source_box-> insertItem(list_dest_box->currentText()); list_dest_box->removeItem(list_dest_box->currentItem()); list_source_box->sort(); list_dest_box->setCurrentItem(-1); CheckButtons(); } }
// -------------------------------------------------------------------------------- // void guImportFiles::OnAddFilesClicked( wxCommandEvent &event ) { wxFileDialog * FileDialog = new wxFileDialog( this, _( "Select files" ), wxGetHomeDir(), wxEmptyString, wxString( _( "Audio files" ) ) + wxT( "|*.mp3;*.ogg;*.oga;*.flac;*.mp4;*.m4a;*.m4b;*.m4p;*.aac;*.wma;*.asf;*.ape;*.wav;*.aif;*.wv;*.tta;*.mpc|" ) + wxString( _( "mp3 files" ) ) + wxT( " (*.mp3)|*.mp3|" ) + wxString( _( "ogg files" ) ) + wxT( " (*.ogg;*.oga)|*.ogg;*.oga|" ) + wxString( _( "flac files" ) ) + wxT( " (*.flac)|*.flac|" ) + wxString( _( "mp4 files" ) ) + wxT( " (*.mp4;*.m4a)|*.mp4;*.m4a;*.m4b;*.m4p;*.aac|" ) + wxString( _( "wma files" ) ) + wxT( " (*.wma;*.asf)|*.wma;*.asf|" ) + wxString( _( "ape files" ) ) + wxT( " (*.ape)|*.ape|" ) + wxString( _( "waf files" ) ) + wxT( " (*.wav)|*.wav|" ) + wxString( _( "aif files" ) ) + wxT( " (*.aif)|*.aif|" ) + wxString( _( "wv files" ) ) + wxT( " (*.wv)|*.wv|" ) + wxString( _( "tta files" ) ) + wxT( " (*.tta)|*.tta|" ) + wxString( _( "mpc files" ) ) + wxT( " (*.mpc)|*.mpc" ), wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_MULTIPLE|wxFD_PREVIEW ); if( FileDialog ) { if( FileDialog->ShowModal() == wxID_OK ) { wxArrayString NewFiles; FileDialog->GetPaths( NewFiles ); int Index; int Count = NewFiles.Count(); for( Index = 0; Index < Count; Index++ ) { wxString NewFile = NewFiles[ Index ]; //guLogMessage( wxT( "Openning file '%s'" ), NewFile.c_str() ); if( wxFileExists( NewFile ) && guIsValidAudioFile( NewFile.Lower() ) ) { guTrack * Track = new guTrack(); if( Track->ReadFromFile( NewFile ) ) { Track->m_Type = guTRACK_TYPE_NOTDB; m_Tracks->Add( Track ); m_FilesListBox->Append( NewFile.AfterLast( wxT( '/' ) ) ); } else { delete Track; } } } UpdateCounters(); CheckButtons(); } FileDialog->Destroy(); } }
//////////////////////////////////////////////////////////////////////////////////////// /// // /// static BOOL CALLBACK CheckUnhookableCallback(HWND hwnd, LPARAM lParam) // /// // //////////////////////////////////////////////////////////////////////////////////////// static BOOL CALLBACK CheckUnhookableCallback(HWND hwnd, LPARAM lParam) { TButtonList ButtonList; ButtonList.NumButtons=0; if ((GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE)) { if (EnumChildWindows((HWND)hwnd, EnumChildWindowCallback,(LPARAM)&ButtonList)) { CheckButtons(&ButtonList); } } return(TRUE); }
// -------------------------------------------------------------------------------- // void guImportFiles::OnDelFilesClicked( wxCommandEvent &event ) { wxArrayInt Selected; m_FilesListBox->GetSelections( Selected ); int Index; int Count = Selected.Count(); for( Index = 0; Index < Count; Index++ ) { m_FilesListBox->Delete( Selected[ Index ] ); m_Tracks->RemoveAt( Selected[ Index ] ); } UpdateCounters(); CheckButtons(); }
void main(void) { init_io(); // 初始化IO RX_Mode(); // 设置为接收模式 while(1) { CheckButtons(); // 按键扫描 sta = SPI_Read(STATUS); // 读状态寄存器 if(RX_DR) // 判断是否接受到数据 { SPI_Read_Buf(RD_RX_PLOAD, RX_BUF, TX_PLOAD_WIDTH); // 从RX FIFO读出数据 flag = 1; } SPI_RW_Reg(WRITE_REG + STATUS, sta); // 清除RX_DS中断标志 if(flag) // 接受完成 { flag = 0; // 清标志 LED = RX_BUF[0]; // 数据送到LED显示 delay_ms(250); delay_ms(250); LED = 0xff; // 关闭LED } } }
void Game::NormalGameLoop() { //check if the player's charcter is moving (We do not allow any movement on top of animation) if (!(player[PLAYER_ONE]->getAnimActiv())) { CheckResetAnimation(PLAYER_ONE); //check if there was previously an animation that has not been restored //check for finger down if (g_pInput->m_Touched && !g_pInput->m_PrevTouched) { if (CheckButtons()) { touchCounter = 0; CheckInputEvents(player[PLAYER_ONE]->getPrevMovement()); } if (player[PLAYER_ONE]->getPrevMovement() == 4) { MakeHadoken(false); } } //check for hold else if (g_pInput->m_Touched && g_pInput->m_PrevTouched) { if (CheckButtonsStillTouched()) { if (player[PLAYER_ONE]->getPrevMovement() == 4) { //resize square if (projectileLines[PLAYER_ONE].size() > 0) { ResizeLine(projectileLines[PLAYER_ONE].back(), PLAYER_ONE, projectiles[PLAYER_ONE].back()->m_Y); } } else if (touchCounter < DASH_LIMIT) { touchCounter++; } CheckInputEvents(player[PLAYER_ONE]->getPrevMovement()); } } //check for finger up else if (!g_pInput->m_Touched && g_pInput->m_PrevTouched) { FingerUp(); } //set the previous state to the current state //this is done explicitly as this was removed from Input->Update() for optimisation g_pInput->m_PrevTouched = g_pInput->m_Touched; } else if (player[PLAYER_ONE]->getAttacking()) //else you are punching or kicking check if the player two gets hit. :) { Collision(PLAYER_TWO, 20, pushBack); } if (!(player[PLAYER_TWO]->getAnimActiv())) { CheckResetAnimation(PLAYER_TWO); //This is where the code for AI goes. if (player[PLAYER_TWO]->getPrevMovement() == 4) { if (projectiles[PLAYER_TWO].size() == 0) { player[PLAYER_TWO]->setPrevMovement(-1); } } else { CheckAINextMove(); } } else if (player[PLAYER_TWO]->getAttacking()) { Collision(PLAYER_ONE, -20, -pushBack); } bool exploded = HadokenOnHadoken(); if (!exploded) { CheckProjectiles(PLAYER_ONE); CheckProjectiles(PLAYER_TWO); } }
void RDListSelector::sourceInsertItem(const QString &text,int index) { list_source_box->insertItem(text,index); list_source_box->sort(); CheckButtons(); }
void RDListSelector::destRemoveItem(int index) { list_dest_box->removeItem(index); CheckButtons(); }
void RDListSelector::sourceRemoveItem(int index) { list_source_box->removeItem(index); CheckButtons(); }
/*------------------------------------------------------------------------* * GINPUT Touch Driver Calibrator. * *------------------------------------------------------------------------*/ int main(void) { GSourceHandle gs; GEventMouse *pem; bool_t isFirstTime; bool_t isCalibrated; bool_t isTouch; bool_t isFinger; const char * isFingerText; const char * deviceText; GMouse * m; GMouseVMT * vmt; GMouseJitter * pjit; uint32_t calerr; gfxInit(); // Initialize the display // Get the display dimensions swidth = gdispGetWidth(); sheight = gdispGetHeight(); // Create our title font = gdispOpenFont("UI2"); gwinSetDefaultFont(font); bWidth = gdispGetStringWidth("Next", font); bHeight = gdispGetStringWidth("Prev", font); if (bHeight > bWidth) bWidth = bHeight; bWidth += 4; bWidth2 = gdispGetStringWidth("+", font)*2; bHeight = gdispGetStringWidth("-", font)*2; if (bHeight > bWidth2) bWidth2 = bHeight; bWidth2 += 4; bHeight = gdispGetFontMetric(font, fontHeight)*2+2; // Create our main display window { GWindowInit wi; gwinClearInit(&wi); wi.show = TRUE; wi.x = 0; wi.y = bHeight; wi.width = swidth; wi.height = sheight-bHeight; ghc = gwinConsoleCreate(&gc, &wi); } // Initialize the listener geventListenerInit(&gl); // Copy the current mouse's VMT so we can play with it. m = (GMouse *)gdriverGetInstance(GDRIVER_TYPE_MOUSE, 0); if (!m) gfxHalt("No mouse instance 0"); vmt = gfxAlloc(sizeof(GMouseVMT)); if (!vmt) gfxHalt("Could not allocate memory for mouse VMT"); memcpy(vmt, m->d.vmt, sizeof(GMouseVMT)); // Swap VMT's on the current mouse to our RAM copy m->d.vmt = (const GDriverVMT *)vmt; // Listen for events gs = ginputGetMouse(0); geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA); // Get initial display settings for buttons isFirstTime = TRUE; isCalibrated = (vmt->d.flags & GMOUSE_VFLG_CALIBRATE) ? FALSE : TRUE; calerr = 0; /* * Test: Device Type */ StepDeviceType: DrawHeader("1. Device Type", isCalibrated, isCalibrated && !isFirstTime, isCalibrated); // Get the type of device and the current mode isTouch = (vmt->d.flags & GMOUSE_VFLG_TOUCH) ? TRUE : FALSE; isFinger = (m->flags & GMOUSE_FLG_FINGERMODE) ? TRUE : FALSE; pjit = isFinger ? &vmt->finger_jitter : &vmt->pen_jitter; isFingerText = isFinger ? "finger" : "pen"; deviceText = isTouch ? isFingerText : "mouse"; gwinPrintf(ghc, "This is detected as a %s device\n\n", isTouch ? "TOUCH" : "MOUSE"); gwinPrintf(ghc, "It is currently in %s mode\n\n", isFinger ? "FINGER" : "PEN"); if (!isCalibrated) gwinPrintf(ghc, "Press and release your %s to move on to the next test.\n", deviceText); else { gwinPrintf(ghc, "Press + for pen or - for finger.\n"); if (isFirstTime) gwinPrintf(ghc, "Press Next to continue.\n"); else gwinPrintf(ghc, "Press Next or Back to continue.\n"); } while(1) { pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); if (isCalibrated) { switch (CheckButtons(pem)) { case BTN_NEXT: break; case BTN_PREV: if (!isFirstTime) goto StepDrawing; continue; case BTN_PLUS: m->flags &= ~GMOUSE_FLG_FINGERMODE; goto StepDeviceType; case BTN_MINUS: m->flags |= GMOUSE_FLG_FINGERMODE; goto StepDeviceType; default: continue; } break; } if ((pem->buttons & GMETA_MOUSE_UP)) break; } /* * Test: Mouse raw reading */ StepRawReading: DrawHeader("2. Raw Mouse Output", FALSE, FALSE, FALSE); if (isTouch) gwinPrintf(ghc, "Press and hold on the surface.\n\n"); else gwinPrintf(ghc, "Press and hold the mouse button.\n\n"); gwinPrintf(ghc, "The raw values coming from your mouse driver will display.\n\n"); gwinPrintf(ghc, "Make sure the x and y values change as you move.\n\n"); gwinPrintf(ghc, "Release your %s to move on to the next test.\n", deviceText); // Make sure we are in uncalibrated mode m->flags &= ~(GMOUSE_FLG_CALIBRATE|GMOUSE_FLG_CLIP); // For this test turn on ALL mouse movement events geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEUPMOVES|GLISTEN_MOUSEMETA|GLISTEN_MOUSENOFILTER); while(1) { // Always sleep a bit first to enable other events. We actually don't // mind missing events for this test. gfxSleepMilliseconds(100); pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); gwinPrintf(ghc, "%u, %u z=%u b=0x%04x\n", pem->x, pem->y, pem->z, pem->buttons & ~GINPUT_MISSED_MOUSE_EVENT); if ((pem->buttons & GMETA_MOUSE_UP)) break; } // Reset to calibrated condition if (isCalibrated) { m->flags |= GMOUSE_FLG_CLIP; if ((vmt->d.flags & GMOUSE_VFLG_CALIBRATE)) m->flags |= GMOUSE_FLG_CALIBRATE; } // Reset to just changed movements. geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA); /* * Test: Calibration */ StepCalibrate: DrawHeader("3. Calibration Jitter", isCalibrated, isCalibrated, isCalibrated); if ((vmt->d.flags & GMOUSE_VFLG_CALIBRATE)) { gwinPrintf(ghc, "You will be presented with a number of points to touch.\nPress them in turn.\n\n" "If the calibration repeatedly fails, increase the jitter for %s calibration and try again.\n\n", isFingerText); gwinPrintf(ghc, "Pressing the surface for longer gives more accurate results.\n\n"); if (calerr) gwinPrintf(ghc, "Last calibration error ^ 2 = %u\n", calerr); gwinPrintf(ghc, "Calibration jitter (%s) = %u\n", isFingerText, pjit->calibrate); if (isCalibrated) gwinPrintf(ghc, "Press + or - to adjust.\n"); } else { gwinPrintf(ghc, "This device does not need calibration.\n\n"); } if (isCalibrated) gwinPrintf(ghc, "Press Next or Back to continue.\n"); else gwinPrintf(ghc, "Press and release your %s to move on to start calibration.\n", deviceText); while(1) { pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); if (isCalibrated) { switch (CheckButtons(pem)) { case BTN_NEXT: break; case BTN_PREV: goto StepRawReading; case BTN_PLUS: gwinPrintf(ghc, "Calibration jitter (%s) = %u", isFingerText, ++pjit->calibrate); continue; case BTN_MINUS: gwinPrintf(ghc, "Calibration jitter (%s) = %u", isFingerText, --pjit->calibrate); continue; default: continue; } break; } if ((pem->buttons & GMETA_MOUSE_UP)) break; } // Calibrate if ((vmt->d.flags & GMOUSE_VFLG_CALIBRATE)) { calerr = ginputCalibrateMouse(0); if (calerr) goto StepCalibrate; isCalibrated = TRUE; } /* * Test: Mouse coords */ StepMouseCoords: DrawHeader("4. Show Mouse Coordinates", TRUE, TRUE, TRUE); if (isTouch) gwinPrintf(ghc, "Press and hold on the surface.\n\n"); else gwinPrintf(ghc, "Press and hold the mouse button.\n\n"); gwinPrintf(ghc, "Check the coordinates against where it should be on the screen.\n\n"); gwinPrintf(ghc, "X should be 0 to %u\nY should be 0 to %u\n\n", swidth-1, sheight-1); gwinPrintf(ghc, "Press + to retry using extremes or - for normal calibration.\n"); gwinPrintf(ghc, "Press Next or Back to continue.\n"); // For this test normal mouse movement events geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA); while(1) { // Always sleep a bit first to enable other events. We actually don't // mind missing events for this test. gfxSleepMilliseconds(100); pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); switch (CheckButtons(pem)) { case BTN_NEXT: break; case BTN_PREV: goto StepCalibrate; case BTN_PLUS: vmt->d.flags |= GMOUSE_VFLG_CAL_EXTREMES; goto StepCalibrate; case BTN_MINUS: vmt->d.flags &= ~GMOUSE_VFLG_CAL_EXTREMES; goto StepCalibrate; default: gwinPrintf(ghc, "%u, %u\n", pem->x, pem->y); continue; } break; } // Reset to just changed movements. geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA); /* * Test: Mouse movement jitter */ StepMovementJitter: DrawHeader("5. Movement Jitter", TRUE, TRUE, TRUE); if (isTouch) gwinPrintf(ghc, "Press firmly on the surface and move around as if to draw.\n\n"); else gwinPrintf(ghc, "Press and hold the mouse button and move around as if to draw.\n\n"); gwinPrintf(ghc, "Dots will display in this window. Ensure that when you stop moving your %s that " "new dots stop displaying.\nNew dots should only display when your %s is moving.\n\n" "Adjust %s movement jitter to the smallest value that this reliably works for.\n\n", deviceText, deviceText, isFingerText); gwinPrintf(ghc, "Movement jitter (%s) = %u\n", isFingerText, pjit->move); gwinPrintf(ghc, "Press + or - to adjust.\n"); gwinPrintf(ghc, "Press Next or Back to continue.\n\n"); while(1) { pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); switch (CheckButtons(pem)) { case BTN_NEXT: break; case BTN_PREV: goto StepMouseCoords; case BTN_PLUS: gwinPrintf(ghc, "Movement jitter (%s) = %u", isFingerText, ++pjit->move); continue; case BTN_MINUS: gwinPrintf(ghc, "Movement jitter (%s) = %u", isFingerText, --pjit->move); continue; default: if ((pem->buttons & GINPUT_MOUSE_BTN_LEFT)) gwinPrintf(ghc, "."); continue; } break; } /* * Test: Click Jitter */ StepClickJitter: gwinClear(ghc); gwinSetColor(ghc, Yellow); gwinPrintf(ghc, "\n6. Click Jitter\n\n"); gwinSetColor(ghc, White); if (isTouch) gwinPrintf(ghc, "Press and release the touch surface to \"click\".\nTry both short and long presses.\n"); else gwinPrintf(ghc, "Click the mouse with the left and right buttons.\n\n"); gwinPrintf(ghc, "A yellow dash is a left (or short) click.\n" "A red x is a right (or long) click.\n\n" "Adjust %s click jitter to the smallest value that this reliably works for.\n" "Note: moving your %s during a click cancels it.\n\n", isFingerText, deviceText); gwinPrintf(ghc, "Click jitter (%s) = %u\n", isFingerText, pjit->click); gwinPrintf(ghc, "Press + or - to adjust.\n"); gwinPrintf(ghc, "Press Next or Back to continue.\n\n"); while(1) { pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); switch (CheckButtons(pem)) { case BTN_NEXT: break; case BTN_PREV: goto StepMovementJitter; case BTN_PLUS: gwinPrintf(ghc, "Click jitter (%s) = %u", isFingerText, ++pjit->click); continue; case BTN_MINUS: gwinPrintf(ghc, "Click jitter (%s) = %u", isFingerText, --pjit->click); continue; default: if ((pem->buttons & GMETA_MOUSE_CLICK)) { gwinSetColor(ghc, Yellow); gwinPrintf(ghc, "-"); } if ((pem->buttons & GMETA_MOUSE_CXTCLICK)) { gwinSetColor(ghc, uRed); gwinPrintf(ghc, "x"); } continue; } break; } /* * Test: Polling frequency */ StepDrawing: gwinClear(ghc); gwinSetColor(ghc, Yellow); gwinPrintf(ghc, "\n7. Drawing\n\n"); gwinSetColor(ghc, White); gwinPrintf(ghc, "Press firmly on the surface (or press and hold the mouse button) and move around as if to draw.\n\n"); gwinPrintf(ghc, "A green line will follow your %s.\n\n", deviceText); gwinPrintf(ghc, "Pressing Next will start the tests again but with the option of changing pen/finger mode.\n\n"); gwinPrintf(ghc, "Press Next or Back to continue.\n\n"); while(1) { pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE); if (pem->y < bHeight && pem->x >= swidth-2*bWidth) { if ((pem->buttons & GMETA_MOUSE_UP)) { if (pem->x >= swidth-bWidth) break; goto StepClickJitter; } } gdispDrawPixel(pem->x, pem->y, uGreen); } // Can't let this really exit isFirstTime = FALSE; goto StepDeviceType; }
//////////////////////////////////////////////////////////////////////////////////////// /// // /// void LRESULT CALLBACK WndProc(HWND hWnd, UINT msg,WPARAM wParam, LPARAM lParam) // /// // //////////////////////////////////////////////////////////////////////////////////////// static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg==MSG_DISPLAY_HOOK) { if (lParam==HCBT_ACTIVATE) { TButtonList ButtonList; ButtonList.NumButtons=0; if ((FindWindow((HWND)wParam)==NULL) )//&& //(FindWindow(GetAncestor((HWND)wParam,GA_ROOTOWNER))==NULL)) { if (EnumChildWindows((HWND)wParam, EnumChildWindowCallback,(LPARAM)&ButtonList)) { if (CheckButtons(&ButtonList)) return(0); } #ifdef PRINTCAPTIONS char Text[512]; if (GetWindowText((HWND)wParam,Text,sizeof(Text))>0) { printf("Caption %s\n",Text); } #endif DWORD dwStyle; dwStyle=GetWindowLong((HWND)wParam,GWL_STYLE); if (((dwStyle & WS_SYSMENU)==WS_SYSMENU) && ((dwStyle & WS_CAPTION )==WS_CAPTION)) { if (SendCloseWindows) { printf("Sent WM_CLOSE\n"); PostMessage((HWND)wParam,WM_CLOSE,0,0); printf("Sent WM_QUIT\n"); PostMessage((HWND)wParam,WM_QUIT,0,0); } return(0); } } else { return DefWindowProc(hWnd, msg, wParam, lParam); } } else if (lParam==HCBT_CREATEWND) { } else if (lParam==HCBT_DESTROYWND) { TWindowDataBase *TmpWindow=FindWindow((HWND)wParam); if (TmpWindow) { RemoveWindow(TmpWindow); return DefWindowProc(hWnd, msg, wParam, lParam); } } return 0; } switch (msg) { case WM_TIMER : CheckUnhookable(); break; case WM_DESTROY : if ((wParam==0xDEAD) && (lParam==0xBEEF)) PostQuitMessage (0xDEADBEEF) ; break; default: return DefWindowProc(hWnd, msg, wParam, lParam); break; } return 0; }
int CDVDInputStreamNavigator::ProcessBlock(BYTE* dest_buffer, int* read) { if (!m_dvdnav) return -1; int result; int len; int iNavresult = NAVRESULT_NOP; // m_tempbuffer will be used for anything that isn't a normal data block uint8_t* buf = m_lastblock; iNavresult = -1; if(m_holdmode == HOLDMODE_HELD) return NAVRESULT_HOLD; try { // the main reading function if(m_holdmode == HOLDMODE_SKIP) { /* we where holding data, return the data held */ m_holdmode = HOLDMODE_DATA; result = DVDNAV_STATUS_OK; } else result = m_dll.dvdnav_get_next_cache_block(m_dvdnav, &buf, &m_lastevent, &len); } catch (...) { CLog::Log(LOGERROR, "CDVDInputStreamNavigator::ProcessBlock - exception thrown in dvdnav_get_next_cache_block."); // okey, we are probably holding a vm_lock here so leave it.. this could potentialy cause problems if we aren't holding it // but it's more likely that we do LeaveCriticalSection((LPCRITICAL_SECTION)&(m_dvdnav->vm_lock)); m_bEOF = true; return NAVRESULT_ERROR; } if (result == DVDNAV_STATUS_ERR) { CLog::Log(LOGERROR,"Error getting next block: %s\n", m_dll.dvdnav_err_to_string(m_dvdnav)); m_bEOF = true; return NAVRESULT_ERROR; } switch (m_lastevent) { case DVDNAV_BLOCK_OK: { // We have received a regular block of the currently playing MPEG stream. // buf contains the data and len its length (obviously!) (which is always 2048 bytes btw) m_holdmode = HOLDMODE_NONE; memcpy(dest_buffer, buf, len); *read = len; iNavresult = NAVRESULT_DATA; } break; case DVDNAV_NOP: // Nothing to do here. break; case DVDNAV_STILL_FRAME: { // We have reached a still frame. A real player application would wait // the amount of time specified by the still's length while still handling // user input to make menus and other interactive stills work. // A length of 0xff means an indefinite still which has to be skipped // indirectly by some user interaction. iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_STILL_FRAME); /* if user didn't care for action, just skip it */ if(iNavresult == NAVRESULT_NOP) SkipStill(); } break; case DVDNAV_WAIT: { // We have reached a point in DVD playback, where timing is critical. // Player application with internal fifos can introduce state // inconsistencies, because libdvdnav is always the fifo's length // ahead in the stream compared to what the application sees. // Such applications should wait until their fifos are empty // when they receive this type of event. if(m_holdmode == HOLDMODE_NONE) { CLog::Log(LOGDEBUG, " - DVDNAV_WAIT (HOLDING)"); m_holdmode = HOLDMODE_HELD; iNavresult = NAVRESULT_HOLD; } else iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_WAIT); /* if user didn't care for action, just skip it */ if(iNavresult == NAVRESULT_NOP) SkipWait(); } break; case DVDNAV_SPU_CLUT_CHANGE: // Player applications should pass the new colour lookup table to their // SPU decoder. The CLUT is given as 16 uint32_t's in the buffer. { iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_SPU_CLUT_CHANGE); } break; case DVDNAV_SPU_STREAM_CHANGE: // Player applications should inform their SPU decoder to switch channels { dvdnav_spu_stream_change_event_t* event = (dvdnav_spu_stream_change_event_t*)buf; //libdvdnav never sets logical, why.. don't know.. event->logical = GetActiveSubtitleStream(); if(event->logical<0 && GetSubTitleStreamCount()>0) { /* this will not take effect in this event */ CLog::Log(LOGINFO, "%s - none or invalid subtitle stream selected, defaulting to first", __FUNCTION__); SetActiveSubtitleStream(0); } m_bCheckButtons = true; iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_SPU_STREAM_CHANGE); } break; case DVDNAV_AUDIO_STREAM_CHANGE: // Player applications should inform their audio decoder to switch channels { //dvdnav_get_audio_logical_stream actually does the oposite to the docs.. //taking a audiostream as given on dvd, it gives the physical stream that //refers to in the mpeg file dvdnav_audio_stream_change_event_t* event = (dvdnav_audio_stream_change_event_t*)buf; //wroong... stupid docs.. //event->logical = dvdnav_get_audio_logical_stream(m_dvdnav, event->physical); //logical should actually be set to the (vm->state).AST_REG event->logical = GetActiveAudioStream(); if(event->logical<0) { /* this will not take effect in this event */ CLog::Log(LOGINFO, "%s - none or invalid audio stream selected, defaulting to first", __FUNCTION__); SetActiveAudioStream(0); } iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_AUDIO_STREAM_CHANGE); } break; case DVDNAV_HIGHLIGHT: { iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_HIGHLIGHT); } break; case DVDNAV_VTS_CHANGE: // Some status information like video aspect and video scale permissions do // not change inside a VTS. Therefore this event can be used to query such // information only when necessary and update the decoding/displaying // accordingly. { if(m_holdmode == HOLDMODE_NONE) { CLog::Log(LOGDEBUG, " - DVDNAV_VTS_CHANGE (HOLDING)"); m_holdmode = HOLDMODE_HELD; iNavresult = NAVRESULT_HOLD; } else iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_VTS_CHANGE); m_bInMenu = (0 == m_dll.dvdnav_is_domain_vts(m_dvdnav)); } break; case DVDNAV_CELL_CHANGE: { // Some status information like the current Title and Part numbers do not // change inside a cell. Therefore this event can be used to query such // information only when necessary and update the decoding/displaying // accordingly. // this may lead to a discontinuity, but it's also the end of the // vobunit, so make sure everything in demuxer is output if(m_holdmode == HOLDMODE_NONE) { CLog::Log(LOGDEBUG, "DVDNAV_CELL_CHANGE (HOLDING)"); m_holdmode = HOLDMODE_HELD; iNavresult = NAVRESULT_HOLD; break; } uint32_t pos, len; m_dll.dvdnav_current_title_info(m_dvdnav, &m_iTitle, &m_iPart); m_dll.dvdnav_get_number_of_titles(m_dvdnav, &m_iTitleCount); if(m_iTitle > 0) m_dll.dvdnav_get_number_of_parts(m_dvdnav, m_iTitle, &m_iPartCount); else m_iPartCount = 0; m_dll.dvdnav_get_position(m_dvdnav, &pos, &len); CLog::Log(LOGDEBUG, "%s - Cell change: Title %d, Chapter %d\n", __FUNCTION__, m_iTitle, m_iPart); CLog::Log(LOGDEBUG, "%s - At position %.0f%% inside the feature\n", __FUNCTION__, 100 * (double)pos / (double)len); //Get total segment time dvdnav_cell_change_event_t* cell_change_event = (dvdnav_cell_change_event_t*)buf; m_iCellStart = cell_change_event->cell_start; // store cell time as we need that for time later m_iTotalTime = (int) (cell_change_event->pgc_length / 90); m_icurrentGroupId = cell_change_event->pgN * 1000 + cell_change_event->cellN; iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_CELL_CHANGE); } break; case DVDNAV_NAV_PACKET: { // A NAV packet provides PTS discontinuity information, angle linking information and // button definitions for DVD menus. Angles are handled completely inside libdvdnav. // For the menus to work, the NAV packet information has to be passed to the overlay // engine of the player so that it knows the dimensions of the button areas. // Applications with fifos should not use these functions to retrieve NAV packets, // they should implement their own NAV handling, because the packet you get from these // functions will already be ahead in the stream which can cause state inconsistencies. // Applications with fifos should therefore pass the NAV packet through the fifo // and decoding pipeline just like any other data. // Calculate current time //unsigned int pos, len; //m_dll.dvdnav_get_position(m_dvdnav, &pos, &len); //m_iTime = (int)(((__int64)m_iTotalTime * pos) / len); pci_t* pci = m_dll.dvdnav_get_current_nav_pci(m_dvdnav); m_dll.dvdnav_get_current_nav_dsi(m_dvdnav); if(!pci) { iNavresult = NAVRESULT_NOP; break; } /* if we have any buttons or are not in vts domain we assume we are in meny */ m_bInMenu = pci->hli.hl_gi.hli_ss || (0 == m_dll.dvdnav_is_domain_vts(m_dvdnav)); /* check for any gap in the stream, this is likely a discontinuity */ __int64 gap = (__int64)pci->pci_gi.vobu_s_ptm - m_iVobUnitStop; if(gap) { /* make sure demuxer is flushed before we change any correction */ if(m_holdmode == HOLDMODE_NONE) { CLog::Log(LOGDEBUG, "DVDNAV_NAV_PACKET (HOLDING)"); m_holdmode = HOLDMODE_HELD; iNavresult = NAVRESULT_HOLD; break; } m_iVobUnitCorrection += gap; CLog::Log(LOGDEBUG, "DVDNAV_NAV_PACKET - DISCONTINUITY FROM:%"PRId64" TO:%"PRId64" DIFF:%"PRId64, (m_iVobUnitStop * 1000)/90, ((__int64)pci->pci_gi.vobu_s_ptm*1000)/90, (gap*1000)/90); } m_iVobUnitStart = pci->pci_gi.vobu_s_ptm; m_iVobUnitStop = pci->pci_gi.vobu_e_ptm; m_iTime = (int) ( m_dll.dvdnav_convert_time( &(pci->pci_gi.e_eltm) ) + m_iCellStart ) / 90; if (m_bCheckButtons) { CheckButtons(); m_bCheckButtons = false; } iNavresult = m_pDVDPlayer->OnDVDNavResult((void*)pci, DVDNAV_NAV_PACKET); } break; case DVDNAV_HOP_CHANNEL: // This event is issued whenever a non-seamless operation has been executed. // Applications with fifos should drop the fifos content to speed up responsiveness. { iNavresult = m_pDVDPlayer->OnDVDNavResult(NULL, DVDNAV_HOP_CHANNEL); } break; case DVDNAV_STOP: { // Playback should end here. // don't read any further, it could be libdvdnav had some problems reading // the disc. reading further results in a crash m_bEOF = true; m_pDVDPlayer->OnDVDNavResult(NULL, DVDNAV_STOP); iNavresult = NAVRESULT_ERROR; } break; default: { CLog::Log(LOGDEBUG,"CDVDInputStreamNavigator: Unknown event (%i)\n", m_lastevent); } break; } // check if libdvdnav gave us some other buffer to work with // probably not needed since function will check if buf // is part of the internal cache, but do it for good measure if( buf != m_lastblock ) m_dll.dvdnav_free_cache_block(m_dvdnav, buf); return iNavresult; }
void DvtListSelector::destInsertItem(const QString &text,int index) { list_dest_box->insertItem(text,index); list_dest_box->sort(); CheckButtons(); }
void Gamepad::Update() { XINPUT_STATE state; ZeroMemory(&state, sizeof(XINPUT_STATE)); if(XInputGetState(m_cID, &state) == ERROR_SUCCESS) { m_isConnected = true; CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_A); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_B); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_X); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_Y); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_LEFT); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_RIGHT); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_SHOULDER); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_SHOULDER); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_THUMB); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_THUMB); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_BACK); CheckButtons(state.Gamepad.wButtons, XINPUT_GAMEPAD_START); float normLX = max(-1, (float) state.Gamepad.sThumbLX / 32767); float normLY = max(-1, (float) state.Gamepad.sThumbLY / 32767); m_LeftStickX = (abs(normLX) < m_DeadzoneX ? 0 : (abs(normLX) - m_DeadzoneX) * (normLX / abs(normLX))); m_LeftStickY = (abs(normLY) < m_DeadzoneY ? 0 : (abs(normLY) - m_DeadzoneY) * (normLY / abs(normLY))); float normRX = max(-1, (float) state.Gamepad.sThumbRX / 32767); float normRY = max(-1, (float) state.Gamepad.sThumbRY / 32767); m_RightStickX = (abs(normRX) < m_DeadzoneX ? 0 : (abs(normRX) - m_DeadzoneX) * (normRX / abs(normRX))); m_RightStickY = (abs(normRY) < m_DeadzoneY ? 0 : (abs(normRY) - m_DeadzoneY) * (normRY / abs(normRY))); m_LeftTrigger = (float)state.Gamepad.bLeftTrigger / 255; m_RightTrigger = (float)state.Gamepad.bRightTrigger / 255; } else m_isConnected = false; }
void Pincer::PeriodicService() { //Let's check and update every time bool isStalled = IsStallDetected(); CheckButtons(); switch(controlMode){ case ClosingMode: PincerDebug = true; position = Moving; SetMotorOutput(closingSpeed); //printf("Closing, Stalled = %d\n", isStalled); if(IsClosedLimitSwitchActive() || isStalled){ position = isStalled ? StalledClosed : FullyClosed; SetMotorOutput(0); controlMode = OffMode; #ifdef PINCER_DEBUG // printf("Pincer: Was closing, now off(lim = %d, stalled = %d)\n", IsClosedLimitSwitchActive(), isStalled); #endif } break; case OpeningMode: PincerDebug = true; position = Moving; //printf("Opening, Stalled = %d\n", isStalled); SetMotorOutput(openingSpeed); if(IsOpenLimitSwitchActive() || isStalled){ position = isStalled ? StalledOpen : FullyOpen; SetMotorOutput(0); controlMode = OffMode; #ifdef PINCER_DEBUG // printf("Pincer: Was opening, now off(lim = %d, stalled = %d)\n", IsOpenLimitSwitchActive(), isStalled); #endif } break; case SeekingPresetMode: position = Moving; if(IsOpenLimitSwitchActive() || IsClosedLimitSwitchActive() || isStalled){ position = PositionError; SetMotorOutput(0); } else{ // This PI stuff is getting a bit complex and should probably be moved to a member function.. position = Moving; //Assume Moving float positionNow = magEncoder->GetVoltage(); float err = (PresetTargetPosition - positionNow); if(fabs(err) < AllowedPositionError){ SetMotorOutput(0); controlMode = OffMode; position = PresetPosition; } else{ static const float Kp = 1.0; static const float Ki = .25; static float i; float lim = 0.0; i += err; lim = 2.0f; if(i > lim){i = lim;} if(i < -lim){i = -lim;} float output = err*Kp + i * Ki; SetMotorOutput(output); } } break; case ManualMode: // Do nothing as buttons are directly controlling... break; case OffMode: default: PincerDebug = true; SetMotorOutput(0); } }