LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 824|回复: 1

我的手柄检测程序

[复制链接]
发表于 2004-6-6 11:24:48 | 显示全部楼层 |阅读模式
gcc myjstest.c
./a.out /dev/jsX 即可

#include<linux/joystick.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
int main(int argc,char *argv[])
{
        int fd;
        int getnum;
        int success;
        struct js_event e;
       
        fd=open(argv[1],O_RDONLY);
        if (fd==-1){printf("joyport open fail!!\n");exit(0);}
        for(;;)
        {
                read(fd,&e,sizeof(struct js_event));
                printf("time:%d  value:%d  type:%d  number:%d\n",e.time,e.value,e.type,e.number);
        }
        return 0;
}

linux下操纵手柄没想到这么简单
发表于 2004-6-6 12:08:41 | 显示全部楼层
good ...
/usr/include/linux/joystick.h:struct js_event {
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表