linux input 设备的测试函数
来源:互联网 发布:brew install php fpm 编辑:程序博客网 时间:2024/06/09 21:00
为了能够在飞凌的OK6410开发板上,运行这个测试程序,在linux的上位机中,使用cross-4.2.2-eabi的交叉编译工具进行编译,把编译完的程序拷贝到SD卡中,运行飞凌开发板,执行该程序,就可以看到终端能够不断的采集到TP的触摸数据了,完整的源程序如下:
编译命令:arm-linux-gcc -o test code_name.c
/*test code for touch screen */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <linux/input.h>
static struct input_event ev_data;
static int ts_fd=-1;
#define TOUS_DEV "/dev/input/event3"
static int init_device(char *TS_DEV)
{
if((ts_fd = open(TS_DEV, O_RDONLY)) < 0)
{
printf("Error open %s\n\n", TS_DEV);
return -1;
}
return ts_fd;
}
static int test_touch_screen()
{
if(init_device(TOUS_DEV) < 0)
return -1;
while(1)
{
read(ts_fd, &ev_data, sizeof(ev_data));
if (ev_data.type == EV_KEY)
{
printf(" type: EV_KEY, code = %s, value = %d\n\n",
ev_data.code == BTN_TOUCH ? “BTN_TOUCH” : "Unkown, ev_data.value);
}
else if(ev_data.type == EV_ABS)
{
printf(" type: EV_ABS, code = %s, value = %d\n\n",
ev_data.code == ABS_X ? "ABS_X" :
ev_data.code == ABS_Y ? "ABS_Y" :
ev_data.code == ABS_PRESSURE ? "ABS_PRESSURE":
"Unkown", ev_data.value);
}
}
return 0;
}
int main(void)
{
test_touch_screen();
return 0;
}
- linux input 设备的测试函数
- qt和linux下的input设备
- Linux input设备子系统的软件架构
- linux input设备
- Linux Input 设备驱动
- linux input设备驱动
- linux input设备驱动 .
- linux input设备驱动
- linux ------ 闲聊input设备
- linux input设备驱动
- Linux Input 设备驱动
- Linux input设备驱动
- Linux Input 设备驱动
- 闲聊linux中的input设备
- 闲聊linux中的input设备
- Linux设备驱动 --- input子系统
- linux ------ input 子系统设备驱动
- 闲聊linux中的input设备
- CF 254B(日期)
- source insight的配置
- 杭电OJ题 1040 As Easy As A+B 解题报告
- Tabular: 在 Vim 中对齐文本
- 详解WINCE的控制面板
- linux input 设备的测试函数
- 指针赋值与指针传递
- android网络应用2——URLConnection
- 熟悉struts2MVC模式之用属性驱动传参例子
- Source Taste: Struts 2: com.opensymphony.xwork2.interceptor.ParametersInterceptor
- sed 命令
- Entity SQL 使用技巧
- Struts2的dojo使用与/template/ajax/head.ftl not found
- 学习方法