예제 #1
0
BOOL CLCDOutput::AnyDeviceOfThisFamilyPresent(DWORD dwDeviceFamilyWanted, DWORD dwReserved1)
{
    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 FALSE;
        }
    }

    // Setup the device family to use next time
    lgLcdSetDeviceFamiliesToUse(m_hConnection, dwDeviceFamilyWanted, dwReserved1);

    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 FALSE;
        }

        // Go back to the previous device family we were using
        lgLcdSetDeviceFamiliesToUse(m_hConnection, m_dwDeviceFamiliesSupported, 
                                    m_dwDeviceFamiliesSupportedReserved1);

        return FALSE;
    }

    // Go back to what was being used
    lgLcdSetDeviceFamiliesToUse(m_hConnection, m_dwDeviceFamiliesSupported, 
                                m_dwDeviceFamiliesSupportedReserved1);

    return TRUE;
}
예제 #2
0
//************************************************************************
// Initializes the connection to the LCD
//************************************************************************
bool CLCDConnectionLogitech::Initialize(tstring strAppletName, bool bAutostart, bool bConfigDialog)
{

	m_strAppletName = strAppletName;
	// initialize the library
	if (lgLcdInit() != ERROR_SUCCESS)
		return false;

	memset(&m_connectContext, 0, sizeof(m_connectContext));
	m_connectContext.connection = LGLCD_INVALID_CONNECTION;

	m_connectContext.appFriendlyName = m_strAppletName.c_str();
	m_connectContext.isAutostartable = bAutostart;
	m_connectContext.isPersistent = bAutostart;
	m_connectContext.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_BW | LGLCD_APPLET_CAP_QVGA;
	m_connectContext.onNotify.notificationCallback = notificationCallback;
	m_connectContext.onNotify.notifyContext = (PVOID)this;

	if (bConfigDialog) {
		m_connectContext.onConfigure.configCallback = CLCDOutputManager::configDialogCallback;
	}
	else {
		m_connectContext.onConfigure.configCallback = NULL;
	}
	m_connectContext.onConfigure.configContext = NULL;

	lgLcdSetDeviceFamiliesToUse(m_connectContext.connection, LGLCD_DEVICE_FAMILY_ALL, NULL);

	return true;
}
예제 #3
0
void CLCDOutput::SetDeviceFamiliesSupported(DWORD dwDeviceFamiliesSupported, DWORD dwReserved1)
{
    m_dwDeviceFamiliesSupported = dwDeviceFamiliesSupported;
    m_dwDeviceFamiliesSupportedReserved1 = dwReserved1;

    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);
}
예제 #4
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);
}