/****f* LCD.SDK/AddNumberOfPages(INT.numberOfPages) * NAME * INT AddNumberOfPages(INT numberOfPages) -- Adds numberOfPages to * the total of pages you've created. * INPUTS * numberOfPages - Count of pages to add in. * RETURN VALUE * Current number of pages, after the pages are added. ****** */ INT CEzLcd::AddNumberOfPages(INT numberOfPages) { for (INT iCount=0; iCount<numberOfPages; iCount++) { AddNewPage(); } return GetPageCount(); }
/****f* LCD.SDK/Initialize(LPCTSTR.friendlyName,AppletSupportType.supportType,BOOL.isAutoStartable,BOOL.isPersistent,lgLcdConfigureContext*configContext,lgLcdSoftbuttonsChangedContext*softbuttonChangedContext) * NAME * HRESULT Initialize(LPCTSTR friendlyName, * AppletSupportType supportType, * BOOL isAutoStartable = FALSE, * BOOL isPersistent = FALSE, * lgLcdConfigureContext* configContext = NULL, * lgLcdNotificationContext* notificationContext = NULL, * lgLcdSoftbuttonsChangedContext* softbuttonChangedContext = NULL) * FUNCTION * Does necessary initialization. This method SHOULD ONLY be called if * the empty constructor is used: CEzLcd(). * INPUTS * friendlyName - friendly name of the applet/game. This name will be * displayed in the Logitech G-series LCD Manager. * supportType - What type of displays the applet supports. Options * are: * - LG_MONOCHROME_MODE_ONLY * - LG_COLOR_MODE_ONLY * - LG_DUAL_MODE * IsAutoStartable - Determines if the applet is to be started * automatically every time by the LCD manager software * (Part of G15 software package). * IsPersistent - Determines if the applet's friendlyName will remain * in the list of applets seen by the LCD manager * software after the applet terminates. * configContext - Pointer to the lgLcdConfigContext structure used * during callback into the applet. * softbuttonChangedContext - softbutton callback (if the user does * not want to use LCD SDK's native handler). * RETURN VALUE * S_OK if it can connect to the LCD Manager. * E_FAIL otherwise. ****** */ HRESULT CEzLcd::Initialize(LPCTSTR friendlyName, AppletSupportType supportType, BOOL isAutoStartable, BOOL isPersistent, lgLcdConfigureContext* configContext, lgLcdSoftbuttonsChangedContext* softbuttonChangedContext) { if ( (m_pageCountMono != 0) || (m_pageCountColor != 0) ) { // Maybe the user is calling the old constructor and calling InitYourself as well. // Alert him of the problem. If the old constructor is called, then InitYourself should // not be called. InitYourself should be called, when the empty parameter constructor is // called, CEzLcd() return E_FAIL; } LCDUI_tcscpy(m_friendlyName, friendlyName); m_initNeeded = TRUE; m_initSucceeded = FALSE; m_currentDeviceFamily = LGLCD_DEVICE_FAMILY_OTHER; m_preferredDeviceFamily = LGLCD_DEVICE_FAMILY_OTHER; m_configContext = configContext; // Keep the context structure pointer m_isPersistent = isPersistent; m_isAutoStartable = isAutoStartable; // No active page to start with m_activePageMono = m_activePageColor = NULL; m_currentPageNumberShownMono = m_currentPageNumberShownColor = 0; // Will now connect to the real library and see it the lgLcdInit() succeeds lgLcdConnectContextEx lgdConnectContextEx_; lgLcdConfigureContext lgdConfigureContext_; if (m_configContext != NULL) { lgdConfigureContext_.configCallback = m_configContext->configCallback; lgdConfigureContext_.configContext = m_configContext->configContext; } else { lgdConfigureContext_.configCallback = NULL; lgdConfigureContext_.configContext = NULL; } lgdConnectContextEx_.appFriendlyName = m_friendlyName; lgdConnectContextEx_.isPersistent = m_isPersistent; lgdConnectContextEx_.isAutostartable = m_isAutoStartable; lgdConnectContextEx_.onConfigure = lgdConfigureContext_; switch(supportType) { case LG_MONOCHROME_MODE_ONLY: lgdConnectContextEx_.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_BW; break; case LG_COLOR_MODE_ONLY: lgdConnectContextEx_.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_QVGA; break; case LG_DUAL_MODE: lgdConnectContextEx_.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_BW|LGLCD_APPLET_CAP_QVGA; break; default: break; } m_SupportType = supportType; lgdConnectContextEx_.dwReserved1 = NULL; lgdConnectContextEx_.onNotify.notificationCallback = NULL; lgdConnectContextEx_.onNotify.notifyContext = NULL; if( NULL == softbuttonChangedContext ) { m_SBContext.softbuttonsChangedCallback = OnButtonCB; m_SBContext.softbuttonsChangedContext = this; } else { m_SBContext.softbuttonsChangedCallback = softbuttonChangedContext->softbuttonsChangedCallback; m_SBContext.softbuttonsChangedContext = softbuttonChangedContext->softbuttonsChangedContext; } if (FALSE == m_connection.Initialize(lgdConnectContextEx_, &m_SBContext)) { // This means the LCD SDK's lgLcdInit failed, and therefore // we will not be able to ever connect to the LCD, even if // a G-series keyboard is actually connected. LCDUITRACE(_T("ERROR: LCD SDK initialization failed\n")); m_initSucceeded = FALSE; return E_FAIL; } else { m_initSucceeded = TRUE; } // Add the first page(s) for backwards compatibility if( m_SupportType == LG_COLOR_MODE_ONLY || m_SupportType == LG_DUAL_MODE ) { ModifyDisplay(LG_COLOR); AddNewPage(); ModifyControlsOnPage(0); ShowPage(0); } if( m_SupportType == LG_MONOCHROME_MODE_ONLY || m_SupportType == LG_DUAL_MODE ) { ModifyDisplay(LG_MONOCHROME); AddNewPage(); ModifyControlsOnPage(0); ShowPage(0); } m_initNeeded = FALSE; // Default mode is Monochrome return S_OK; }
/****f* EZ.LCD.Wrapper/CEzLcd::InitYourself * NAME * HRESULT CEzLcd::InitYourself(pFriendlyName, BOOL IsAutoStartable, * BOOL IsPersistent, lgLcdOnConfigureCB callbackFunction ,width , * height) * FUNCTION * Does necessary initialization. This method SHOULD ONLY be called if * the empty constructor is used: CEzLcd::CEzLcd() * INPUTS * pFriendlyName - friendly name of the applet/game. This name will be * displayed in the Logitech G-series LCD Manager. * IsAutoStartable - Determines if the applet is to be started * automatically every time by the LCD manager software * (Part of G15 software package) * IsPersistent - Determines if the applet's friendlyName will remain * in the list of applets seen by the LCD manager * software after the applet terminates * pConfigContext - Pointer to the lgLcdConfigContext structure used * during callback into the applet * width - width in pixels of the LCD. * height - height in pixels of the LCD. * RETURN VALUE * The method returns the S_OK if it can connect to the LCD Manager * library, or returns E_FAIL if it can not. ****** */ HRESULT CEzLcd::InitYourself(LPCTSTR pFriendlyName, BOOL bIsAutoStartable, BOOL bIsPersistent, lgLcdConfigureContext * pConfigContext, INT iWidth, INT iHeight) { if (m_iPageCount != 0) { // Maybe the user is calling the old constructor and calling InitYourself as well. // Alert him of the problem. If the old constructor is called, then InitYourself should // not be called. InitYourself should be called, when the empty parameter constructor is // called, CEzLcd::CEzLcd() return E_FAIL; } m_iLcdWidth = iWidth; m_iLcdHeight = iHeight; _tcscpy(m_chFriendlyName, pFriendlyName); m_bInitNeeded = TRUE; m_bInitSucceeded = FALSE; for (INT ii = 0; ii < NUMBER_SOFT_BUTTONS; ii++) { m_bButtonIsPressed[ii] = FALSE; m_bButtonWasPressed[ii] = FALSE; } m_pConfigContext = pConfigContext; // Keep the context structure pointer m_bIsPersistent = bIsPersistent; m_bIsAutoStartable = bIsAutoStartable; // No active page to start with m_pActivePage = NULL; // Add the first page for backwards compatibility AddNewPage(); ModifyControlsOnPage(0); // Will now connect to the real library and see it the lgLcdInit() succeeds lgLcdConnectContext lgdConnectContext_; lgLcdConfigureContext lgdConfigureContext_; if (m_pConfigContext != NULL) { lgdConfigureContext_.configCallback = m_pConfigContext->configCallback; lgdConfigureContext_.configContext = m_pConfigContext->configContext; } else { lgdConfigureContext_.configCallback = NULL; lgdConfigureContext_.configContext = NULL; } lgdConnectContext_.appFriendlyName = m_chFriendlyName; lgdConnectContext_.isPersistent = m_bIsPersistent; lgdConnectContext_.isAutostartable = m_bIsAutoStartable; lgdConnectContext_.onConfigure = lgdConfigureContext_; if (FAILED(m_output.Initialize(&lgdConnectContext_, FALSE))) { // This means the LCD SDK's lgLcdInit failed, and therefore // we will not be able to ever connect to the LCD, even if // a G-series keyboard is actually connected. m_bInitSucceeded = FALSE; return E_FAIL; } return S_OK; }