在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 如何編寫Windows CE.net的usb驅(qū)動程序(2)

            如何編寫Windows CE.net的usb驅(qū)動程序(2)

            作者: 時間:2012-05-02 來源:網(wǎng)絡(luò) 收藏

            m_pInterface->lpEndpoints[0].Descriptor.bmAttributes));

            returnFALSE;

            }

            DEBUGMSG(ZONE_INIT,(TEXT(USBMouse:EP0:MaxPacket:%u,Interval:%urn),

            m_pInterface->lpEndpoints[0].Descriptor.wMaxPacketSize,

            m_pInterface->lpEndpoints[0].Descriptor.bInterval));

            m_hInterruptPipe=(*m_lpUsbFuncs->lpOpenPipe)(m_hDevice,

            m_pInterface->lpEndpoints[0].Descriptor);

            if(m_hInterruptPipe==NULL){

            RETAILMSG(1,(TEXT(Mouse:Erroropeninginterruptpipern)));

            return(FALSE);

            }

            m_hEvent=CreateEvent(NULL,FALSE,FALSE,NULL);

            if(m_hEvent==NULL)

            {

            RETAILMSG(1,(TEXT(USBMouse:ErroronCreateEventforconnecteventrn)));

            return(FALSE);

            }

            //創(chuàng)建數(shù)據(jù)接受線程

            m_hThread=CreateThread(0,0,MouseThreadStub,this,0,NULL);

            if(m_hThread==NULL)

            {

            RETAILMSG(1,(TEXT(USBMouse:ErroronCreateThreadrn)));

            return(FALSE);

            }

            return(TRUE);

            }

            //從USB鼠標設(shè)備中讀出數(shù)據(jù),產(chǎn)生相應(yīng)的鼠標事件。

            BOOLCMouse::SubmitInterrupt()

            {

            if(m_hInterruptTransfer)

            (*m_lpUsbFuncs->lpCloseTransfer)(m_hInterruptTransfer);

            //從USB鼠標PIPE中讀數(shù)據(jù)

            m_hInterruptTransfer=(*m_lpUsbFuncs->lpIssueInterruptTransfer)

            (m_hInterruptPipe,MouseTransferCompleteStub,this,

            USB_IN_TRANSFER|USB_SHORT_TRANSFER_OK,//表示讀數(shù)據(jù)

            min(m_pInterface->lpEndpoints[0].Descriptor.wMaxPacketSize,

            sizeof(m_pbDataBuffer)),

            m_pbDataBuffer,

            NULL);

            if(m_hInterruptTransfer==NULL)

            {

            DEBUGMSG(ZONE_ERROR,(L!USBMouse:ErrorinIssueInterruptTransferrn));

            returnFALSE;

            }

            else

            {

            DEBUGMSG(ZONE_TRANSFER,(LUSBMouse::SubmitInterrupt,Transfer:0x%Xrn,

            m_hInterruptTransfer));

            }

            returnTRUE;

            }

            //處理鼠標中斷傳輸?shù)臄?shù)據(jù)

            BOOLCMouse::HandleInterrupt()

            {

            DWORDdwError;

            DWORDdwBytes;

            DWORDdwFlags=0;

            INTdx=(signedchar)m_pbDataBuffer[1];

            INTdy=(signedchar)m_pbDataBuffer[2];

            BOOLfButton1=m_pbDataBuffer[0]0x01?TRUE:FALSE;

            BOOLfButton2=m_pbDataBuffer[0]0x02?TRUE:FALSE;

            BOOLfButton3=m_pbDataBuffer[0]0x04?TRUE:FALSE;

            if(!(*m_lpUsbFuncs->lpGetTransferStatus)(m_hInterruptTransfer,dwBytes,dwError))

            {

            DEBUGMSG(ZONE_ERROR,(TEXT(!USBMouse:ErrorinGetTransferStatus(0x%X)rn),

            m_hInterruptTransfer));

            returnFALSE;

            }

            else

            {

            DEBUGMSG(ZONE_TRANSFER,(TEXT(USBMouse::HandleInterrupt,hTransfer0x%Xcomplete(%ubytes,Error:%X)rn),

            m_hInterruptTransfer,dwBytes,dwError));

            }

            if(!SubmitInterrupt())

            returnFALSE;

            if(dwError!=USB_NO_ERROR)

            {

            DEBUGMSG(ZONE_ERROR,(TEXT(!USBMouse:Error0x%Xininterrupttransferrn),dwError));

            returnTRUE;

            }

            if(dwBytes3)

            {

            DEBUGMSG(ZONE_ERROR,(TEXT(!USBMouse:Invalidbytecnt%ufrominterrupttransferrn),dwBytes));

            returnTRUE;

            }

            if(dx||dy)

            dwFlags|=MOUSEEVENTF_MOVE;

            if(fButton1!=m_fPrevButton1)

            {

            if(fButton1)

            dwFlags|=MOUSEEVENTF_LEFTDOWN;

            else

            dwFlags|=MOUSEEVENTF_LEFTUP;

            }

            if(fButton2!=m_fPrevButton2)

            {

            if(fButton2)

            dwFlags|=MOUSEEVENTF_RIGHTDOWN;

            else

            dwFlags|=MOUSEEVENTF_RIGHTUP;

            }

            if(fButton3!=m_fPrevButton3)

            {

            if(fButton3)

            dwFlags|=MOUSEEVENTF_MIDDLEDOWN;

            else

            dwFlags|=MOUSEEVENTF_MIDDLEUP;

            }

            m_fPrevButton1=fButton1;

            m_fPrevButton2=fButton2;

            m_fPrevButton3=fButton3;

            DEBUGMSG(ZONE_EVENTS,

            (TEXT(USBMouseevent:dx:%d,dy:%d,dwFlags:0x%X(B1:%u,B2:%u,B3:%u)rn),

            dx,dy,dwFlags,fButton1,fButton2,fButton3));

            //通知系統(tǒng)產(chǎn)生鼠標事件

            if(m_fReadyForMouseEvents)

            mouse_event(dwFlags,dx,dy,0,0);

            else

            m_fReadyForMouseEvents=IsAPIReady(SH_WMGR);

            returnTRUE;

            }

            DWORDCALLBACKCMouse::MouseTransferCompleteStub(LPVOIDlpvNotifyParameter)

            {

            CMouse*pMouse=(CMouse*)lpvNotifyParameter;

            return(pMouse->MouseTransferComplete());

            }

            //數(shù)據(jù)傳輸完畢回調(diào)函數(shù)

            DWORDCMouse::MouseTransferComplete()

            {

            if(m_hEvent)

            SetEvent(m_hEvent);

            return0;

            }

            ULONGCALLBACKCMouse::MouseThreadStub(PVOIDcontext)

            {

            CMouse*pMouse=(CMouse*)context;

            return(pMouse->MouseThread());

            }

            //USB鼠標線程

            DWORDCMouse::MouseThread()

            {

            DEBUGMSG(ZONE_INIT,(TEXT(USBMouse:Workerthreadstartedrn)));

            SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_HIGHEST);



            評論


            相關(guān)推薦

            技術(shù)專區(qū)

            關(guān)閉