(转)linux如何获取鼠标相对位置信息
- #include <stdio.h>
- #include <stdlib.h>
- #include <linux/input.h>
- #include <fcntl.h>
- #include <sys/time.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- int main(int argc,char **argv)
- {
- int fd, retval;
- char buf[6];
- fd_set readfds;
- struct timeval tv;
- // 打开鼠标设备
- fd = open( "/dev/input/mice", O_RDONLY );
- // 判断是否打开成功
- if(fd<0) {
- printf("Failed to open \"/dev/input/mice\".\n");
- exit(1);
- } else {
- printf("open \"/dev/input/mice\" successfuly.\n");
- }
- while(1) {
- // 设置最长等待时间
- tv.tv_sec = 5;
- tv.tv_usec = 0;
- FD_ZERO( &readfds );
- FD_SET( fd, &readfds );
- retval = select( fd+1, &readfds, NULL, NULL, &tv );
- if(retval==0) {
- printf( "Time out!\n" );
- }
- if(FD_ISSET(fd,&readfds)) {
- // 读取鼠标设备中的数据
- if(read(fd, buf, 6) <= 0) {
- continue;
- }
- // 打印出从鼠标设备中读取到的数据
- printf("Button type = %d, X = %d, Y = %d, Z = %d\n", (buf[0] & 0x07), buf[1], buf[2], buf[3]);
- }
- }
- close(fd);
- return 0;
- }
(转)linux如何获取鼠标相对位置信息的更多相关文章
- document.compatMode属性和获取鼠标的位置
document.compatMode属性 document.compatMode用来判断当前浏览器采用的渲染方式. 官方解释: BackCompat:标准兼容模式关闭.CSS1Compat:标准兼容 ...
- 获取鼠标经过位置的X、Y坐标
利用JavaScript获取鼠标经过位置的X.Y坐标方法. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN& ...
- js获取鼠标的位置
<!doctype html><html><head><meta charset="utf-8"><title>获取鼠标 ...
- WPF 获取鼠标屏幕位置、窗口位置、控件位置
原文:WPF 获取鼠标屏幕位置.窗口位置.控件位置 public struct POINT { public int X; public int Y; public POINT(int x, int ...
- js之获取窗口大小和位置信息
除IE外的浏览器查看窗口大小和位置信息: //The overall size of the browser window on the desktop var windowWidth = windo ...
- Range对象理解,浏览器兼容性,获取鼠标光标位置
一.关于浏览器的兼容性 目前主要有3种关于range的类似的对象,分别是W3C range 对象,Mozzlia selection ,ie TextRange 关于这三种的区别,请查看文档 http ...
- 获取用户当前位置信息的两种方法——H5、微信
在之前的 调用百度地图API的总结 中获取当前位置信息我用的是 H5 ,其实微信也提供了获取用户地理位置的方法,现将这两种方法都贴出来,看情况选择使用. 一.H5 获取当前地理位置得到经纬度 // H ...
- WPF获取鼠标当前位置
/// <summary> /// 设置鼠标的坐标 /// </summary> /// <param name="x">横坐标</par ...
- js获取鼠标坐标位置兼容多个浏览器
这个是IE 11 下兼容下视图测试时可用. $(window).bind('beforeunload', function (event) { var _this = this; var x = ev ...
随机推荐
- vue-resource HTTP API基础
vue-resource特点 vue-resource插件具有以下特点: 1. 体积小 vue-resource非常小巧,在压缩以后只有大约12KB,服务端启用gzip压缩后只有4.5KB大小,这远比 ...
- 14 微服务电商【黑马乐优商城】:day02-springcloud(理论篇二:知道什么是SpringCloud)
本项目的笔记和资料的Download,请点击这一句话自行获取. day01-springboot(理论篇) :day01-springboot(实践篇) day02-springcloud(理论篇一: ...
- PAT甲级——1035 Password (20分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- 源码分析Dubbo服务消费端启动流程
通过前面文章详解,我们知道Dubbo服务消费者标签dubbo:reference最终会在Spring容器中创建一个对应的ReferenceBean实例,而ReferenceBean实现了Spring生 ...
- Hardy-Weinberg laws
I.3 Diploids with two alleles: Hardy-Weinberg laws 假设子代是Aa,AA,aa的概率分别是PAa,PAA,Paa,A的基因概率是P1,a的基因概率是P ...
- Mysql数据库删除重复数据
最近因为发现数据库中的表有脏数据,需要维护.这些脏数据就是重复数据,需要将其删除. 现假设有一张test表,主键字段为num,还有id,one,two三个字段.假设id规定只能有一条记录(即需要为id ...
- Thinkphp中js报错,Uncaught SyntaxError: Unexpected token }
tp中js在行末使用注释报错Uncaught SyntaxError: Unexpected token } if (new_directors==1) {// 注释 解决办法:注释换成单行 if ( ...
- SVN服务器的搭建(二)
上一篇介绍了VisualSVN Server和TortoiseSVN的下载,安装,汉化.这篇介绍一下如何使用VisualSVN Server建立版本库,以及TortoiseSVN的使用. 首先打开Vi ...
- MDS算法及其matlab实现
问题背景: 在求解MTSP问题的时候,因为已知的为各个巡检点之间路径耗时长度,而这个具体描述采用无向图结构可以很好的描述,在matlab中通过函数(graphallshortestpaths)可以得到 ...
- E - Apple Tree(树状数组+DFS序)
There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. ...