#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/kd.h>
#include <linux/h3600_ts.h>
#include <time.h>
#define KBD_DEVICE "/dev/zlg7289"
//#define _DEBUG
#include "ial.h"
#include "zlg7289.h"
#define N_KEYS 128
/* for data reading from /dev/hs3600_ts */
#if 1
typedef struct {
short b;
short x;
short y;
short pad;
} POS;
#endif
static time_t last_time;
static unsigned char state[N_KEYS];
static unsigned char status1=0; // different number and alphabetic
static unsigned char status2=0; // different alphabetic1 .. alphabetic3
static int ts = -1;
static int btn_fd = -1;
static unsigned char btn_state=0;
int key;
#if 1
static int mousex = 0;
static int mousey = 0;
static POS pos;
#endif
/************************ Low Level Input Operations **********************/
/*
* Mouse operations -- Event
*/
#if 1
static int mouse_update(void)
{
return 1;
}
static void mouse_getxy(int *x, int* y)
{
*x = mousex;
*y = mousey;
}
static int mouse_getbutton(void)
{
return pos.b;
}
#endif
static int keyboard_update(void)
{
int status;
status = (btn_state & 0x80)? 0 : 1;
key = btn_state & 0x7f;
printf("key:%x\n",key);
switch(key)
{
case 0x0D: //上
state[0] = status;
break;
case 0x0E: //下
state[1] = status;
break;
case 0x0F: //左
state[2] = status;
break;
case 0x13: //右
state[3] = status;
break;
case 0x3F: //静音
state[7] = status;
break;
case 0x35:
state[5] = status;
break;
case 0x2E:
state[6] = status;
break;
case 0x3E: //手动/自动
state[7] = status;
break;
case 0x36:
state[8] = status;
break;
case 0x2F:
state[9] = status;
break;
case 0x3D: //隔离
state[10] = status;
break;
case 0x37:
state[11] = status;
break;
case 0x33:
state[12] = status;
break;
case 0x3C: //火警复位
state[13] = status;
break;
case 0x3B:
state[14] = status;
break;
case 0x34:
state[15] = status;
break;
case 0x2D: //ESC
state[16] = status;
break;
case 0x23: //2
state[50] = status;
break;
case 0x1C: //5
state[53] = status;
break;
case 0x15: //8
state[56] = status;
break;
case 0x2C: //1
state[49] = status;
break;
case 0x24: //3
state[51] = status;
break;
case 0x1D: //6
state[54] = status;
break;
case 0x16: //9
state[5] = status;
break;
case 0x2B: //DEL
state[127] = status;
break;
case 0x25: //4
state[52] = status;
break;
case 0x1E: //7
state[55] = status;
break;
case 0x17: //0
state[48] = status;
break;
case 0x27: //FN
state[28] = status;
break;
case 0x26: //SHIFT
state[29] = status;
break;
case 0x1F: //+-*/
state[43] = status;
break;
case 0x1B: //BACKSPACE
state[32] = status;
break;
case 0x14: //ENTER
state[32] = status;
break;
}
return N_KEYS;
}
static const char* keyboard_getstate(void)
{
return (char *)state;
}
#ifdef _LITE_VERSION
static int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except,
struct timeval *timeout)
#else
static int wait_event (int which, fd_set *in, fd_set *out, fd_set *except,
struct timeval *timeout)
#endif
{
fd_set rfds;
int retvalue = 0;
int e;
if (!in) {
in = &rfds;
FD_ZERO (in);
}
if ((which & IAL_MOUSEEVENT) && ts >= 0) {
FD_SET (ts, in);
#ifdef _LITE_VERSION
if (ts > maxfd) maxfd = ts;
#endif
}
if ((which & IAL_KEYEVENT) && btn_fd >= 0){
FD_SET (btn_fd, in);
#ifdef _LITE_VERSION
if(btn_fd > maxfd) maxfd = btn_fd;
#endif
}
#ifdef _LITE_VERSION
e = select (maxfd + 1, in, out, except, timeout) ;
#else
e = select (FD_SETSIZE, in, out, except, timeout) ;
#endif
if (e > 0) {
#if 1
if (ts >= 0 && FD_ISSET (ts, in)) {
short data [4];
FD_CLR (ts, in);
read (ts, data, sizeof (data));
if (data[0]) {
mousex = pos.x = data[1];
mousey = pos.y = data[2];
}
#ifdef _DEBUG
if (data[0]) {
printf ("mouse down: pos.x = %d, pos.y = %d\n", pos.x, pos.y);
}
#endif
pos.b = (data[0] ? 4 : 0);
retvalue |= IAL_MOUSEEVENT;
}
#endif
if (btn_fd >= 0 && FD_ISSET(btn_fd, in)) {
unsigned char key;
FD_CLR(btn_fd, in);
read(btn_fd, &key, sizeof(key));
#ifdef _DEBUG
printf("IAL:read key:0x%x \n",key);
#endif
btn_state = key;
retvalue |= IAL_KEYEVENT;
}
} else if (e < 0) {
return -1;
}
return retvalue;
}
BOOL InitZLG7289Input (INPUT* input, const char* mdev, const char* mtype)
{
printf("init ZLG7289 input ... \n");
btn_fd = open (KBD_DEVICE, O_RDONLY);
if (btn_fd < 0 ) {
printf (stderr, "kb9200: Can not open button key!\n");
return FALSE;
}
#if 1
printf("mouse");
input->update_mouse = mouse_update;
input->get_mouse_xy = mouse_getxy;
input->set_mouse_xy = NULL;
input->get_mouse_button = mouse_getbutton;
input->set_mouse_range = NULL;
#endif
input->update_keyboard = keyboard_update;
input->get_keyboard_state = keyboard_getstate;
input->set_leds = NULL;
input->wait_event = wait_event;
#if 1
mousex = 0;
mousey = 0;
pos.x = pos.y = pos.b = 0;
#endif
return TRUE;
}
void TermZLG7289Input (void)
{
if (ts >= 0)
close(ts);
if (btn_fd >= 0)
close(btn_fd);
}
//#endif /* _IPAQ_IAL */
zlg_7289.rar_Makefile.am_minigui_minigui 1.6.2_minigui ial_zlg72
版权申诉
43 浏览量
2022-09-14
14:39:40
上传
评论
收藏 8KB RAR 举报
御道御小黑
- 粉丝: 58
- 资源: 1万+
最新资源
- 电子万年历软件仿真(经过多次修改,保证正确性)
- Unity XR 手势射击控制脚本(适用于任何可手势识别的设备)
- 机械设计全自动电表(NB和IC卡表)控制和上壳装配线sw16可编辑非常好的设计图纸100%好用.zip
- 基于matlab的EAN-13条形码识别系统GUI界面.zip代码53
- matlab基于bp神经网络交通信号标志识别GUI界面13个标志.zip代码54
- 电子万年历答辩实物展示视频mp4格式
- 基于python实现的程序,包括哈希感知算法cvHash,图像切割cvsplit,固定目标检测cvRec(附文档ppt)等
- 计算0-10000之间所有偶数的和
- multiled.zip
- 基于php实现的哈希算法的人脸检索
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0