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

📄 mfw_kbd.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 4 页
字号:


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_KBD            |
| STATE   : code                        ROUTINE : sigDistribute      |
+--------------------------------------------------------------------+

  PURPOSE : distribute keyboard event

*/

static void sigDistribute (U32 map, U8 key)
{
    int res = 0;
    int fail=0;
	/*2003/12/16,talcon comment*/
    //char temp[100];
    if(doAlways)
        if(doAlways(map,(void*) -1))
            return;                     /* event consumed           */

    if(mfwSignallingMethod == 0)
    {
        if(mfwFocus)
            res = sigExec(mfwFocus,map,key);
        if(!res && mfwRoot)
            res = sigExec(mfwRoot,map,key);
    }
    else
    {
        MfwHdr *h = mfwFocus;

        if(!h)
        {
            //TRACE_EVENT("nofucus only mfwroot");
            h = mfwRoot;
        }
        if(h)
        {
            fail = sigExec(h,map,key);
            res=1;
           
            if((!fail)&&(map&KEY_MAKE))
            {
                //TRACE_EVENT("the win has't kbdcb");
                //winFocusShow(mfwParent(current_mfw_elem));
            }
        }
        if(!res && mfwRoot && h != mfwRoot)
            res = sigExec(mfwRoot,map,key);
    }

    if(doAlways)
        doAlways(map,(void*) res);

    return;
}

#ifdef DRVPCTMTRACE
void TraceHallVarvalue(void)
{
    /*ljq added for trace_pctm command 2003/1/8*/
    RivieraTrace_Chunhui("TraceHallVarvalue: drvpara.hallstatusflag=", drvpara.hallstatusflag);
    return;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_KBD            |
| STATE   : code                        ROUTINE : kbdSignal          |
+--------------------------------------------------------------------+

  PURPOSE : keyboard event (called by driver/PEI)

*/

#define MAX_CONSEC_KEYS 6   // Maximum number of keys which can be processed before
// allowing the protocol stack processing time


//glowing, 2003-12-18 replace the function that define in 
//mmisounds.c

int HallOnOff(void){
	drvpara.hallstatusflag = GetHallStatus( );
	return drvpara.hallstatusflag;
}
void kbdSignal (char make, char key)
{
    U32 map;
    UBYTE temp;
    USHORT numElem;

    int loopNo;
    int keyNo;

    //	if (key < 0 || key > KCD_MAX)
    //	return;
	PHK_TRACE_EVENT(("glowing: kbdSignal--enter key=%d", key));

#ifndef _INNOVATION_EMULATOR_
    if(key == KCD_F4)
    {   
    	/* filter hall noise */
		PHK_TRACE_EVENT(("glowing: kbdSignal--Hall Interrupt!!!!!!!!!"));
		
        if(HallInterruptHandler())
        {
            AI_UnmaskHall_IT( ); 
            return;
        }
	}

    if((key==KCD_ABC)&&(pwr_Status.charging_state==0))
    {
        if(ledblinkflag!=0)
            timStart(ledblink);
    }

    if(key == KCD_F4)
    {
		drvpara.hallstatusflag = GetHallStatus(); //glowing,2003-12-18
		PHK_TRACE_EVENT(("glowing: kbdSignal--hallstatusflag=%d",drvpara.hallstatusflag));

		
        if(drvpara.hallstatusflag ==1)
        {
        	/* go here that not a noise, so we can turn on LCD backlight */
	        MMIActionKeyPress_flip( ); //glowing, 2004-02-12, for just one backlight
#ifndef _INNOVATION_EMULATOR_
			main_lcd_pwrCtrl(1);	
            sub_lcd_pwrCtrl(0);
#endif
            r2d_refresh();  //ganchh 2002/12/25
            
			/* 2004/03/31 sunsj modify */
            LedLightnessAdjust(200); //glowing : 2004-2-26 add it

			PHK_TRACE_EVENT(("glowing: kbdSignal--before Backlight_ON"));
            Backlight_ON();
            //Bob added 01/23
            Green_Off();
			/* 2004/03/15 sunsj remove */
            //Red_Off();
            if(ledblinkflag!=0)
                timStop(ledblink);

			if( NotCharingMode == TRUE )
			{
				StartPlayByReason(HALLON, 0);
			}

			/*2003/12/20,talcon add*/
			idleHandleByLcdState(1);
			setOuterState(0x04,1,0);//2004-04-22 Sunny modify

			//2004.4.9 WYJ modify
			/* 2004/07/05 sunsj modify */
			#if 0	/* Robert.Chen modified, 2004-08-03, replace it before drawIdle */
			if( NotCharingMode == TRUE )
			{
				StartPlayByReason(HALLON, 0);
			}
			#endif
        }
        else
        {
#ifndef _INNOVATION_EMULATOR_      	

            main_lcd_pwrCtrl(0);
            sub_lcd_pwrCtrl(1);
#endif
			CloseMic();					// 修正关盖挂机有啸叫 2004.5.19 WYJ

            MMIActionKeyPress_flip();	/* 2004-04-17, Robert.Chen added */
            
            //LCD_OFF();  //glowing,2003-12-16 comment it
			MMI_TRACE_EVENT(("glowing: kbdSignal--before Backlight_Off"));
            
		    /* 2004/04/02 sunsj modify */
		    //LedLightnessAdjust(200);
		    Backlight_OFF();

            //Bob added for ledblink 01/23
#ifndef SEVEN_COLORS_LED
            /* 2004/04/10 sunsj modify */
            if( FlashSettingData.LedSwitch == 1 )
            {
            	LEDStart();  //glowing, 2004-2-26, add it
            }
#endif
			/*2003/12/20,talcon add*/
			idleHandleByLcdState(0);
			setOuterState(0x02,1,0);//2004-04-22 Sunny modify

			// 2004.4.16 WYJ add
			MC_StopVibra();
			
			//2004.4.9 WYJ modify
			StopPlayingMelody2();
			if( NotCharingMode == TRUE )
			{
				StartPlayByReason(HALLOFF, 0);
			}
        }
        //AI_UnmaskIT(2);
        AI_UnmaskHall_IT( ); 
    }
#else
	if(key == KCD_F4)
    {
	static int lcdcover = 0;
        if(lcdcover)//LCD ON
        {
  
			idleHandleByLcdState(1);
			setOuterState(0x04,1,0);//2004-03-23 Sunny modify
        }
        else
        {
			idleHandleByLcdState(0);
			setOuterState(0x02,1,0);//OUTERIDLESTATE_LCDOFF//2004-04-22 Sunny modify

        }
		lcdcover = 1- lcdcover;
      
    }
#endif //_INNOVATION_EMULATOR_    
    if((key==KCD_ABC)||(key==KCD_F4))    
    {    	
		/*2003/12/23,talcon add*/
		if (key==KCD_ABC)
		{
			//setChargeState(0x01,0);//2004-03-21 Sunny remove
		}/*end talcon add*/
        map = 1L << key;
        if(make)
        {
            map |= KEY_MAKE;
            curMap = map;
            curKey = key;   
        }
        else
        {
            map &= ~KEY_MAKE;
            curMap = map; //ES!!
            curKey = key; //ES!!
        }

        sigDistribute(map,key);
        /* 2004/07/09 sunsj add for forbidden hall off */
        if( key == KCD_F4 )
        {
            if( drvpara.hallstatusflag == 0 )
            {
                if( HallOffForbid == FALSE )
                {
                    if( FocuseIdlewin() == 0 )
                    {
                        MMI_TRACE_EVENT(("sunsj-----------return to idle"));
                        sigDistribute(map, KCD_HUP);
                        returntoidle(1);
                    }
                }
            }
        }
        while(kbd_getMakeAndKey(&make,&key) != -1);
        return;
    }
    
	
    
    if((kbd_processKeyInput()== QUEUE_EVERY_KEY) ||
       (kbd_processKeyInput()== QUEUE_N_KEYS))
        temp = dspl_Enable(0);

    loopNo = 0;
    keyNo = 0;

	while(kbd_getMakeAndKey(&make,&key) != -1)
	{
		if((!HallStatus()))  /* in order to send virtual charging key to mmi when halloff */
        {
			if(call_win_flag&&(key==KCD_VOLDOWN||key==KCD_VOLUP)&&IsHandsetPlugin())
			{
				/* adjust vol when halloff and handsetis plugin and press kcdvoldown kcdvolup */
			}
			/*2004/4/2, wangyan add the control of longkey when halloff */
			else if((key==KCD_VOLUP||key==KCD_F3))
			{
			}
			/*2004/4/2, wangyan add the control of longkey when halloff */
			else
			{
				while(kbd_getMakeAndKey(&make,&key) != -1)
				{
				}              //zy: halloff needn't action keys"	    
				nElements=0;
				if((kbd_processKeyInput()== QUEUE_EVERY_KEY) ||
						(kbd_processKeyInput()== QUEUE_N_KEYS))
					dspl_Enable(temp);//zy must use dspl_enable(temp) with couple

				return;//zy 11/25 lock all key when hall is closed
			}
		}
		
        still_processing_flag = 1;
        //TraceMMIValue("key in signal", key);
        if((key >= 0) && (key <= KCD_MAX))
        {
            loopNo++;
            keyNo++;

            map = 1L << key;

            if(make)
            {
                map |= KEY_MAKE;
                curMap = map;
                curKey = key;
                if((key != KCD_ABC)&&(key != KCD_F4))
                {
					if(key==KCD_HUP || key==KCD_RIGHT)	//MI18800000126
						StopPlayingMelody2();
					
                    if((key == KCD_MNUUP) ||(key == KCD_MNUDOWN)||(key == KCD_RIGHT)||(key == KCD_HUP)
                       || ((key != KCD_MNUUP)&&(key != KCD_MNUDOWN)&&(key != KCD_RIGHT)&&(key != KCD_HUP)
                           &&!(driverFlag&0x04)))
                    {
                        if(FlashEnvironmentData.EnviroProfile[FlashEnvironmentData.CurrentEnv].KeypadTone)  //xsf add 2002.09.16
                        {
                            //xsf add for not play keypad tone when start the phone before entered idle 2003.02.20 
                            if(animation_complete || ((!animation_complete) && (key != KCD_POWER))) //&& (key != KCD_F4)
                                StartPlayByReason(9,key);  //KEYPADTONE = 9
                        }
                    }

                    if(HallStatus() ||  (key!=KCD_VOLUP && key!=KCD_F3)  )/*2004/04/08,talcon add */
				MMIActionKeyPress();///zym added
                    timStart(&timLongH);
                    timAuto.time = valAuto;

                    /*NM, p007a*/
                    if(valAuto)
                        timStart(&timAutoH);
                    /*NM, p007a end*/
                }
            }
            else
            {

                map &= ~KEY_MAKE;
                curMap = map; //ES!!
                curKey = key; //ES!!
                timStop(&timLongH);

                /*NM, p007b*/
                if(valAuto)
                    timStop(&timAutoH);
                /*NM, p007b end*/
            }

            //Select when we update the display
            switch(kbd_processKeyInput())
            {

            case QUEUE_EVERY_KEY:
                sigDistribute(map,key);
                break;

            case PROCESS_EVERY_KEY:
                temp = dspl_Enable(0);
                sigDistribute(map,key);
                dspl_Enable(temp);
                break;

            case QUEUE_N_KEYS:
                if((loopNo %(NUM_QUEUE_KEYS*2))==0)
                {
                    kbd_setDisplayUpdateNeeded(1);
                    sigDistribute(map,key); 
                    dspl_Enable(temp); 
                    temp = dspl_Enable(0);
                    kbd_setDisplayUpdateNeeded(0);
                }
                else
                    sigDistribute(map,key);
                break;
            }
        }
#ifndef _INNOVATION_EMULATOR_
        if(keyNo == MAX_CONSEC_KEYS)
        {
            still_processing_flag = FALSE;
            break;
        }
#endif       

        still_processing_flag = FALSE;
    }

    numElem = mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id);
    TRACE_EVENT_P2("NDH >>> Kbd :- There are %d elements in the buffer (id : %d)" ,
                   numElem, mfw_kbd_kpress_buf_id);

#ifndef _INNOVATION_EMULATOR_
    if((keyNo == MAX_CONSEC_KEYS) && (numElem > 0))
    {
        sendKeyInd(12, 0, 0); // dummy values to trigger another keypress_ind
        /*
        ** This delay is required to slow down the BMI when no trace is being output in order
        ** to permit the Protocol Stack & other tasks to function correctly
        */
        vsi_t_sleep (VSI_CALLER  30); 
    }
#endif
    if((kbd_processKeyInput()== QUEUE_EVERY_KEY) ||
       (kbd_processKeyInput()== QUEUE_N_KEYS))
        dspl_Enable(temp);

    return;
}


/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_KBD            |
| STATE   : code                        ROUTINE : toLong             |
+--------------------------------------------------------------------+

  PURPOSE : long press timeout handler

*/

static int toLong (U32 t, void *h)
{
    curMap |= KEY_LONG;

    sigDistribute(curMap,curKey);

    return 0;
}

⌨️ 快捷键说明

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