00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #ifndef LIBUSB_HIDTYPES_H_
00036 #define LIBUSB_HIDTYPES_H_
00037
00038 #include <stdint.h>
00039 #include <adt/list.h>
00040
00041
00042
00046 #define USB_HID_MAX_USAGES 0xffff
00047
00056 #define USB_HID_UINT32_TO_INT32(x, size) \
00057 ((((x) & (1 << ((size) - 1))) != 0) ? \
00058 -(~((x) - 1) & ((1 << size) - 1)) : (x))
00059
00068 #define USB_HID_INT32_TO_UINT32(x, size) \
00069 (((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
00070
00071
00072
00076 typedef enum {
00078 USB_HID_REPORT_TYPE_INPUT = 1,
00079
00081 USB_HID_REPORT_TYPE_OUTPUT = 2,
00082
00085 USB_HID_REPORT_TYPE_FEATURE = 3
00086 } usb_hid_report_type_t;
00087
00088
00089
00093 typedef struct {
00095 int report_count;
00096
00098 link_t reports;
00099
00101 link_t collection_paths;
00102
00104 int collection_paths_count;
00105
00107 int use_report_ids;
00108
00110 uint8_t last_report_id;
00111
00112 } usb_hid_report_t;
00113
00114
00118 typedef struct {
00120 uint8_t report_id;
00121
00123 usb_hid_report_type_t type;
00124
00126 size_t bit_length;
00127
00129 size_t item_length;
00130
00132 link_t report_items;
00133
00135 link_t link;
00136 } usb_hid_report_description_t;
00137
00138
00142 typedef struct {
00144 int offset;
00145
00147 size_t size;
00148
00150 uint16_t usage_page;
00151
00153 uint16_t usage;
00154
00156 uint8_t item_flags;
00157
00159 usb_hid_report_path_t *collection_path;
00160
00164 int32_t logical_minimum;
00165
00169 int32_t logical_maximum;
00170
00174 int32_t physical_minimum;
00175
00177 int32_t physical_maximum;
00178
00180 int32_t usage_minimum;
00181
00183 int32_t usage_maximum;
00184
00186 uint32_t unit;
00187
00189 uint32_t unit_exponent;
00190
00192 uint32_t *usages;
00193
00195 size_t usages_count;
00196
00198 int32_t value;
00199
00201 link_t link;
00202 } usb_hid_report_field_t;
00203
00204
00205
00209 typedef struct {
00211 int32_t id;
00212
00214 uint16_t extended_usage_page;
00215
00217 uint32_t usages[USB_HID_MAX_USAGES];
00218
00220 int usages_count;
00221
00223 uint32_t usage_page;
00224
00226 int32_t usage_minimum;
00227
00229 int32_t usage_maximum;
00230
00232 int32_t logical_minimum;
00233
00235 int32_t logical_maximum;
00236
00238 int32_t size;
00239
00241 int32_t count;
00242
00244 size_t offset;
00245
00247 int32_t unit_exponent;
00249 int32_t unit;
00250
00252 uint32_t string_index;
00253
00255 uint32_t string_minimum;
00256
00258 uint32_t string_maximum;
00259
00261 uint32_t designator_index;
00262
00264 uint32_t designator_minimum;
00265
00267 uint32_t designator_maximum;
00268
00270 int32_t physical_minimum;
00271
00273 int32_t physical_maximum;
00274
00276 uint8_t item_flags;
00277
00279 usb_hid_report_type_t type;
00280
00282 usb_hid_report_path_t *usage_path;
00283
00285 link_t link;
00286
00287 int in_delimiter;
00288 } usb_hid_report_item_t;
00289
00293 typedef enum {
00294 USB_HID_MOD_LCTRL = 0x01,
00295 USB_HID_MOD_LSHIFT = 0x02,
00296 USB_HID_MOD_LALT = 0x04,
00297 USB_HID_MOD_LGUI = 0x08,
00298 USB_HID_MOD_RCTRL = 0x10,
00299 USB_HID_MOD_RSHIFT = 0x20,
00300 USB_HID_MOD_RALT = 0x40,
00301 USB_HID_MOD_RGUI = 0x80,
00302 USB_HID_MOD_COUNT = 8
00303 } usb_hid_modifiers_t;
00304
00305 static const usb_hid_modifiers_t
00306 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = {
00307 USB_HID_MOD_LCTRL,
00308 USB_HID_MOD_LSHIFT,
00309 USB_HID_MOD_LALT,
00310 USB_HID_MOD_LGUI,
00311 USB_HID_MOD_RCTRL,
00312 USB_HID_MOD_RSHIFT,
00313 USB_HID_MOD_RALT,
00314 USB_HID_MOD_RGUI
00315 };
00316
00317
00318
00319 #endif
00320