Changeset 051f96b in mainline
- 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
- Location:
- uspace/app/usbinfo
- Files:
-
- 3 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 */ -
uspace/app/usbinfo/main.c
re9c02b7 r051f96b 68 68 _OPTION("-S --status", "Get status of the device."); 69 69 _OPTION("-r --hid-report", "Dump HID report descriptor."); 70 _OPTION("-r --hid-report-usages", "Dump usages of HID report."); 70 71 71 72 printf("\n"); … … 86 87 {"status", no_argument, NULL, 'S'}, 87 88 {"hid-report", no_argument, NULL, 'r'}, 89 {"hid-report-usages", no_argument, NULL, 'R'}, 88 90 {0, 0, NULL, 0} 89 91 }; 90 static const char *short_options = "himtTsSr ";92 static const char *short_options = "himtTsSrR"; 91 93 92 94 static usbinfo_action_t actions[] = { … … 123 125 { 124 126 .opt = 'r', 125 .action = dump_hidreport, 127 .action = dump_hidreport_raw, 128 .active = false 129 }, 130 { 131 .opt = 'R', 132 .action = dump_hidreport_usages, 126 133 .active = false 127 134 }, -
uspace/app/usbinfo/usbinfo.h
re9c02b7 r051f96b 85 85 void dump_strings(usbinfo_device_t *); 86 86 void dump_status(usbinfo_device_t *); 87 void dump_hidreport(usbinfo_device_t *); 87 void dump_hidreport_raw(usbinfo_device_t *); 88 void dump_hidreport_usages(usbinfo_device_t *); 88 89 89 90
Note:
See TracChangeset
for help on using the changeset viewer.