Changeset 051f96b in mainline for uspace/app/usbinfo/hid.c
- Timestamp:
- 2011-06-17T20:53:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2e833cf7
- Parents:
- e9c02b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/hid.c
re9c02b7 r051f96b 44 44 #define BYTES_PER_LINE 20 45 45 46 typedef enum { 47 HID_DUMP_RAW, 48 HID_DUMP_USAGES 49 } hid_dump_type_t; 50 46 51 typedef struct { 47 52 usbinfo_device_t *dev; 53 hid_dump_type_t dump_type; 48 54 usb_standard_interface_descriptor_t *last_iface; 49 55 } descriptor_walk_context_t; … … 85 91 } 86 92 87 /** Dumps HID report in pseudo human-readable format.93 /** Dumps usages in HID report. 88 94 * 89 95 * @param iface_no USB interface the report belongs to. 90 96 * @param report Parsed report descriptor. 91 97 */ 92 static void dump_hid_report_ brief(int iface_no, usb_hid_report_t *report)98 static void dump_hid_report_usages(int iface_no, usb_hid_report_t *report) 93 99 { 94 100 printf("%sParsed HID report descriptor for interface %d\n", … … 110 116 /** Retrieves HID report from given USB device and dumps it. 111 117 * 118 * @param dump_type In which format to dump the report. 112 119 * @param ctrl_pipe Default control pipe to the device. 113 120 * @param iface_no Interface number. 114 121 * @param report_size Size of the report descriptor. 115 122 */ 116 static void retrieve_and_dump_hid_report( usb_pipe_t *ctrl_pipe,117 u int8_t iface_no, size_t report_size)123 static void retrieve_and_dump_hid_report(hid_dump_type_t dump_type, 124 usb_pipe_t *ctrl_pipe, uint8_t iface_no, size_t report_size) 118 125 { 119 126 assert(report_size > 0); … … 146 153 } 147 154 148 dump_hid_report_raw(iface_no, raw_report, report_size); 149 dump_hid_report_brief(iface_no, &report); 155 switch (dump_type) { 156 case HID_DUMP_RAW: 157 dump_hid_report_raw(iface_no, raw_report, report_size); 158 break; 159 case HID_DUMP_USAGES: 160 dump_hid_report_usages(iface_no, &report); 161 break; 162 default: 163 assert(false && "unreachable code apparently reached"); 164 } 150 165 151 166 free(raw_report); … … 195 210 } 196 211 197 retrieve_and_dump_hid_report(&context->dev->ctrl_pipe, 198 context->last_iface->interface_number, report_size); 199 } 200 201 202 void dump_hidreport(usbinfo_device_t *dev) 212 retrieve_and_dump_hid_report(context->dump_type, 213 &context->dev->ctrl_pipe, context->last_iface->interface_number, 214 report_size); 215 } 216 217 218 void dump_hidreport_raw(usbinfo_device_t *dev) 203 219 { 204 220 descriptor_walk_context_t context = { 205 221 .dev = dev, 222 .dump_type = HID_DUMP_RAW, 206 223 .last_iface = NULL 207 224 }; … … 213 230 } 214 231 232 void dump_hidreport_usages(usbinfo_device_t *dev) 233 { 234 descriptor_walk_context_t context = { 235 .dev = dev, 236 .dump_type = HID_DUMP_USAGES, 237 .last_iface = NULL 238 }; 239 240 usb_dp_walk_simple(dev->full_configuration_descriptor, 241 dev->full_configuration_descriptor_size, 242 usb_dp_standard_descriptor_nesting, 243 descriptor_walk_callback, &context); 244 } 245 215 246 /** @} 216 247 */
Note:
See TracChangeset
for help on using the changeset viewer.