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

📄 mfw_kbd.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 2 页
字号:
        }
        curElem = curElem->next;
    }

    return 0;
}


/*
+--------------------------------------------------------------------+
| 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;

    TRACE_EVENT("sigDistribute");

    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)
            h = mfwRoot;
        while (h)
        {
            if (res = sigExec(h,map,key))
                break;
            if (h == mfwRoot)
                break;
            h = mfwParent(mfwParent(h));
            if (h)
                h = ((MfwWin *)(h->data))->elems;
        }
        if (!res && mfwRoot && h != mfwRoot)
            res = sigExec(mfwRoot,map,key);
    }

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

    return;
}


/*
+--------------------------------------------------------------------+
| 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

void kbdSignal (char make, char key)
{
	U32 map;
	UBYTE temp ;
	USHORT numElem;

	int loopNo;
	int keyNo;


	if ((kbd_processKeyInput()== QUEUE_EVERY_KEY) ||
	     (kbd_processKeyInput()== QUEUE_N_KEYS))		
		temp = dspl_Enable(0);

	mme_backlightEvent(BL_KEY_PRESS);

	loopNo = 0;
	keyNo = 0;

	while (kbd_getMakeAndKey(&make,&key) != -1)
	{
		still_processing_flag = 1;

		if ((key >= 0) && (key <= KCD_MAX))
		{
			loopNo++;
			keyNo++;
			
			map = 1L << key;

			if (make)
			{
				map |= KEY_MAKE;
				curMap = map;
				curKey = key;
				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);
				
				if (valAuto)
					timStop(&timAutoH);
			}

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

		if (keyNo == MAX_CONSEC_KEYS)
		{
			still_processing_flag = FALSE;
			break;
		}

		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);
	
	if ((keyNo == MAX_CONSEC_KEYS) && (numElem > 0))
	{
		sendKeyInd(0, 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); 
	}

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


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

  PURPOSE : auto repeat timeout handler

*/

static int toAuto (U32 t, void *h)
{
    curMap |= KEY_AUTO;
    sigDistribute(curMap,curKey);
    timAuto.time = valRepeat;
    /* NM p007c*/
    if (valRepeat)
   		timStart(&timAutoH);
	/* NM p007c end*/
    return 0;
}


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

  PURPOSE : handle mfw windows command

*/

static int kbdCommand (U32 cmd, void *h)
{
    switch (cmd)
    {
        case MfwCmdDelete:              /* delete me                */
            if (!h)
                return 0;
            kbdDelete(h);
            return 1;
        default:
            break;
    }

    return 0;
}


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

  PURPOSE : places 'make' (key up/down) and key index into a queue

*/

int kbd_putMakeAndKey( char make, char key)
{
	keyPressDetails localKP;
	SHORT retVal;

	localKP.make = make;
	localKP.key = key;

	retVal = mfw_cbuf_put(mfw_kbd_kpress_buf_id, &localKP);

	if (retVal < 0)
		TRACE_EVENT_P1("ERROR : mfw_cbuf_put failed with error value %d", retVal);

	return (retVal);
}

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

  PURPOSE : reads 'make' (key up/down) and key index into a queue
		Return	+ve number - keys left in buffer
				 0 - no keys left - last key press returned
				-1 - no keys and none in buffer
*/

int kbd_getMakeAndKey( char* make, char* key)
{
	keyPressDetails localKP;
	SHORT retVal;

	retVal = mfw_cbuf_get(mfw_kbd_kpress_buf_id, &localKP);

	if (retVal < 0)
	{
		*key = 0x7F;
		*make = 0;
		return (-1);
	}

	*make = !(localKP.make);
	*key =   drvGetKeyIndex(localKP.key);
	return (mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id));
}

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

  PURPOSE : returns number of elements in queue

*/
int kbd_getNumElements(void)
{
	return ((int)mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id));
}

int kbd_stillProcessingKeys(void)
{
	return (still_processing_flag);
}

int mfwKey_skipDisplay( void )
{
	if ((mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id) > 2) && (still_processing_flag == 1))
		return (TRUE);
	else
		return (FALSE);
}

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

  PURPOSE : returns TRUE if we need to update the display

*/
int displayUpdateNeeded; //used for output every 'n' key presses
int kbd_displayUpdateNeeded(void)
{	
	if (kbd_processKeyInput()==PROCESS_EVERY_KEY)
		return (TRUE);//Processing each key press - always update screen
	else if (displayUpdateNeeded==0)
		return (TRUE);//need to update the display (1 in 6 output) 
	else if (mfw_cbuf_num_elements(mfw_kbd_kpress_buf_id) > 1) 
		return (FALSE);//keys in queue - do not update
	else
		return (TRUE);//only 1 key up/down in queue - update display
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417)        MODULE  : MFW_KBD            |
| STATE   : code                        ROUTINE : kbd_setDisplayUpdateNeeded   |
+--------------------------------------------------------------------+

  PURPOSE : sets/clears the flag indicating we need to update the display

*/
void kbd_setDisplayUpdateNeeded(int set)
{
	displayUpdateNeeded = set;
}
	
void mfw_TRACE_EVENT(char* str)
{
/*	TRACE_EVENT(str);*/
	TRACE_FUNCTION(str);
}
void mfw_TRACE_EVENT_data(char* str,int i)
{
	char opStr[100];
	sprintf(opStr,"%s : %d",str,i);
	mfw_TRACE_EVENT(opStr);
}

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

  PURPOSE : indicates if the software should process each keypad input individually 
  			(TRUE) or if it should process keypad inputs one at a time (FALSE) 

*/
int kbd_processKeyInput(void)
{
	return (QUEUE_EVERY_KEY);//We buffer multiple key inputs

}







⌨️ 快捷键说明

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