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

📄 keymap.cpp

📁 MTK手机平台的MMI部分的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *  KeyMap.cpp
 *
 * Project:
 * --------
 *  MAUI
 *
 * Description:
 * ------------
 *  Processing keys of simulator.
 *  Routine to identify the keys being pressed.
 *
 * Author:
 * -------
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
#ifndef _KEYMAP_CPP
#define _KEYMAP_CPP

#ifdef MMI_ON_WIN32

#include <windows.h>
#include "PixtelDataTypes.h"

#include "KeyMap.h"
#include "StdAfx.h"
#include "GlobalConstants.h"
#include "DebugInitDef.h"
#include "resource.h"
#include "MMI_features.h"
#include "lcd_sw_inc.h"


/***************************************************************************** 
* Define
*****************************************************************************/

/***************************************************************************** 
* Typedef 
*****************************************************************************/

/***************************************************************************** 
* Local Variable
*****************************************************************************/
bool						isShutDownSystem = true;
T_W32_SCREEN_DEVICE	device;


/***************************************************************************** 
* Local Function
*****************************************************************************/

/***************************************************************************** 
* Global Variable
*****************************************************************************/
extern "C" S16	HEIGHT_OFFSET;
extern "C" S16	WIDTH_OFFSET;

extern "C" S16 Leftsoftkey[]; 	
extern "C" S16 Rightsoftkey[];	
extern "C" S16 UpArrow[];		
extern "C" S16 DownArrow[];		
extern "C" S16 LeftArrow[];		
extern "C" S16 RightArrow[];	
extern "C" S16 KeyMenu[];
extern "C" S16 KeyClear[];
extern "C" S16 KeyCall[];		
extern "C" S16 KeyEnd[]	;		
extern "C" S16 KeyPowerDown[];
extern "C" S16 VolumeUp[];		
extern "C" S16 VolumeDown[];	
extern "C" S16 KeyOne[]	;		
extern "C" S16	KeyTwo[];		
extern "C" S16	KeyThree[];		
extern "C" S16	KeyFour[];		
extern "C" S16	KeyFive[];		
extern "C" S16	KeySix[];		
extern "C" S16	KeySeven[];		
extern "C" S16	KeyEight[];		
extern "C" S16	KeyNine[];		
extern "C" S16	KeyZero[];		
extern "C" S16	KeyStar[];		
extern "C" S16	KeyHash[];		
extern "C" S16 KeyEnter[];
extern "C" S16 KeyboardKey[];
extern "C" S16 KeyReserved1[];
extern "C" S16 KeyReserved2[];
extern "C" S16 KeyReserved3[];
extern "C" S16 KeyReserved4[];
extern "C" S16 KeyReserved5[];

extern "C" HWND hWnd;
extern "C" BOOL bFlagNWSimulatorStart;

extern "C" U16 SIMULATOR_SKIN_LCD_X;
extern "C" U16 SIMULATOR_SKIN_LCD_Y;

/***************************************************************************** 
* Global Function
*****************************************************************************/
extern "C" void						FeedBackFeelingKeyInit(HWND hWnd, HINSTANCE hInstance, HBITMAP main_hbitmap);
extern "C" void						FeedBackFeelingKeyAction(int key_code);
extern "C" void						ResetKeyMemory();
extern "C" void						ReadKeyProfile(char in_path[], HWND hWnd);
extern "C" T_W32_SCREEN_DEVICE*	GetDeviceData();
extern "C" BOOL						GetSimulatorBootStatus();
extern "C" HWND						GetDialogHandle();
extern "C" HWND						GetWindowHandle();
extern "C" void						set_global_window_handle(HWND hwnd);


/*****************************************************************************
* FUNCTION
*	GetDeviceData
* DESCRIPTION
*	Get device data
*
* PARAMETERS
*  nil
* RETURNS
*	T_W32_SCREEN_DEVICE *
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
extern "C" T_W32_SCREEN_DEVICE* GetDeviceData()
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	return &device;
} /* end of GetDeviceDate */


/*****************************************************************************
* FUNCTION
*	GetKeyCode
* DESCRIPTION
*	Returns the location at which key is pressed
*
* PARAMETERS
*  nil
* RETURNS
*	UINT
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
UINT GetKeyCode()
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	UINT 			keyCode = KEY_INVALID; 
	POINT			point;
	RECT			wnd_rect, clint_rect;

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

	/* get window info */

	/*  Code below to find out the Curser position. */
	GetCursorPos(&point);

	/*  Code below to find out the co-ordinates of Rectangle. */
	GetClientRect(hWnd, &clint_rect);
	GetWindowRect(hWnd,&wnd_rect);   /* window coordinates */

	HEIGHT_OFFSET	= (short)(wnd_rect.bottom-wnd_rect.top-clint_rect.bottom);
	WIDTH_OFFSET	= (short)(wnd_rect.right-wnd_rect.left-clint_rect.right);

	/*  Code below identifies which key is being pressed based upon Cursor position & window coordinates */
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + Leftsoftkey[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + Leftsoftkey[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + Leftsoftkey[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + Leftsoftkey[3])))
	{
		keyCode = KEY_LSK;
	}
		
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + Rightsoftkey[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + Rightsoftkey[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + Rightsoftkey[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + Rightsoftkey[3])))
	{
		keyCode = KEY_RSK;	
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + UpArrow[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + UpArrow[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + UpArrow[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + UpArrow[3])))
	{
		keyCode = KEY_UP_ARROW;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + DownArrow[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + DownArrow[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + DownArrow[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + DownArrow[3])))
	{
		keyCode = KEY_DOWN_ARROW;	
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + LeftArrow[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + LeftArrow[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + LeftArrow[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + LeftArrow[3])))
	{
		keyCode = KEY_LEFT_ARROW;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + RightArrow[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + RightArrow[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + RightArrow[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + RightArrow[3])))
	{
		keyCode = KEY_RIGHT_ARROW;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyCall[0] ) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyCall[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyCall[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyCall[3])))
	{
		keyCode = KEY_SEND;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyEnd[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyEnd[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyEnd[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyEnd[3])))
	{
		keyCode = KEY_END;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyOne[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyOne[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyOne[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyOne[3])))
	{
		keyCode = KEY_1;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyTwo[0])  && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyTwo[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyTwo[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyTwo[3])))
	{
		keyCode = KEY_2;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyThree[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyThree[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyThree[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyThree[3])))
	{
		keyCode = KEY_3;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyFour[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyFour[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyFour[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyFour[3])))
	{
		keyCode = KEY_4;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyFive[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyFive[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyFive[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyFive[3])))
	{
		keyCode = KEY_5;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeySix[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeySix[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeySix[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeySix[3])))
	{
		keyCode = KEY_6;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeySeven[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeySeven[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeySeven[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeySeven[3])))
	{
		keyCode = KEY_7;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyEight[0] ) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyEight[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyEight[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyEight[3])))
	{
		keyCode = KEY_8;
	}

	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyNine[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyNine[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyNine[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyNine[3])))
	{
		keyCode = KEY_9;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyZero[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyZero[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyZero[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyZero[3])))
	{
		keyCode = KEY_0;
	}
	
	if (((point.x - WIDTH_OFFSET > wnd_rect.left + KeyStar[0]) && (point.x - WIDTH_OFFSET < wnd_rect.left + KeyStar[2])) &&
		((point.y - HEIGHT_OFFSET > wnd_rect.top + KeyStar[1]) && (point.y - HEIGHT_OFFSET < wnd_rect.top + KeyStar[3])))
	{
		keyCode = KEY_STAR;
	}

⌨️ 快捷键说明

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