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

📄 keymap.cpp

📁 MTK手机平台的MMI部分的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyHash[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyHash[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyHash[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyHash[3])))
	{
		keyCode = KEY_POUND;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyMenu[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyMenu[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyMenu[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyMenu[3])))
	{
		keyCode = KEY_QUICK_ACS;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyClear[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyClear[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyClear[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyClear[3])))
	{
		keyCode = KEY_CLEAR;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + VolumeUp[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + VolumeUp[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + VolumeUp[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + VolumeUp[3])))
	{
		keyCode = KEY_VOL_UP;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + VolumeDown[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + VolumeDown[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + VolumeDown[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + VolumeDown[3])))
	{
		keyCode = KEY_VOL_DOWN;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyEnter[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyEnter[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyEnter[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyEnter[3])))
	{
		keyCode = KEY_ENTER;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyReserved1[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyReserved1[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyReserved1[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyReserved1[3])))
	{
		keyCode = KEY_EXTRA_1;
	}
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyReserved2[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyReserved2[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyReserved2[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyReserved2[3])))
	{
		keyCode = KEY_EXTRA_2;
	}


	/* PRINT_INFORMATION(("KEY CODE returned from key map = %d\n",keyCode));*/
	return keyCode;
} /* end of GetKeyCode */


/*****************************************************************************
* FUNCTION
*	KillWindowObject
* DESCRIPTION
*	Distroy the window
*
* PARAMETERS
*  nil
* RETURNS
*	void
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
extern "C"{
	void KillWindowObject(void)
	{
		/*----------------------------------------------------------------*/
		/* Local Variables                                                */
		/*----------------------------------------------------------------*/

		/*----------------------------------------------------------------*/
		/* Code Body                                                      */
		/*----------------------------------------------------------------*/
		if(isShutDownSystem == true)
		{
			isShutDownSystem = false;
			PostMessage(hWnd, WM_DESTROY, 0, 0);
		}
	} /* end of KillWindowObject */
}


/*****************************************************************************
* FUNCTION
*	FeedBackFeelingKeyInit
* DESCRIPTION
*	initial the feedback feeling keypad
*
* PARAMETERS
*  hWnd				IN		HWND
*	hInstance		IN		HINSTANCE
*	main_hbitmap	IN		HBITMAP
* RETURNS
*	void
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
void FeedBackFeelingKeyInit(HWND hWnd, HINSTANCE hInstance, HBITMAP main_hbitmap)
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	HWND			hDlg;
	RECT			dlg_rect, wnd_rect, clint_rect;

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	device.hwnd = hWnd;
	hDlg = GetDialogHandle();

	GetWindowRect(hWnd, &wnd_rect);
	GetWindowRect(hDlg, &dlg_rect);
	GetClientRect(hWnd, &clint_rect);
	
	/* reset window size */
	SetWindowPos(hWnd, 0, 0, 0, device.window_width, device.window_height+(wnd_rect.bottom-wnd_rect.top-clint_rect.bottom), SWP_NOMOVE | SWP_NOZORDER);
	MoveWindow(hDlg, wnd_rect.right, clint_rect.top, dlg_rect.right - dlg_rect.left, wnd_rect.bottom - wnd_rect.top, TRUE);

	/* key 1 */
	device.key_location[KEY_1].left		= KeyOne[0];
	device.key_location[KEY_1].top		= KeyOne[1];
	device.key_location[KEY_1].right		= KeyOne[2];
	device.key_location[KEY_1].bottom	= KeyOne[3];
	/* key 2 */
	device.key_location[KEY_2].left		= KeyTwo[0];
	device.key_location[KEY_2].top		= KeyTwo[1];
	device.key_location[KEY_2].right		= KeyTwo[2];
	device.key_location[KEY_2].bottom	= KeyTwo[3];
	/* key 3 */
	device.key_location[KEY_3].left		= KeyThree[0];
	device.key_location[KEY_3].top		= KeyThree[1];
	device.key_location[KEY_3].right		= KeyThree[2];
	device.key_location[KEY_3].bottom	= KeyThree[3];
	/* key 4 */
	device.key_location[KEY_4].left		= KeyFour[0];
	device.key_location[KEY_4].top		= KeyFour[1];
	device.key_location[KEY_4].right		= KeyFour[2];
	device.key_location[KEY_4].bottom	= KeyFour[3];
	/* key 5 */
	device.key_location[KEY_5].left		= KeyFive[0];
	device.key_location[KEY_5].top		= KeyFive[1];
	device.key_location[KEY_5].right		= KeyFive[2];
	device.key_location[KEY_5].bottom	= KeyFive[3];
	/* key 6 */
	device.key_location[KEY_6].left		= KeySix[0];
	device.key_location[KEY_6].top		= KeySix[1];
	device.key_location[KEY_6].right		= KeySix[2];
	device.key_location[KEY_6].bottom	= KeySix[3];
	/* key 7 */
	device.key_location[KEY_7].left		= KeySeven[0];
	device.key_location[KEY_7].top		= KeySeven[1];
	device.key_location[KEY_7].right		= KeySeven[2];
	device.key_location[KEY_7].bottom	= KeySeven[3];
	/* key 8 */
	device.key_location[KEY_8].left		= KeyEight[0];
	device.key_location[KEY_8].top		= KeyEight[1];
	device.key_location[KEY_8].right		= KeyEight[2];
	device.key_location[KEY_8].bottom	= KeyEight[3];
	/* key 9 */
	device.key_location[KEY_9].left		= KeyNine[0];
	device.key_location[KEY_9].top		= KeyNine[1];
	device.key_location[KEY_9].right		= KeyNine[2];
	device.key_location[KEY_9].bottom	= KeyNine[3];
	/* key 0 */
	device.key_location[KEY_0].left		= KeyZero[0];
	device.key_location[KEY_0].top		= KeyZero[1];
	device.key_location[KEY_0].right		= KeyZero[2];
	device.key_location[KEY_0].bottom	= KeyZero[3];
	/* key * */
	device.key_location[KEY_STAR].left	= KeyStar[0];
	device.key_location[KEY_STAR].top	= KeyStar[1];
	device.key_location[KEY_STAR].right	= KeyStar[2];
	device.key_location[KEY_STAR].bottom= KeyStar[3];
	/* key hash */
	device.key_location[KEY_POUND].left		= KeyHash[0];
	device.key_location[KEY_POUND].top		= KeyHash[1];
	device.key_location[KEY_POUND].right	= KeyHash[2];
	device.key_location[KEY_POUND].bottom	= KeyHash[3];
	/* key soft 1 */
	device.key_location[KEY_LSK].left	= Leftsoftkey[0];
	device.key_location[KEY_LSK].top		= Leftsoftkey[1];
	device.key_location[KEY_LSK].right	= Leftsoftkey[2];
	device.key_location[KEY_LSK].bottom	= Leftsoftkey[3];
	/* key soft 2 */
	device.key_location[KEY_RSK].left	= Rightsoftkey[0];
	device.key_location[KEY_RSK].top		= Rightsoftkey[1];
	device.key_location[KEY_RSK].right	= Rightsoftkey[2];
	device.key_location[KEY_RSK].bottom	= Rightsoftkey[3];
	/* key ok, send */
	device.key_location[KEY_SEND].left	= KeyCall[0];
	device.key_location[KEY_SEND].top	= KeyCall[1];
	device.key_location[KEY_SEND].right	= KeyCall[2];
	device.key_location[KEY_SEND].bottom= KeyCall[3];
	/* key cancel, end */
	device.key_location[KEY_END].left	= KeyEnd[0];
	device.key_location[KEY_END].top		= KeyEnd[1];
	device.key_location[KEY_END].right	= KeyEnd[2];
	device.key_location[KEY_END].bottom	= KeyEnd[3];
	/* key up */
	device.key_location[KEY_UP_ARROW].left		= UpArrow[0];
	device.key_location[KEY_UP_ARROW].top		= UpArrow[1];
	device.key_location[KEY_UP_ARROW].right	= UpArrow[2];
	device.key_location[KEY_UP_ARROW].bottom	= UpArrow[3];
	/* key down */
	device.key_location[KEY_DOWN_ARROW].left	= DownArrow[0];
	device.key_location[KEY_DOWN_ARROW].top	= DownArrow[1];
	device.key_location[KEY_DOWN_ARROW].right	= DownArrow[2];
	device.key_location[KEY_DOWN_ARROW].bottom= DownArrow[3];
	/* key left */
	device.key_location[KEY_LEFT_ARROW].left	= LeftArrow[0];
	device.key_location[KEY_LEFT_ARROW].top	= LeftArrow[1];
	device.key_location[KEY_LEFT_ARROW].right	= LeftArrow[2];
	device.key_location[KEY_LEFT_ARROW].bottom= LeftArrow[3];
	/* key right */
	device.key_location[KEY_RIGHT_ARROW].left		= RightArrow[0];
	device.key_location[KEY_RIGHT_ARROW].top		= RightArrow[1];
	device.key_location[KEY_RIGHT_ARROW].right	= RightArrow[2];
	device.key_location[KEY_RIGHT_ARROW].bottom	= RightArrow[3];
	/* key menu */
	device.key_location[KEY_QUICK_ACS].left	= KeyMenu[0];
	device.key_location[KEY_QUICK_ACS].top		= KeyMenu[1];
	device.key_location[KEY_QUICK_ACS].right	= KeyMenu[2];
	device.key_location[KEY_QUICK_ACS].bottom	= KeyMenu[3];
	/* key func */
	device.key_location[KEY_ENTER].left		= KeyEnter[0];
	device.key_location[KEY_ENTER].top		= KeyEnter[1];
	device.key_location[KEY_ENTER].right	= KeyEnter[2];
	device.key_location[KEY_ENTER].bottom	= KeyEnter[3];
	/* key volume up */
	device.key_location[KEY_VOL_UP].left	= VolumeUp[0];
	device.key_location[KEY_VOL_UP].top		= VolumeUp[1];
	device.key_location[KEY_VOL_UP].right	= VolumeUp[2];
	device.key_location[KEY_VOL_UP].bottom	= VolumeUp[3];
	/* key volume down */
	device.key_location[KEY_VOL_DOWN].left		= VolumeDown[0];
	device.key_location[KEY_VOL_DOWN].top		= VolumeDown[1];
	device.key_location[KEY_VOL_DOWN].right	= VolumeDown[2];
	device.key_location[KEY_VOL_DOWN].bottom	= VolumeDown[3];
	/* key clear */
	device.key_location[KEY_CLEAR].left		= KeyClear[0];
	device.key_location[KEY_CLEAR].top		= KeyClear[1];
	device.key_location[KEY_CLEAR].right	= KeyClear[2];
	device.key_location[KEY_CLEAR].bottom	= KeyClear[3];
	/* key ext1 */
	device.key_location[KEY_EXTRA_1].left		= KeyReserved1[0];
	device.key_location[KEY_EXTRA_1].top		= KeyReserved1[1];
	device.key_location[KEY_EXTRA_1].right	= KeyReserved1[2];
	device.key_location[KEY_EXTRA_1].bottom	= KeyReserved1[3];
	/* key clear */
	device.key_location[KEY_EXTRA_2].left		= KeyReserved2[0];
	device.key_location[KEY_EXTRA_2].top		= KeyReserved2[1];
	device.key_location[KEY_EXTRA_2].right	= KeyReserved2[2];
	device.key_location[KEY_EXTRA_2].bottom	= KeyReserved2[3];


} /* end of FeedBackFeelingKeyInit */


/*****************************************************************************
* FUNCTION
*	FeedBackFeelingKeyAction
* DESCRIPTION
*	To draw the feedback feeling button, or recover the original
*
* PARAMETERS
*  key_code		IN		selected key
* RETURNS
*	void
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
void FeedBackFeelingKeyAction(int key_code)
{
   /*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	HDC		hdc;
	HRGN		hrgn_lcd;

	#ifdef __MMI_SUBLCD__
		HRGN	hrgn_sublcd;
	#endif	

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

	hdc = GetDC(hWnd);

	if (GetSimulatorBootStatus() != FALSE)
	{
		/* set clipping space for LCD and SUB-LCD */
		hrgn_lcd = CreateRectRgn(device.skin_main_lcd_x, device.skin_main_lcd_y, device.skin_main_lcd_x + LCD_WIDTH, device.skin_main_lcd_y + LCD_HEIGHT);
		ExtSelectClipRgn(hdc, hrgn_lcd, RGN_DIFF);
		
		#ifdef __MMI_SUBLCD__
			hrgn_sublcd = CreateRectRgn(device.skin_sub_lcd_x, device.skin_sub_lcd_y, device.skin_sub_lcd_x + SUBLCD_WIDTH, device.skin_sub_lcd_y + SUBLCD_HEIGHT);
			ExtSelectClipRgn(hdc, hrgn_sublcd, RGN_DIFF);
		#endif 	

	}

   if (key_code == KEY_INVALID || key_code == -1)
   {
		BitBlt(hdc, 0, 0, device.main_bitmap_width, device.main_bitmap_height, device.main_bitmap, 0, 0, SRCCOPY);
   }
   else if (key_code >= 0)
   {
		BitBlt(hdc, device.key_location[key_code].left, device.key_location[key_code].top, device.key_location[key_code].right - device.key_location[key_code].left + 1, device.key_location[key_code].bottom - device.key_location[key_code].top + 1, device.key_bitmap[key_code], 0, 0, SRCCOPY);
   }

#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif

	DeleteDC(hdc);
} /* end of FeedBackFeelingKeyAction */


/*****************************************************************************
* FUNCTION
*	ResetKeyMemory
* DESCRIPTION
*	Reset memories for keys
*
* PARAMETERS
*  nil
* RETURNS
*	void
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
void ResetKeyMemory()
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	int	i;

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	device.main_bitmap = NULL;

	for (i = 0; i < PC_KEY_NUMBERS; i++)
	{
		device.key_bitmap[i] = NULL;

⌨️ 快捷键说明

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