dashandeda

dashandeda

0个粉丝

5

问答

0

专栏

0

资料

dashandeda  发布于  2015-01-19 18:54:37
采纳率 0%
5个问答
2878

怎么获取鼠标滚轮的状态啊?

 
如题,就是鼠标左右键中间的滚轮,这段代码只能获取鼠标移动的相对位置以及按键,而无法获取滚轮的状态。
#include
#include
#include
#include
#include
#include
#include
#include


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 = open("/dev/input/mice", O_RDONLY))<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;
}
我来回答
回答6个
时间排序
认可量排序

dashandeda

0个粉丝

5

问答

0

专栏

0

资料

dashandeda 2015-01-19 20:55:50
认可0
大神,来给我解答吧

dashandeda

0个粉丝

5

问答

0

专栏

0

资料

dashandeda 2015-01-20 08:48:07
认可0
等大神回复

ak491980

0个粉丝

34

问答

0

专栏

8

资料

ak491980 2015-01-20 21:52:29
认可0
没做过这个块,么有建议。帮顶。

dashandeda

0个粉丝

5

问答

0

专栏

0

资料

dashandeda 2015-01-22 09:51:44
认可0
有会的大神在吗

dashandeda

0个粉丝

5

问答

0

专栏

0

资料

dashandeda 2015-01-22 09:52:56
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=11550&ptid=5143]ak491980 发表于 2015-1-20 21:52[/url]
没做过这个块,么有建议。帮顶。[/quote]

谢谢谢谢,支持

dashandeda

0个粉丝

5

问答

0

专栏

0

资料

dashandeda 2015-01-23 14:36:29
认可0
还是没人回答
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区