方法是把每一个/dev/input/event打开。通过ioctl函数来读取设备name,每一个设备name是固定的,可以根据name区分event。我这是查找触摸事件为例:代码如下:

 static int getTouchEventNum()
{
char name[]; /* RATS: Use ok, but could be better */
char buf[] = { , }; /* RATS: Use ok */
int fd = ;
int i;
for (i = ; i < ; i++)
{
sprintf(name, "/dev/input/event%d", i);
if ((fd = open(name, O_RDONLY, )) >= )
{
ioctl(fd, EVIOCGNAME(sizeof(buf)), buf);
if(strstr(buf, "MTOUC Touch"))
{
close(fd);
return i;
}
//printf("%s\n", name);
//printf("name: %s\n", buf);
close(fd);
}
}
return -;
}

这个函数的目的就是返回名字里有 MTOUC Touch 这个字段的event设备号,MTOUC Touch这个就是触摸的设备名字。

如何区分/dev/input/event的更多相关文章

  1. 如何读取Linux键值,输入子系统,key,dev/input/event,dev/event,C语言键盘【转】

    转自:https://blog.csdn.net/lanmanck/article/details/8423669 相信各位使用嵌入式的都希望直接读取键值,特别是芯片厂家已经提供input驱动的情况下 ...

  2. Linux如何查看与/dev/input目录下的event对应的设备

    1.查看当前的设备 dev/input/ 2.查看设备的名称 cat /proc/bus/input/devices

  3. Input event驱动

    Input event驱动 Linux 专门对输入设备. 键盘,鼠标,手柄,触摸屏.按键.封装一个类驱动. 主要统一与应用程序接口.这一类的设备结点都是在/dev/input/eventn( 0< ...

  4. Exception dispatching input event. use XlistView

    今天上午解决Bug,一个上午的时间: log: 11-01 14:49:14.826: E/InputEventReceiver(30810): Exception dispatching input ...

  5. 利用input event 实时监听input输入的内容

    <div id="addNumber"> <p>How many people would you like to invite?</p> &l ...

  6. js & input event & input change event

    js & input event & input change event vue & search & input change <input @click=& ...

  7. Linux获取/dev/input目录下的event对应的设备【转】

    转自:https://blog.csdn.net/qq_21792169/article/details/51458855 当我们在Linux操作系统下使用input子系统时,当我们先插鼠标,在插上摄 ...

  8. input event兼容性

    <div class="wrapper"> <p>keypress - event not call on adroid</p> <inp ...

  9. 使用JNI封装底层input系统提供的event事件

    首先说下思路,本文采用jni技术封装底层触摸事件,封装成MotionEvent类一样,不过没有android系统MotionEvent强大.源码MotionEvent位置:java-->fram ...

随机推荐

  1. ActiveX(一)第一个简单的Demo

    说道ActiveX,我的第一直觉就是Flash,利用ActiveX.我们可以创建丰富的可交互式应用程序.同时.利用ActiveX特性.我们可以实现Js 与 ActiveX 的无缝连接(包括数据共享.和 ...

  2. MS SQL验证字符串是否包含有大小写字母

    昨晚有实现一个小功能,就是在MS SQL Server中,检查字符串是否包含有大小写字母.通常应用在字符串的复杂度. ) = N'SDFfgGRYJhhTYUJ' IF LOWER(@s) COLLA ...

  3. ipsec IP安全策略操作 win7

    //禁止 win7 连接 public static void BannedWINRunCmd() { string str = Console.ReadLine(); System.Diagnost ...

  4. Python获取中国证券报最新资讯

    # -*- coding: utf-8 -*- import urllib from bs4 import BeautifulSoup from time import time from time ...

  5. ExtJS关于组件Component生命周期

    extjs组件生命周期大体分为3个阶段:初始化.渲染.销毁. 第一阶段:初始化 初始化工作开始于组件的诞生,所有必须的配置设定.事件注册.预渲染处理等都在此时进行. 1.应用组件的配置: 当初始化一个 ...

  6. c#中奖算法的实现

    算法名称 Alias Method public class AliasMethod { /* The probability and alias tables. */ private int[] _ ...

  7. 变通实现微服务的per request以提高IO效率

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  8. 本地部署arcgis by eclipse

    首次来博客园发帖,从本地部署arcgis api开始吧: 首先还是下载arcgis的api包开始,在中国区官网下载arcgis包: 1.http://support.esrichina.com.cn/ ...

  9. 【翻译】jQuery是有害的

    原文:http://lea.verou.me/2015/04/jquery-considered-harmful/**(第一次翻译,望大家多批评指正) jQuery是有害的 嗨,我总想写一个“X”是有 ...

  10. jqueryAPI使用之选择器

    好一段时间没有更新博文了.刚学习完JS基础知识后,也进入到了JQ的学习.为了能熟练掌握JQ的使用,最好的方法就是反复多练,讲JQ中的API的每个知识点都练习一遍.如果能做到这个,那么对JQ就没那么陌生 ...