コード例 #1
0
NvBool NvOdmMouseGetEventInfo(
    NvOdmMouseDeviceHandle hDevice,
    NvU32 *NumPayLoad,
    NvU8 *PayLoadBuf)
{
    NvError Status = NvSuccess;

    // Retrive the event info
    Status = NvEcGetEvent(hDevice->hEcEventRegister,
                          hDevice->pEvent,
                          sizeof(NvEcEvent));

    if (Status != NvSuccess)
        return NV_FALSE;

    /**
     * if compression is enabled, latch the first data byte whenever a full-size
     * packet is received; then insert the latched data whenever a compressed
     * packet is seen.
     */
    if (hDevice->CompressionEnabled && hDevice->pEvent->NumPayloadBytes == 3)
    {
        hDevice->CompressionState = hDevice->pEvent->Payload[0];
    }
    
    /**
     * fill in the payload and number of bytes
     */
    if (hDevice->CompressionEnabled && hDevice->pEvent->NumPayloadBytes == 2)
    {
        // compressed packet, so insert latched data at beginning
        *NumPayLoad = 3;
        PayLoadBuf[0] = hDevice->CompressionState;
        PayLoadBuf[1] = hDevice->pEvent->Payload[0];
        PayLoadBuf[2] = hDevice->pEvent->Payload[1];
    }
    else
    {
        *NumPayLoad = hDevice->pEvent->NumPayloadBytes;
        NvOdmOsMemcpy(PayLoadBuf, hDevice->pEvent->Payload, *NumPayLoad);
    }

    return NV_TRUE;
}
コード例 #2
0
/* Gets the actual scan code for a key press */
NvBool NvOdmKeyboardGetKeyData(NvU32 *pKeyScanCode, NvU8 *pScanCodeFlags, NvU32 Timeout)
{
    NvError NvStatus = NvError_Success;
    NvU32 OutCode, OutCodeBytes, i;
    NvU8 ScanCodeFlags;

    if (!pKeyScanCode || !pScanCodeFlags || s_KeyboardDeinit)
    {
        return NV_FALSE;
    }

    if (Timeout != 0)
    {
        /* Use the timeout value */
        if (!NvOdmOsSemaphoreWaitTimeout(s_hKbcKeyScanRecvSema, Timeout))
            return NV_FALSE; // timed out
    }
    else
    {
        /* wait till we receive a scan code from the EC */
        NvOdmOsSemaphoreWait(s_hKbcKeyScanRecvSema);
    }

    // stop scanning
    if (s_KeyboardDeinit)
        return NV_FALSE;

    if (s_hEcEventRegistration)
    {
        NvStatus = NvEcGetEvent(s_hEcEventRegistration, &KbdEvent, sizeof(NvEcEvent));
        if (NvStatus != NvError_Success)
        {
            NV_ASSERT(!"Could not receive scan code");
            return NV_FALSE;
        }
        if (KbdEvent.NumPayloadBytes == 0)
        {
            NV_ASSERT(!"Received keyboard event with no scan codes");
            return NV_FALSE;
        }

        // Pack scan code bytes from payload buffer into 32-bit dword
        OutCode = (NvU32)KbdEvent.Payload[0];
        OutCodeBytes = 1;
        ScanCodeFlags = 0;

        if (KbdEvent.NumPayloadBytes == 1)
            NVODM_PRINTF(("EC Payload = 0x%x", KbdEvent.Payload[0]));
        else
        {
            for (i = 0; i < KbdEvent.NumPayloadBytes; i++)
                NVODM_PRINTF(("EC Payload = 0x%x", KbdEvent.Payload[i]));
        }

        for (i = 1; i < KbdEvent.NumPayloadBytes; i++)
        {
            if (KbdEvent.Payload[i-1] == SC1_PREFIX_E0)
            {
                // Temporary clear break flag just to check for extended shifts.
                // If detected, remove the entire extended shift sequence, as
                // it has no effect on SC1-to-VK translation
                NvU8 sc = KbdEvent.Payload[i] & (~SC1_BREAK_MASK);
                if ((sc == SC1_LSHIFT) || (sc == SC1_RSHIFT))
                {
                    OutCode = OutCode >> 8;
                    OutCodeBytes--;
                    continue;
                }
                else if (KbdEvent.Payload[i] == SC1_SCROLL)
                {
                    // If extended ScrollLock = Ctrl+Break, detected store it,
                    // set both make/break flags, and abort buffer packing, as
                    // the following bytes are just the break part of sequence
                    OutCode = (OutCode << 8) | ((NvU32)KbdEvent.Payload[i]);
                    OutCodeBytes++;
                    ScanCodeFlags = NV_ODM_SCAN_CODE_FLAG_MAKE |
                                    NV_ODM_SCAN_CODE_FLAG_BREAK;
                    break;
                }
            }
コード例 #3
0
/* Gets the actual scan code for a key press */
NvBool NvOdmCirGetKeyData(NvU8 showlog, NvU32 *pKeyScanCode, NvU8 *pRePeat, NvU32 Timeout)
{
    NvError NvStatus = NvError_Success;
    NvU32 OutCode, i;
    NvU8 RepeatKey;
	
    if (!pKeyScanCode || !pRePeat || s_CirDeinit)
    {
        return NV_FALSE;
    }

    if (Timeout != 0)
    {
        /* Use the timeout value */
        if (!NvOdmOsSemaphoreWaitTimeout(s_hCirKeyScanRecvSema, Timeout))
            return NV_FALSE; // timed out
    }
    else
    {
        /* wait till we receive a scan code from the EC */
        NvOdmOsSemaphoreWait(s_hCirKeyScanRecvSema);
    }
	//NvOsDebugPrintf("$$$$$$$ In kernel  cir nvodm_cir.c !! get key data  \n");
    // stop scanning
    if (s_CirDeinit)
        return NV_FALSE;

    if (s_hEcEventRegistration)
    {
        NvStatus = NvEcGetEvent(s_hEcEventRegistration, &CirEvent, sizeof(NvEcEvent));
        if (NvStatus != NvError_Success)
        {
            NV_ASSERT(!"Could not receive scan code");
            return NV_FALSE;
        }
        if (CirEvent.NumPayloadBytes == 0)
        {
            NV_ASSERT(!"Received Cir event with no scan codes");
            return NV_FALSE;
        }

		if(showlog){
		for (i = 0; i < CirEvent.NumPayloadBytes; i++){
			printk(KERN_INFO "EC Payload[%d]=0x%x\n",i,CirEvent.Payload[i]);
		}
		}
		
		RepeatKey = 0x0;	/*default is new key input*/
		if(CirEvent.Payload[1] == NV_ODM_CIR_SCAN_CODE_REPET){
			RepeatKey = NV_ODM_CIR_SCAN_CODE_REPET;
		}
				
		OutCode = CirEvent.Payload[3]; /*Ir Command */
		if(showlog)
			printk(KERN_INFO "nvec_cir OUT code: 0x%x,RepeatKey =%x\n", OutCode,RepeatKey );

        *pRePeat = RepeatKey ;
        *pKeyScanCode = OutCode;
        return NV_TRUE;
    }

    return NV_FALSE;
}