Exemplo n.º 1
0
BOOL CLCDOutput::OpenByType(lgLcdOpenByTypeContext &OpenContext)
{
    //Close the old device if there is one
    Close();

    DWORD res = lgLcdOpenByType(&OpenContext);
    if (ERROR_SUCCESS != res)
    {
        if( res == ERROR_INVALID_PARAMETER )
        {
            LCDUITRACE( _T("Open failed: invalid parameter.\n") );
            return FALSE;
        }
        else if( res == ERROR_ALREADY_EXISTS )
        {
            LCDUITRACE( _T("Open failed: already exists.\n") );
            return FALSE;
        }
        return FALSE;
    }

    m_hDevice = OpenContext.device;
    m_dwButtonState = 0;

    // restores
    SetAsForeground(m_bSetAsForeground);

    m_OpenByTypeContext = OpenContext;

    OnOpenedDevice(m_hDevice);

    return TRUE;
}
Exemplo n.º 2
0
void CLCDOutput::EnumerateDevices()
{
    lgLcdDeviceDescEx descEx;

    if (LGLCD_INVALID_CONNECTION == m_hConnection)
    {
        if (ERROR_SUCCESS == lgLcdConnectEx(&m_lcdConnectCtxEx))
        {
            // make sure we don't work with a stale device handle
            m_hConnection = m_lcdConnectCtxEx.connection;
            m_hDevice = LGLCD_INVALID_CONNECTION;
        }
        else
        {
            return;
        }
    }

    // close the lcd device before we open up another
    if (LGLCD_INVALID_DEVICE != m_hDevice)
    {
        lgLcdClose(m_hDevice);
        m_hDevice = LGLCD_INVALID_DEVICE;

    }
    
    // Setup the device family to use next time
    lgLcdSetDeviceFamiliesToUse(m_hConnection, m_dwDeviceFamiliesSupported, m_dwDeviceFamiliesSupportedReserved1);
 
    ZeroMemory(&descEx, sizeof(lgLcdDeviceDescEx));
    DWORD res = ERROR_SUCCESS;
    
    res = lgLcdEnumerateEx(m_hConnection, 0, &descEx);
    if (ERROR_SUCCESS != res)
    {
        if(ERROR_NO_MORE_ITEMS != res)
        {
            // something happened. Let's close this.
            CloseAndDisconnect();
        }
        return;
    }
// ERROR_NO_MORE_ITEMS
    lgLcdOpenContext open_ctx;
    ZeroMemory(&open_ctx, sizeof(open_ctx));

    open_ctx.connection = m_hConnection;
    open_ctx.index = 0;
    res = lgLcdOpen(&open_ctx);
    if (ERROR_SUCCESS != res)
        return;
    m_hDevice = open_ctx.device;
    m_dwButtonState = 0;

    // restores
    SetAsForeground(m_bSetAsForeground);
}
Exemplo n.º 3
0
/* attach to an available lcd */
CMPC_Lcd::CMPC_Lcd(void)
{
	InitializeCriticalSection(&cs);
	hLCD_UpdateThread = NULL;

	// lcd init
	ZeroMemory(&m_ConnCtx, sizeof(m_ConnCtx));

	m_ConnCtx.appFriendlyName = _T(LCD_APP_NAME);
	m_ConnCtx.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_BW | LGLCD_APPLET_CAP_QVGA;
	m_ConnCtx.isAutostartable = FALSE;
	m_ConnCtx.isPersistent = FALSE;
	m_ConnCtx.onConfigure.configCallback = NULL;     // we don't have a configuration screen
	m_ConnCtx.onConfigure.configContext = NULL;
	m_ConnCtx.onNotify.notificationCallback = NULL;
	m_ConnCtx.onNotify.notifyContext = NULL;
	m_ConnCtx.connection = LGLCD_INVALID_CONNECTION; // the "connection" member will be returned upon return

	CAppSettings& s = AfxGetAppSettings();
	if (!s.fLCDSupport) {
		return;
	}

	if (FALSE == m_Connection.Initialize(m_ConnCtx)) {
		//_tperror(_T("Initialize"));
		return;
	}

	m_MonoOutput = m_Connection.MonoOutput();
	m_MonoOutput->ShowPage(&m_MonoPage);

	m_ColorOutput = m_Connection.ColorOutput();
	m_ColorOutput->ShowPage(&m_ColorPage);

	SetAsForeground(TRUE);

	m_Connection.Update();

	if (m_Connection.IsConnected()) {
		Thread_Loop = true;
		SetPlayState(PS_STOP);
		hLCD_UpdateThread = (HANDLE) _beginthread(LCD_UpdateThread, 512 /* stack */, (void*) this /* arg */);
	}
}