在使用HIDIOCSUSAGE一次向设备写1个value可以,但使用HIDIOCSUSAGES向设备写多个value却失败。
经过调查发现: kernel从2.4版本开始代码就已经实现了HIDIOCSUSAGES方法,但是从/usr/include/linux/hiddev.h中却没有对HIDIOCSUSAGES和及其相关的hiddev_usage_ref_multi结构进行定义,而且在kernel中关于hid设备driver的说明文件hiddev.txt中也没列出HIDIOCSUSAGES方法,向在使用HIDIOCSUSAGES向设备写数据不成功,也不知道问题出在哪边?
下面是我使用HIDIOCSUSAGES向设备写数据的代码:
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <asm/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/hiddev.h>
#define DEBUG 1
#define HID_MAX_MULTI_USAGES 1024
#define HIDIOCGUSAGES _IOWR('H', 0x13, struct hiddev_usage_ref_multi)
#define HIDIOCSUSAGES _IOW('H', 0x14, struct hiddev_usage_ref_multi)
#define HID_MAX_MULTI_USAGES 1024
struct hiddev_usage_ref_multi {
struct hiddev_usage_ref uref;
__u32 num_values;
__s