⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 events.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
 *  void
 *****************************************************************************/
void ClearAllKeyHandler(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 keyCode = 0;
    U16 keyType = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRALLKEY_HDLR));

    for (keyCode = 0; keyCode < MAX_KEYS; keyCode++)
    {
        for (keyType = 0; keyType < MAX_KEY_TYPE; keyType++)
        {
            currKeyFuncPtrs[keyCode][keyType] = NULL;
        }
    }
    PowerAndEndKeyHandler();

    SetDefaultVolumeKeyHandlers();
}


/*****************************************************************************
 * FUNCTION
 *  ClearInputEventHandler
 * DESCRIPTION
 *  Clear input device event handlers
 *  
 *  This is used to clear input device event handlers
 * PARAMETERS
 *  device      [IN]        Type
 * RETURNS
 *  void
 *****************************************************************************/
void ClearInputEventHandler(U16 device)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (device & MMI_DEVICE_KEY)
    {
        ClearAllKeyHandler();
    }

#ifdef  __MMI_TOUCH_SCREEN__
	if ( device & MMI_DEVICE_PEN )
	{
		wgui_clear_pen_handlers();
	}
#endif
}


/*****************************************************************************
 * FUNCTION
 *  PowerAndEndKeyHandler
 * DESCRIPTION
 *  sets power key & end key handlers
 *  
 *  This is used to set power key & end key handlers
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
#if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
extern BOOL DirectMode;
extern void CallBackPowerOnAnimationCompleteWrapper(void);
#endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 

void PowerAndEndKeyHandler(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
   /**
    * The end key must not be registered to
    * Go to IDle screen in case any call exists on the
    * the phone. This is a temporary solution for fixing the
    * CM bugs
    */
    if (isInCall() && !GetWapCallPresent())
    {
#ifdef __MMI_VOIP__
        if (GetTotalCallCount() != 0) /* disconnect gsm call */
        {
            currKeyFuncPtrs[KEY_END][KEY_EVENT_DOWN] = HangupAllCalls;
        }
        else if (mmi_voip_app_total_call() != 0) /* disconnect voip call */
        {
            currKeyFuncPtrs[KEY_END][KEY_EVENT_DOWN] = mmi_voip_entry_ans_to_disconn_voip;
        }
#else
        currKeyFuncPtrs[KEY_END][KEY_EVENT_DOWN] = HangupAllCalls;
#endif
    }
    else
    {
        if (mmi_bootup_is_in_security_check() == MMI_FALSE)
        {
            /**
            * The end key should end all the existing calls
            *  and screen should be the last screen thru call menu.
            */
            #ifdef __MMI_EMAIL__
                if (mmi_email_util_get_stop_cause() == EMAIL_MODULE_ACTIVE_NOW)
                {
                    currKeyFuncPtrs[KEY_END][KEY_EVENT_DOWN] = mmi_email_main_goto_idle;
                }
                else if (!gSecuritySetupContext.PINBlocked)
            #else /* __MMI_EMAIL__ */ 
                if (!gSecuritySetupContext.PINBlocked)
            #endif /* __MMI_EMAIL__ */ 
                {
                    currKeyFuncPtrs[KEY_END][KEY_EVENT_DOWN] = DisplayIdleScreen;
                }
        }
    }

#if defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__)
    if (DirectMode)
    {
        currKeyFuncPtrs[KEY_END][KEY_EVENT_DOWN] = CallBackPowerOnAnimationCompleteWrapper;
    }
#endif /* defined(__DIRECT_ENTRY_FACTORY_MODE_ON_BOOTUP__) */ 

    if (!g_keylock_context.gKeyPadLockFlag)
    {
        mmi_frm_set_default_power_onoff_key();
    }
}


/*****************************************************************************
 * FUNCTION
 *  SetProtocolEventHandler
 * DESCRIPTION
 *  sets protocol event handler
 *  
 *  This is used to set protocol event handler
 * PARAMETERS
 *  funcPtr     [IN]        
 *  eventID     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void SetProtocolEventHandler(PsFuncPtr funcPtr, U16 eventID)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    static U16 maxUsedInHistory = 0;
    U16 count;
    S16 i, firstNotUsed;
    S16 pos;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(eventID != 0);
    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETPTO_HDLR, eventID, funcPtr, usedProtocolEvent,
               maxProtocolEvent));

    /* serach */
    pos = -1;
    firstNotUsed = -1;
    for (count = 0; count < maxProtocolEvent; count++)
    {
        if (protocolEventHandler[count].eventID == eventID)
        {
            pos = count;
            break;
        }
        /* BTW, find a non-used item */ ;
        if ((firstNotUsed == -1) && (protocolEventHandler[count].eventID == MMI_EVENT_INVALID))
        {
            firstNotUsed = count;
        }
    }

    if (pos != -1)
    {
        /* found */
        if (funcPtr != NULL)
        {
            /* just need to update */
            protocolEventHandler[pos].entryFuncPtr = funcPtr;
        }
        else
        {
            /* reset it */
            protocolEventHandler[pos].eventID = MMI_EVENT_INVALID;
            protocolEventHandler[pos].entryFuncPtr = NULL;
            usedProtocolEvent--;
        }
    }
    else
    {
        /* not found */
        if (funcPtr != NULL)
        {
            /* newly set */
            if (firstNotUsed != -1)
            {
                pos = firstNotUsed;
            }
            else
            {
                /* need to enlarge current searching list */
                pos = maxProtocolEvent;
                maxProtocolEvent++;
                MMI_ASSERT(maxProtocolEvent < MAX_PROTOCOL_EVENT);
            }
            usedProtocolEvent++;
            protocolEventHandler[pos].eventID = eventID;
            protocolEventHandler[pos].entryFuncPtr = funcPtr;
        }
        else
        {
            /* do nothing */
        }
    }

    /* recycle not-used items in the tail of list. It is for searching efficency */
    for (i = (maxProtocolEvent - 1); i >= 0; i--)
    {
        if (protocolEventHandler[i].eventID != MMI_EVENT_INVALID)
        {
            break;
        }
    }
    maxProtocolEvent = i + 1;

    /* record the max value for array size analysis */
    if (maxUsedInHistory < maxProtocolEvent)
    {
        PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "SetProtocolEventHandler old maxUsedInHistory = %d", maxUsedInHistory));
        maxUsedInHistory = maxProtocolEvent;
        PRINT_INFORMATION_2((MMI_TRACE_G1_FRM, "SetProtocolEventHandler maxUsedInHistory = %d", maxUsedInHistory));
    }

    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETPTO_HDLR, eventID, funcPtr, usedProtocolEvent,
               maxProtocolEvent));
}


/*****************************************************************************
 * FUNCTION
 *  ClearProtocolEventHandler
 * DESCRIPTION
 *  clears protocol event handler
 *  
 *  This is used to clear protocol event handler
 * PARAMETERS
 *  eventID     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void ClearProtocolEventHandler(U16 eventID)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRPTO_HDLR, eventID));
    SetProtocolEventHandler(NULL, eventID);
}


/*****************************************************************************
 * FUNCTION
 *  ClearAllProtocolEventHandler
 * DESCRIPTION
 *  clears all the protocol event handler
 *  
 *  This is used to clear all the protocol event handlers
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void ClearAllProtocolEventHandler(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 count = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRALLPTO_HDLR));

    for (count = 0; count < maxProtocolEvent; count++)
    {
        protocolEventHandler[count].eventID = 0;
        protocolEventHandler[count].entryFuncPtr = NULL;
    }
    usedProtocolEvent = 0;

}


/*****************************************************************************
 * FUNCTION
 *  SetEntryHandler
 * DESCRIPTION
 *  sets current screen entry handlers
 *  
 *  This is used to sets current screen entry handlers
 * PARAMETERS
 *  scrnID              [IN]        
 *  entryFuncPtr        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void SetEntryHandler(U16 scrnID, FuncPtr entryFuncPtr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETENTRY_HDLR, scrnID));
    currEntryFuncPtr = entryFuncPtr;
}


/*****************************************************************************
 * FUNCTION
 *  ClearEntryHandler
 * DESCRIPTION
 *  clears current screen entry handlers
 *  
 *  This is used to clears current screen e1ntry handlers
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void ClearEntryHandler(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE((MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRENTRY_HDLR));
    currEntryFuncPtr = NULL;

}


/*****************************************************************************
 * FUNCTION
 *  SetGenericExitHandler
 * DESCRIPTION
 *  Generic function to set exit screen handler.
 *  Store current screen id, exit function, and entry function.
 * PARAMETERS
 *  scrnID              [IN]        Screen ID
 *  exitFuncPtr         [IN]        Exit function pointer
 *  entryFuncPtr        [IN]        Entry function pointer
 * RETURNS
 *  void
 *****************************************************************************/
static void SetGenericExitHandler(U16 scrnID, FuncPtr exitFuncPtr, FuncPtr entryFuncPtr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MM

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -