📄 e_event.c
字号:
/******************************************************************************
*
* The information contained herein is the exclusive property of
* Sunplus Technology Co. And shall not be distributed, reproduced,
* or disclosed in whole in part without prior written permission.
*
* (C) COPYRIGHT 2005 SUNPLUS TECHNOLOGY CO.
* ALL RIGHTS RESERVED
*
* The entire notice above must be reproduced on all authorized copies.
*
*****************************************************************************/
/******************************************************************************
* Filename: E_Event.c
* Author: Robin.xjliu (eMail: xjliu@sunplus.com)
* Tel: 00885-028-87848688-5884
* Date: 2005-11-21
* Description: deal with input device,and translate key
* Reference:
* Version history:
*-----------------------------------------------------------------------------
* Version YYYY-MM-DD-INDEX Modified By Description
* 1.0.0 2005-11-21 xjliu Create
*
*****************************************************************************/
#include "Include/E_Event.h"
extern U32 DetectPosition;
#define Position_X_Ready bit1
#define Position_Y_Ready bit2
EVENT g_stEvent;
#define LDM_EN 0x80000000
#define LDM_IRQEN 0x40000000
#define LDM_MIU2LDM 0x00000000
#define LDM_LDM2MIU 0x20000000
#define LDM_BYTE 0x00000000
#define LDM_HWORD 0x04000000
#define LDM_WORD 0x08000000
#define LDM_BURST 0x0C000000
//U32 DiffBuf[300];
U32 old_yuv,md_frame_int;
/**
* E_TransJoystick
*/
VIRTUAL_KEY E_TransJoystick(U32 nKeyValue)
{
#define Translate(a,b) case a: return b;
switch(nKeyValue)
{
Translate(KEY_UP, VK_UP);
Translate(KEY_DOWN, VK_DOWN);
Translate(KEY_LEFT, VK_LEFT);
Translate(KEY_RIGHT, VK_RIGHT);
Translate(KEY_LEFTUP, VK_LEFTUP);
Translate(KEY_RIGHTUP, VK_RIGHTUP);
Translate(KEY_LEFTDOWN, VK_LEFTDOWN);
Translate(KEY_RIGHTDOWN, VK_RIGHTDOWN);
Translate(KEY_START, VK_START);
Translate(KEY_MODE, VK_MODE);
Translate(KEY_A, VK_A);
Translate(KEY_B, VK_B);
}
return VK_MAX_NUM;
}
/**
*
*/
#ifdef INPUT_SENSOR
#endif //SENSOR
/**
*
*/
#ifdef INPUT_TOUCHPANEL
#endif //TOUCHPANEL
/* U32 CSI_MD_BUFFER[1200] __attribute__ ((section (".ar_MD_LDM")));
U32 CSI_MD_DIFFBUF[1200] __attribute__ ((section (".ar_MD_SDRAM"))) ;
U32 CSI_KEY[7],OLDCSI_KEY[7], diff_key[7];
U32 CSIKey;
U32 CSI_Table[]={
KEY_LEFT,
KEY_UP,
KEY_DOWN,
KEY_RIGHT,
};
void CheckCSIKey(U32 x, U32 y)
{
if(x<=12 && x>=0)
{
// if(y<=9 && y>=0)
// CSI_KEY[0]+=1;
// CSIKey = KEY_LEFTUP;
if(y<=19 && y>=10)
// CSIKey = KEY_LEFT;
CSI_KEY[0]+=1;
// else if(y<=29 && y>=20)
// CSI_KEY[2]+=1;
// CSIKey = KEY_LEFTDOWN;
}
else if(x<=26 && x>=13)
{
if(y<=9 && y>=0)
CSI_KEY[1]+=1;
if(y<=29 && y>=20)
CSI_KEY[2]+=1;
// CSIKey = KEY_UP;
}
else if(x<=39 && x>=27)
{
// if(y<=9 && y>=0)
// CSI_KEY[4]+=1;
// CSIKey = KEY_RIGHTUP;
if(y<=19 && y>=10)
CSI_KEY[3]+=1;
// CSIKey = KEY_RIGHT;
// else if(y<=29 && y>=20)
// CSI_KEY[6]+=1;
// CSIKey = KEY_RIGHTDOWN;
}
}
void GetMotionDetect(void)
{
U32 i,j,k;
U32 diff_value;
U32 max_value, keyindex;
while (md_frame_int == 0);
md_frame_int = 0;
// Move DIFF Buffer to LDM
*P_LDM_MIU_START = (U32)CSI_MD_DIFFBUF;
*P_LDM_MIU_END = (U32)CSI_MD_DIFFBUF + 1200;
*P_LDM_START = (U32)CSI_MD_BUFFER;
*P_LDM_END = (U32)CSI_MD_BUFFER + 1200;
*P_LDM_CTRL = LDM_EN|LDM_MIU2LDM|LDM_BURST;
while (*P_LDM_STATUS == 0);
*P_LDM_STATUS = 0x80000000;
*P_LDM_CTRL = 0;
k=0;
for(i=0; i<4; i++)
CSI_KEY[i]=0;
for(i=0; i<30; i++)
{
for(j=0; j<40; j++)
{
if ((k&0x3) == 0)
diff_value = CSI_MD_BUFFER[k/4]&0xF;
if((diff_value & 0x1) != 0)
CheckCSIKey(j,i);
// break;
// return true;
k++;
diff_value = (diff_value>>1);
}
}
for(i=0; i<4; i++)
{
if(CSI_KEY[i] != OLDCSI_KEY[i])
diff_key[i] = CSI_KEY[i];
else
diff_key[i] = 0;
}
max_value = diff_key[0];
keyindex = 0;
for(i=0; i<4; i++)
{
if(diff_key[i]>max_value)
{
max_value = diff_key[i];
keyindex = i;
// CSIKey = CSI_Table[i];
// break;
}
}
CSIKey = CSI_Table[keyindex];
// return false;
}
*/
extern U32 Location;
extern U8 g_nText3Mode;
/**
* E_InputService
*/
void E_InputService(EVENT_TYPE msg)
{
//Check Joystick info in the PPU_Service
//GetMotionDetect();
switch(msg)
{
case EV_JOYSTICK:
if(g_nText3Mode==1)
{
GetTouchKeyCode();
if(Location == 0)
{
GetJoystickKeyCode();
}
g_stEvent.Ev_Type = EV_JOYSTICK;
g_stEvent.Ev_Key = E_TransJoystick(Location);
if(g_stEvent.Ev_Key == VK_MAX_NUM)
{
g_stEvent.Ev_Key = E_TransJoystick(g_Joystick_KeyCode1);
}
Location = 0;
}
else
{
GetJoystickKeyCode();
g_stEvent.Ev_Type = EV_JOYSTICK;
g_stEvent.Ev_Key = E_TransJoystick(g_Joystick_KeyCode1);
// GetMotionDetect();
// g_stEvent.Ev_Key = E_TransJoystick(CSIKey);
// CSIKey = 0;
}
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -