Example #1
0
void CLCDOutput::ReadButtons()
{
    if(IsOpened())
    {
        DWORD dwButtonState = 0;
        
        DWORD res = lgLcdReadSoftButtons(m_hDevice, &dwButtonState);
        if (ERROR_SUCCESS != res)
        {
            LCDUITRACE(_T("lgLcdReadSoftButtons failed: unplug?\n"));
            HandleErrorFromAPI(res);
        }
        
        if (m_dwButtonState == dwButtonState)
            return;
        
        // handle the buttons
        HandleButtonState(dwButtonState, LGLCDBUTTON_BUTTON0);
        HandleButtonState(dwButtonState, LGLCDBUTTON_BUTTON1);
        HandleButtonState(dwButtonState, LGLCDBUTTON_BUTTON2);
        HandleButtonState(dwButtonState, LGLCDBUTTON_BUTTON3);
        
        m_dwButtonState = dwButtonState;
    }
}
Example #2
0
BOOL CLCDOutput::OnDraw(void)
{
    DWORD dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);

    if ( (NULL == m_pActivePage) ||
        (LGLCD_INVALID_DEVICE == m_hDevice) ||
        (LGLCD_PRIORITY_IDLE_NO_SHOW == dwPriorityToUse) )
    {
        // don't submit the bitmap
        return TRUE;
    }

    // Render the active screen
    m_pGfx->BeginDraw();
    m_pGfx->ClearScreen();
    m_pActivePage->OnDraw(*m_pGfx);
    m_pGfx->EndDraw(); 

    // Get the active bitmap
    lgLcdBitmap* pBitmap = m_pGfx->GetLCDScreen();

    // Only submit if the bitmap needs to be updated
    // (If the priority or bitmap have changed)
    DWORD res = ERROR_SUCCESS;
    if (DoesBitmapNeedUpdate(pBitmap))
    {
        res = lgLcdUpdateBitmap(m_hDevice, &pBitmap->bmp_mono.hdr, dwPriorityToUse);
        HandleErrorFromAPI(res);
    }

    return (LGLCD_INVALID_DEVICE != m_hDevice);
}
Example #3
0
BOOL CLCDOutput::HasHardwareChanged(void)
{
    if(LGLCD_INVALID_DEVICE != m_hDevice)
    {
        // ping to see whether we're still alive
        DWORD dwButtonState = 0;
        
        DWORD res = lgLcdReadSoftButtons(m_hDevice, &dwButtonState);

        HandleErrorFromAPI(res);
    }

    // check for lcd devices
    if (LGLCD_INVALID_DEVICE == m_hDevice)
    {
        EnumerateDevices();
    }
    else
    {
        // we still have our device;
        return FALSE;
    }

    // we got a new device
    return LGLCD_INVALID_DEVICE != m_hDevice;
}
Example #4
0
HRESULT CLCDOutput::Draw()
{
    DWORD dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
    
    if ( (NULL == m_pActiveScreen)              ||
         (LGLCD_INVALID_DEVICE == m_hDevice)    ||
         (LGLCD_PRIORITY_IDLE_NO_SHOW == dwPriorityToUse) )
    {
        // don't submit the bitmap
        return S_OK;
    }

    // Render the active screen
    m_pActiveScreen->Draw();
    
    // Get the active bitmap
    lgLcdBitmap160x43x1* pScreen = m_pActiveScreen->GetLCDScreen();

    // Only submit if the bitmap needs to be updated
    // (If the priority or bitmap have changed)
    DWORD res = ERROR_SUCCESS;
    if (DoesBitmapNeedUpdate(pScreen))
    {
        res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
        HandleErrorFromAPI(res);
    }

    // read the soft buttons
    ReadButtons();

    return S_OK;
}
HRESULT CLCDOutput::Draw()
{
    DWORD dwPriorityToUse;
    
    if (m_pActiveScreen)
    {
        m_pActiveScreen->Draw();
        dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
    }
    else
    {
        dwPriorityToUse = LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW);
    }
    
    lgLcdBitmap160x43x1* pScreen = GetLCDScreen();
    if (pScreen && (LGLCD_INVALID_DEVICE != m_hDevice))
    {
        DWORD res = ERROR_SUCCESS;
        res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
        
        HandleErrorFromAPI(res);

        // read the soft buttons
        ReadButtons();
    }

    return S_OK;
}
void CLCDConnectionLogitech::OnNotificationCB(DWORD notificationCode, DWORD notifyParm1, DWORD, DWORD, DWORD) {
	CLgLCDDevice *device;

	switch (notificationCode) {
	case LGLCD_NOTIFICATION_DEVICE_ARRIVAL: {
		int *counter = notifyParm1 == LGLCD_DEVICE_QVGA ? &m_iNumQVGADevices : &m_iNumBWDevices;
		if (*counter == 0) {
			SIZE size;
			if (notifyParm1 == LGLCD_DEVICE_QVGA) {
				size.cx = 320;
				size.cy = 240;
				device = new CLgLCDDevice(notifyParm1, size, 7, 4);
			}
			else {
				size.cx = 160;
				size.cy = 43;
				device = new CLgLCDDevice(notifyParm1, size, 4, 1);
			}
			m_lcdDevices.push_back(device);
		}

		(*counter)++;
		break;
	}
	case LGLCD_NOTIFICATION_DEVICE_REMOVAL: {
		int *counter = notifyParm1 == LGLCD_DEVICE_QVGA ? &m_iNumQVGADevices : &m_iNumBWDevices;
		(*counter)--;
		if (*counter == 0) {
			std::vector<CLgLCDDevice*>::iterator i = m_lcdDevices.begin();
			for (; i != m_lcdDevices.end(); i++) {
				if ((*i)->GetIndex() == notifyParm1) {
					device = *i;

					if (device == m_pConnectedDevice) {
						HandleErrorFromAPI(ERROR_DEVICE_NOT_CONNECTED);
					}

					m_lcdDevices.erase(i);
					delete device;

					break;
				}
			}
		}
		break;
	}
	}
}
void CLCDConnectionLogitech::runDrawingThread() {
	m_hStopEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
	m_hDrawEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

	DWORD dwRes = 0;

	while (1) {
		HANDLE hArray[2] = { m_hStopEvent, m_hDrawEvent };
		dwRes = WaitForMultipleObjects(2, hArray, FALSE, INFINITE);
		if (dwRes == WAIT_OBJECT_0) {
			break;
		}
		else if (dwRes == WAIT_OBJECT_0 + 1) {
			DWORD rc;
			if (GetConnectionState() != CONNECTED) {
				continue;
			}
			// do a sync update if the applet is in the foreground, or every 500 ms
			// the delay is there because sync updates can take up to 33ms to fail
			if (m_dwForegroundCheck < GetTickCount())
			{
				m_dwForegroundCheck = GetTickCount() + 500;
				rc = lgLcdUpdateBitmap(m_hDevice, &m_lcdBitmap.hdr, LGLCD_SYNC_COMPLETE_WITHIN_FRAME(m_iPriority));
				if (rc == ERROR_ACCESS_DENIED)
				{
					rc = ERROR_SUCCESS;
					m_bIsForeground = false;
				}
				else if (rc == ERROR_SUCCESS)
					m_bIsForeground = true;
			}
			else
				rc = lgLcdUpdateBitmap(m_hDevice, &m_lcdBitmap.hdr, LGLCD_ASYNC_UPDATE(m_iPriority));

			if (rc != ERROR_SUCCESS) {
				HandleErrorFromAPI(rc);
			}
		}
	}
	CloseHandle(m_hStopEvent);
	CloseHandle(m_hDrawEvent);
}