📄 jkapi.c
字号:
/*********************************************************************
Function: uchar Remote_Transform(uchar mode,uchar *InBuffer)
功能: 将遥感数据转化成不同模式时的数据格式
输入:mode 表示当前遥感的工作模式,InBuffer 遥感数据存放地址
输出:OutBuffer 转化以后数据输出地址
返回:转换后数据长度
描述:上层调用此函数来将遥感数据按相应模式转化成相应的数据
mode 1:遥感 -\
mode 2:4方向 } 游戏手柄模式下的情况
mode 3:8方向 -/
mode 4:4按键
mode 5:鼠标
output_key的低四位表示四个按键位,1表示按下,0表示弹起;其中
0 bit表示up; 1 bit表示right; 2 bit表示down; 3 bit表示left;
********************************************************************/
#define min_d (79)
#define max_d (175)
#define mouse_map_l4 0xf6 //-10
#define mouse_map_h4 0xff //
#define mouse_map_l3 0xfa //-6
#define mouse_map_h3 0xff //
#define mouse_map_l2 0xfd //-3
#define mouse_map_h2 0xff //
#define mouse_map_l1 0xff //-1
#define mouse_map_h1 0xff //
#define mouse_map_l0 0x00 //0
#define mouse_map_h0 0x00 //
#define mouse_mapl1 0x01 //1
#define mouse_maph1 0x00 //
#define mouse_mapl2 0x03 //3
#define mouse_maph2 0x00 //
#define mouse_mapl3 0x06 //6
#define mouse_maph3 0x00 //
#define mouse_mapl4 0x0a //10
#define mouse_maph4 0x00 //
#define mouse_jk_4 8 //
#define mouse_jk_3 20 //
#define mouse_jk_2 44 //
#define mouse_jk_1 80 //
#define mouse_jk1 175 //
#define mouse_jk2 211 //
#define mouse_jk3 235 //
#define mouse_jk4 247 //
uchar Remote_Transform(uchar mode,uchar *InBuffer)
{
uchar x,y,output_x,output_y,output_key,output_x_l,output_x_h,output_y_l,output_y_h;
if(mode==1)
return 0;
x=*InBuffer;
y=*(InBuffer+1);
//=================================================
if(mode==5){
if(x>mouse_jk4)
{
output_y_h=mouse_maph4;
output_y_l=mouse_mapl4;
}
else if(x>mouse_jk3)
{
output_y_h=mouse_maph3;
output_y_l=mouse_mapl3;
}
else if(x>mouse_jk2)
{
output_y_h=mouse_maph2;
output_y_l=mouse_mapl2;
}
else if(x>mouse_jk1)
{
output_y_h=mouse_maph1;
output_y_l=mouse_mapl1;
}
else if(x<mouse_jk_4)
{
output_y_h=mouse_map_h4;
output_y_l=mouse_map_l4;
}
else if(x<mouse_jk_3)
{
output_y_h=mouse_map_h3;
output_y_l=mouse_map_l3;
}
else if(x<mouse_jk_2)
{
output_y_h=mouse_map_h2;
output_y_l=mouse_map_l2;
}
else if(x<mouse_jk_1)
{
output_y_h=mouse_map_h1;
output_y_l=mouse_map_l1;
}
else
{
output_y_h=mouse_map_h0;
output_y_l=mouse_map_l0;
}
//--------------------------------------------------------------
if(y>mouse_jk4)
{
output_x_h=mouse_maph4;
output_x_l=mouse_mapl4;
}
else if(y>mouse_jk3)
{
output_x_h=mouse_maph3;
output_x_l=mouse_mapl3;
}
else if(y>mouse_jk2)
{
output_x_h=mouse_maph2;
output_x_l=mouse_mapl2;
}
else if(y>mouse_jk1)
{
output_x_h=mouse_maph1;
output_x_l=mouse_mapl1;
}
else if(y<mouse_jk_4)
{
output_x_h=mouse_map_h4;
output_x_l=mouse_map_l4;
}
else if(y<mouse_jk_3)
{
output_x_h=mouse_map_h3;
output_x_l=mouse_map_l3;
}
else if(y<mouse_jk_2)
{
output_x_h=mouse_map_h2;
output_x_l=mouse_map_l2;
}
else if(y<mouse_jk_1)
{
output_x_h=mouse_map_h1;
output_x_l=mouse_map_l1;
}
else
{
output_x_h=mouse_map_h0;
output_x_l=mouse_map_l0;
}
*OutBuffer =output_x_l;
*(OutBuffer+1)=output_x_h;
*(OutBuffer+2)=output_y_l;
*(OutBuffer+3)=output_y_h;
return 4;
}
//=================================================
if(mode==2){
if(x>37&&x<217&&y>217){
output_x =0x7f;
output_y =0xff; //up
}
else if(x>217&&y<217&&y>37){
output_x =0xff;
output_y =0x7f; //right
}
else if(x>37&&x<217&&y<37){
output_x =0x7f;
output_y =0x00; //down
}
else if(x<37&&y<217&&y>37){
output_x =0x00;
output_y =0x7f; //left
}
else {
output_x =0x7f;
output_y =0x7f;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else{
if(x>min_d&&x<max_d&&y>max_d)
{ output_key =0x01; //key
output_x =0x7f;
output_y =0xff;} //up
//----------------------------------
else if(x>max_d&&y>max_d)
{ output_key =0x03; //key
output_x =0xff;
output_y =0xff;} //up and right
//----------------------------------
else if(x>max_d&&y<max_d&&y>min_d)
{ output_key =0x02; //key
output_x =0xff;
output_y =0x7f;} //right
//----------------------------------
else if(x>max_d&&y<min_d)
{ output_key =0x06; //key
output_x =0xff;
output_y =0x00;} //right and down
//----------------------------------
else if(x<max_d&&x>min_d&&y<min_d)
{ output_key =0x04;
output_x =0x7f;
output_y =0x00;} //down
//----------------------------------
else if(x<min_d&&y<min_d)
{ output_key =0x0c; //key
output_x =0x00;
output_y =0x00;} //down and left
//----------------------------------
else if(x<min_d&&y>min_d&&y<max_d)
{ output_key =0x08; //key
output_x =0x00;
output_y =0x7f;} //left
//----------------------------------
else if(x<min_d&&y>max_d)
{ output_key =0x09; //key
output_x =0x00;
output_y =0xff;} //up and left
//----------------------------------
else {
output_key =0x00;
output_x =0x7f;
output_y =0x7f;
}
}
//=================================================
if(mode==2||mode==3){
*OutBuffer=output_x;
*(OutBuffer+1)=output_y;
return 2;
}
if(mode=4) {
*OutBuffer=output_key;
return 1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -