0001
0002 #ifndef __UHID_H_
0003 #define __UHID_H_
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include <linux/input.h>
0024 #include <linux/types.h>
0025 #include <linux/hid.h>
0026
0027 enum uhid_event_type {
0028 __UHID_LEGACY_CREATE,
0029 UHID_DESTROY,
0030 UHID_START,
0031 UHID_STOP,
0032 UHID_OPEN,
0033 UHID_CLOSE,
0034 UHID_OUTPUT,
0035 __UHID_LEGACY_OUTPUT_EV,
0036 __UHID_LEGACY_INPUT,
0037 UHID_GET_REPORT,
0038 UHID_GET_REPORT_REPLY,
0039 UHID_CREATE2,
0040 UHID_INPUT2,
0041 UHID_SET_REPORT,
0042 UHID_SET_REPORT_REPLY,
0043 };
0044
0045 struct uhid_create2_req {
0046 __u8 name[128];
0047 __u8 phys[64];
0048 __u8 uniq[64];
0049 __u16 rd_size;
0050 __u16 bus;
0051 __u32 vendor;
0052 __u32 product;
0053 __u32 version;
0054 __u32 country;
0055 __u8 rd_data[HID_MAX_DESCRIPTOR_SIZE];
0056 } __attribute__((__packed__));
0057
0058 enum uhid_dev_flag {
0059 UHID_DEV_NUMBERED_FEATURE_REPORTS = (1ULL << 0),
0060 UHID_DEV_NUMBERED_OUTPUT_REPORTS = (1ULL << 1),
0061 UHID_DEV_NUMBERED_INPUT_REPORTS = (1ULL << 2),
0062 };
0063
0064 struct uhid_start_req {
0065 __u64 dev_flags;
0066 };
0067
0068 #define UHID_DATA_MAX 4096
0069
0070 enum uhid_report_type {
0071 UHID_FEATURE_REPORT,
0072 UHID_OUTPUT_REPORT,
0073 UHID_INPUT_REPORT,
0074 };
0075
0076 struct uhid_input2_req {
0077 __u16 size;
0078 __u8 data[UHID_DATA_MAX];
0079 } __attribute__((__packed__));
0080
0081 struct uhid_output_req {
0082 __u8 data[UHID_DATA_MAX];
0083 __u16 size;
0084 __u8 rtype;
0085 } __attribute__((__packed__));
0086
0087 struct uhid_get_report_req {
0088 __u32 id;
0089 __u8 rnum;
0090 __u8 rtype;
0091 } __attribute__((__packed__));
0092
0093 struct uhid_get_report_reply_req {
0094 __u32 id;
0095 __u16 err;
0096 __u16 size;
0097 __u8 data[UHID_DATA_MAX];
0098 } __attribute__((__packed__));
0099
0100 struct uhid_set_report_req {
0101 __u32 id;
0102 __u8 rnum;
0103 __u8 rtype;
0104 __u16 size;
0105 __u8 data[UHID_DATA_MAX];
0106 } __attribute__((__packed__));
0107
0108 struct uhid_set_report_reply_req {
0109 __u32 id;
0110 __u16 err;
0111 } __attribute__((__packed__));
0112
0113
0114
0115
0116
0117
0118
0119
0120 enum uhid_legacy_event_type {
0121 UHID_CREATE = __UHID_LEGACY_CREATE,
0122 UHID_OUTPUT_EV = __UHID_LEGACY_OUTPUT_EV,
0123 UHID_INPUT = __UHID_LEGACY_INPUT,
0124 UHID_FEATURE = UHID_GET_REPORT,
0125 UHID_FEATURE_ANSWER = UHID_GET_REPORT_REPLY,
0126 };
0127
0128
0129 struct uhid_create_req {
0130 __u8 name[128];
0131 __u8 phys[64];
0132 __u8 uniq[64];
0133 __u8 __user *rd_data;
0134 __u16 rd_size;
0135
0136 __u16 bus;
0137 __u32 vendor;
0138 __u32 product;
0139 __u32 version;
0140 __u32 country;
0141 } __attribute__((__packed__));
0142
0143
0144 struct uhid_input_req {
0145 __u8 data[UHID_DATA_MAX];
0146 __u16 size;
0147 } __attribute__((__packed__));
0148
0149
0150 struct uhid_output_ev_req {
0151 __u16 type;
0152 __u16 code;
0153 __s32 value;
0154 } __attribute__((__packed__));
0155
0156
0157 struct uhid_feature_req {
0158 __u32 id;
0159 __u8 rnum;
0160 __u8 rtype;
0161 } __attribute__((__packed__));
0162
0163
0164 struct uhid_feature_answer_req {
0165 __u32 id;
0166 __u16 err;
0167 __u16 size;
0168 __u8 data[UHID_DATA_MAX];
0169 } __attribute__((__packed__));
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 struct uhid_event {
0181 __u32 type;
0182
0183 union {
0184 struct uhid_create_req create;
0185 struct uhid_input_req input;
0186 struct uhid_output_req output;
0187 struct uhid_output_ev_req output_ev;
0188 struct uhid_feature_req feature;
0189 struct uhid_get_report_req get_report;
0190 struct uhid_feature_answer_req feature_answer;
0191 struct uhid_get_report_reply_req get_report_reply;
0192 struct uhid_create2_req create2;
0193 struct uhid_input2_req input2;
0194 struct uhid_set_report_req set_report;
0195 struct uhid_set_report_reply_req set_report_reply;
0196 struct uhid_start_req start;
0197 } u;
0198 } __attribute__((__packed__));
0199
0200 #endif