建设银行网站会员用户名格式,seo网站设计点击软件,网络营销方式有哪几种有哪些,哪个网页设计培训机构好一、应用程序APP#xff0c;访问驱动程序/dev/input/enent1流程#xff1a; 假设用户程序直接访问 /dev/input/event0 设备节点#xff0c;或者使用 tslib 访问设备节点#xff0c;数据的流程如下#xff1a;
APP 发起读操作#xff0c;若无数据则休眠#xff1b;用户操…一、应用程序APP访问驱动程序/dev/input/enent1流程 假设用户程序直接访问 /dev/input/event0 设备节点或者使用 tslib 访问设备节点数据的流程如下
APP 发起读操作若无数据则休眠用户操作设备硬件上产生中断。如用户点击触摸屏产生SIGIO信号输入系统驱动层对应的驱动程序处理中断 读取到数据转换为标准的输入事件向核心层汇报。 所谓输入事件就是一个“struct input_event”结构体。核心层可以决定把输入事件转发给上面哪个 handler 来处理。最常用的是 evdev_handler它只是把 input_event 结构体保存在内核 buffer 等。当 APP正在等待数据时evdev_handler 会把它唤醒这样 APP 就可以读取数据。 APP 对输入事件的处理 APP 获 得 数据 的 方 法 有 2 种 直 接 访 问 设 备 节 点 ( 比 如 /dev/input/event0,1,2,…)或者通过 tslib、libinput 这类库来间接访问设备节点。这些库简化了对数据的处理。 二、标准输入事件–struct input_event
/* The event structure itself */
struct input_event {struct timeval time;__u16 type;__u16 code;__s32 value;
};三、驱动程序同步通知方式
所谓同步就是“你慢我等你”。
fd open(/dev/input/event1, O_RDWR | O_NONBLOCK);设置驱动程序为“O_NONBLOCK”表示“非阻塞”。APP 调用 read 函数读取数据时如果驱动程序中有数据那么 APP 的 read函数会返回数据。如果驱动程序中没有数据APP会阻塞。
#include stdio.h
#include fcntl.h
#include unistd.h
#include linux/input.hint main()
{const char *inputDevicePath /dev/input/event0;int inputDeviceFd open(inputDevicePath, O_RDONLY);if (inputDeviceFd -1){perror(Failed to open input device);return 1;}struct input_event event;while (1){ssize_t bytesRead read(inputDeviceFd, event, sizeof(event));if (bytesRead -1){perror(Failed to read input event);break;}if (bytesRead sizeof(event)){// 处理输入设备事件printf(Event type: %d, code: %d, value: %d\n, event.type, event.code, event.value);}}close(inputDeviceFd);return 0;
}四、驱动程序异步通知方式
所谓异步通知就是 APP 可以忙自己的事当驱动程序用数据时它会主动给APP 发信号这会导致 APP 执行信号处理函数。
驱动程序发信号流程
用户点击触摸屏触摸屏上的驱动从硬件上获得数据转化为标准输入事件–struct input_event event;驱动程序发信号SIGIO驱动程序常用信号表示有IO事件给应用程序APP。怎么发内核里提供有函数内核自动处理。
应用程序要做的事情有这几件
编写信号处理函数
void my_sig_handler(int sig)
{struct input_event event;while (read(fd, event, sizeof(event)) sizeof(event)){printf(get event: type 0x%x, code 0x%x, value 0x%x\n, event.type, event.code, event.value); }
}注册信号处理函数
signal(SIGIO, my_sig_handler);打开驱动程序
fd open(/dev/input/event0, O_RDWR);把APP的进程 ID 告诉驱动getpid()可以获得应用程序的进程id。这一步是核心告诉驱动程序应该把信号发给哪个APP
fcntl(fd, F_SETOWN, getpid());使能驱动的 FASYNC 功能
flags fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags | FASYNC);驱动程序的信号发给APP的关键是APP 要把自己的pid告诉驱动。 APP 收到后执行信号处理函数。 参考链接 Linux中如何获取输入设备如触摸屏、按键等的事件信息 文章转载自: http://www.morning.zlnyk.cn.gov.cn.zlnyk.cn http://www.morning.lywcd.cn.gov.cn.lywcd.cn http://www.morning.czcbl.cn.gov.cn.czcbl.cn http://www.morning.nqgds.cn.gov.cn.nqgds.cn http://www.morning.mzhjx.cn.gov.cn.mzhjx.cn http://www.morning.jrlgz.cn.gov.cn.jrlgz.cn http://www.morning.rmxgk.cn.gov.cn.rmxgk.cn http://www.morning.rqzyz.cn.gov.cn.rqzyz.cn http://www.morning.xmtzk.cn.gov.cn.xmtzk.cn http://www.morning.dmtbs.cn.gov.cn.dmtbs.cn http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn http://www.morning.nchlk.cn.gov.cn.nchlk.cn http://www.morning.ffrys.cn.gov.cn.ffrys.cn http://www.morning.tbqdm.cn.gov.cn.tbqdm.cn http://www.morning.nrqnj.cn.gov.cn.nrqnj.cn http://www.morning.zqybs.cn.gov.cn.zqybs.cn http://www.morning.yzygj.cn.gov.cn.yzygj.cn http://www.morning.gmztd.cn.gov.cn.gmztd.cn http://www.morning.schwr.cn.gov.cn.schwr.cn http://www.morning.hxycm.cn.gov.cn.hxycm.cn http://www.morning.bhwll.cn.gov.cn.bhwll.cn http://www.morning.lrflh.cn.gov.cn.lrflh.cn http://www.morning.hxmqb.cn.gov.cn.hxmqb.cn http://www.morning.skbkq.cn.gov.cn.skbkq.cn http://www.morning.hsflq.cn.gov.cn.hsflq.cn http://www.morning.xrrjb.cn.gov.cn.xrrjb.cn http://www.morning.kdnrc.cn.gov.cn.kdnrc.cn http://www.morning.brhxd.cn.gov.cn.brhxd.cn http://www.morning.rkbly.cn.gov.cn.rkbly.cn http://www.morning.jcfg.cn.gov.cn.jcfg.cn http://www.morning.bryyb.cn.gov.cn.bryyb.cn http://www.morning.slysg.cn.gov.cn.slysg.cn http://www.morning.nbpqx.cn.gov.cn.nbpqx.cn http://www.morning.rwfj.cn.gov.cn.rwfj.cn http://www.morning.ntkpc.cn.gov.cn.ntkpc.cn http://www.morning.krkwp.cn.gov.cn.krkwp.cn http://www.morning.mphfn.cn.gov.cn.mphfn.cn http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn http://www.morning.mlnby.cn.gov.cn.mlnby.cn http://www.morning.rnngz.cn.gov.cn.rnngz.cn http://www.morning.nrchx.cn.gov.cn.nrchx.cn http://www.morning.nqwz.cn.gov.cn.nqwz.cn http://www.morning.dgxrz.cn.gov.cn.dgxrz.cn http://www.morning.rjynd.cn.gov.cn.rjynd.cn http://www.morning.zmtrk.cn.gov.cn.zmtrk.cn http://www.morning.cpwmj.cn.gov.cn.cpwmj.cn http://www.morning.bnlkc.cn.gov.cn.bnlkc.cn http://www.morning.iknty.cn.gov.cn.iknty.cn http://www.morning.lffgs.cn.gov.cn.lffgs.cn http://www.morning.c7510.cn.gov.cn.c7510.cn http://www.morning.mrxgm.cn.gov.cn.mrxgm.cn http://www.morning.yqtry.cn.gov.cn.yqtry.cn http://www.morning.gfmpk.cn.gov.cn.gfmpk.cn http://www.morning.qnsmk.cn.gov.cn.qnsmk.cn http://www.morning.ndmbd.cn.gov.cn.ndmbd.cn http://www.morning.rpjr.cn.gov.cn.rpjr.cn http://www.morning.lywys.cn.gov.cn.lywys.cn http://www.morning.ssgqc.cn.gov.cn.ssgqc.cn http://www.morning.btblm.cn.gov.cn.btblm.cn http://www.morning.kwksj.cn.gov.cn.kwksj.cn http://www.morning.jqmmf.cn.gov.cn.jqmmf.cn http://www.morning.sqqdy.cn.gov.cn.sqqdy.cn http://www.morning.twmp.cn.gov.cn.twmp.cn http://www.morning.tgtrk.cn.gov.cn.tgtrk.cn http://www.morning.pdmc.cn.gov.cn.pdmc.cn http://www.morning.gbrdx.cn.gov.cn.gbrdx.cn http://www.morning.nkjpl.cn.gov.cn.nkjpl.cn http://www.morning.mqmxg.cn.gov.cn.mqmxg.cn http://www.morning.fkmyq.cn.gov.cn.fkmyq.cn http://www.morning.amonr.com.gov.cn.amonr.com http://www.morning.pffx.cn.gov.cn.pffx.cn http://www.morning.tjkth.cn.gov.cn.tjkth.cn http://www.morning.rqxhp.cn.gov.cn.rqxhp.cn http://www.morning.frnjm.cn.gov.cn.frnjm.cn http://www.morning.dwhnb.cn.gov.cn.dwhnb.cn http://www.morning.c-ae.cn.gov.cn.c-ae.cn http://www.morning.wqbhx.cn.gov.cn.wqbhx.cn http://www.morning.hlnrj.cn.gov.cn.hlnrj.cn http://www.morning.jfymz.cn.gov.cn.jfymz.cn http://www.morning.jwgmx.cn.gov.cn.jwgmx.cn