Changes in uspace/app/vuhid/main.c [eb34d8e:920d0fc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/vuhid/main.c
reb34d8e r920d0fc 40 40 #include <errno.h> 41 41 #include <str_error.h> 42 #include <getopt.h>43 42 44 43 #include <usb/usb.h> … … 53 52 #include "stdreq.h" 54 53 55 #define DEFAULT_CONTROLLER "/virt/usbhc/virtual"56 57 54 static usbvirt_control_request_handler_t endpoint_zero_handlers[] = { 58 55 { 59 STD_REQ_IN(USB_REQUEST_RECIPIENT_INTERFACE, USB_DEVREQ_GET_DESCRIPTOR), 56 .req_direction = USB_DIRECTION_IN, 57 .req_type = USB_REQUEST_TYPE_STANDARD, 58 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE, 59 .request = USB_DEVREQ_GET_DESCRIPTOR, 60 60 .name = "Get_Descriptor", 61 61 .callback = req_get_descriptor 62 62 }, 63 63 { 64 CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_INTERFACE, USB_HIDREQ_SET_PROTOCOL), 64 .req_direction = USB_DIRECTION_OUT, 65 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE, 66 .req_type = USB_REQUEST_TYPE_CLASS, 67 .request = USB_HIDREQ_SET_PROTOCOL, 65 68 .name = "Set_Protocol", 66 69 .callback = req_set_protocol 67 70 }, 68 71 { 69 CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_INTERFACE, USB_HIDREQ_SET_REPORT), 72 .req_direction = USB_DIRECTION_OUT, 73 .req_recipient = USB_REQUEST_RECIPIENT_INTERFACE, 74 .req_type = USB_REQUEST_TYPE_CLASS, 75 .request = USB_HIDREQ_SET_REPORT, 70 76 .name = "Set_Report", 71 77 .callback = req_set_report … … 145 151 146 152 147 static struct option long_options[] = {148 {"help", optional_argument, NULL, 'h'},149 {"controller", required_argument, NULL, 'c' },150 {"list", no_argument, NULL, 'l' },151 {0, 0, NULL, 0}152 };153 static const char *short_options = "hc:l";154 155 static void print_help(const char* name, const char* module)156 {157 if (module == NULL) {158 /* Default help */159 printf("Usage: %s [options] device.\n", name);160 printf("\t-h, --help [device]\n");161 printf("\t\to With no argument print this help and exit.\n");162 printf("\t\to With argument print device specific help and exit.\n");163 printf("\t-l, --list \n\t\tPrint list of available devices.\n");164 printf("\t-c, --controller \n\t\t"165 "Use provided virtual hc instead of default (%s)\n",166 DEFAULT_CONTROLLER);167 return;168 }169 printf("HELP for module %s\n", module);170 }171 172 static void print_list(void)173 {174 printf("Available devices:\n");175 for (vuhid_interface_t **i = available_hid_interfaces; *i != NULL; ++i)176 {177 printf("\t`%s'\t%s\n", (*i)->id, (*i)->name);178 }179 180 }181 182 static const char *controller = DEFAULT_CONTROLLER;183 184 153 int main(int argc, char * argv[]) 185 154 { 186 187 if (argc == 1) { 188 print_help(*argv, NULL); 189 return 0; 190 } 191 192 int opt = 0; 193 while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) > 0) { 194 switch (opt) 195 { 196 case 'h': 197 print_help(*argv, optarg); 198 return 0; 199 case 'c': 200 controller = optarg; 201 break; 202 case 'l': 203 print_list(); 204 return 0; 205 case -1: 206 default: 207 break; 208 } 209 } 210 155 int rc; 211 156 212 157 log_init("vuhid"); … … 216 161 217 162 /* Determine which interfaces to initialize. */ 218 for (int i = optind; i < argc; i++) { 219 int rc = add_interface_by_id(available_hid_interfaces, argv[i], 163 int i; 164 for (i = 1; i < argc; i++) { 165 rc = add_interface_by_id(available_hid_interfaces, argv[i], 220 166 &hid_dev); 221 167 if (rc != EOK) { … … 227 173 } 228 174 229 for (i nt i= 0; i < (int) hid_dev.descriptors->configuration->extra_count; i++) {175 for (i = 0; i < (int) hid_dev.descriptors->configuration->extra_count; i++) { 230 176 usb_log_debug("Found extra descriptor: %s.\n", 231 177 usb_debug_str_buffer( … … 235 181 } 236 182 237 const int rc = usbvirt_device_plug(&hid_dev, controller);183 rc = usbvirt_device_plug(&hid_dev, "/virt/usbhc/hc"); 238 184 if (rc != EOK) { 239 printf("Unable to start communication with VHCD `%s': %s.\n",240 controller,str_error(rc));185 printf("Unable to start communication with VHCD: %s.\n", 186 str_error(rc)); 241 187 return rc; 242 188 } 243 189 244 printf("Connected to VHCD `%s'...\n", controller);190 printf("Connected to VHCD...\n"); 245 191 246 192 wait_for_interfaces_death(&hid_dev);
Note:
See TracChangeset
for help on using the changeset viewer.