Changeset 777e336 in mainline
- Timestamp:
- 2011-04-12T15:59:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e7df6cd
- Parents:
- 1cbb4b7
- Location:
- uspace/drv/usbhid
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/subdrivers.c
r1cbb4b7 r777e336 37 37 #include "usb/classes/hidut.h" 38 38 39 static usb_hid_subdriver_usage_t path_kbd[] = {{USB_HIDUT_PAGE_KEYBOARD, 0}}; 39 static usb_hid_subdriver_usage_t path_kbd[] = { 40 {USB_HIDUT_PAGE_KEYBOARD, 0}, 41 {0, 0} 42 }; 40 43 41 44 const usb_hid_subdriver_mapping_t usb_hid_subdrivers[] = { 42 45 { 43 46 path_kbd, 44 1,45 47 USB_HID_PATH_COMPARE_END 46 48 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 47 NULL,48 NULL,49 0, 50 0, 49 51 { 50 usb_kbd_init,51 usb_kbd_deinit,52 usb_kbd_polling_callback,53 NULL52 .init = usb_kbd_init, 53 .deinit = usb_kbd_deinit, 54 .poll = usb_kbd_polling_callback, 55 .poll_end = NULL 54 56 }, 55 57 56 58 }, 57 {NULL, 0, 0, NULL, NULL, {NULL, NULL, NULL, NULL}}59 {NULL, 0, 0, 0, {NULL, NULL, NULL, NULL}} 58 60 }; 59 61 -
uspace/drv/usbhid/subdrivers.h
r1cbb4b7 r777e336 54 54 typedef struct usb_hid_subdriver_mapping { 55 55 const usb_hid_subdriver_usage_t *usage_path; 56 int path_size;57 56 int compare; 58 const char *vendor_id;59 const char *product_id;57 uint16_t vendor_id; 58 uint16_t product_id; 60 59 usb_hid_subdriver_t subdriver; 61 60 } usb_hid_subdriver_mapping_t; -
uspace/drv/usbhid/usbhid.c
r1cbb4b7 r777e336 164 164 165 165 static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev, 166 const usb_hid_subdriver_usage_t *path, int path_size, intcompare)166 const usb_hid_subdriver_usage_t *path, int compare) 167 167 { 168 168 assert(hid_dev != NULL); … … 174 174 return false; 175 175 } 176 int i ;177 for (i = 0; i < path_size; ++i) {176 int i = 0; 177 while (path[i].usage != 0 || path[i].usage_page != 0) { 178 178 if (usb_hid_report_path_append_item(usage_path, 179 179 path[i].usage_page, path[i].usage) != EOK) { … … 182 182 return false; 183 183 } 184 ++i; 184 185 } 185 186 … … 238 239 while (count < USB_HID_MAX_SUBDRIVERS && 239 240 (mapping->usage_path != NULL 240 || mapping->vendor_id != NULL 241 || mapping->product_id != NULL)) { 241 || mapping->vendor_id != 0 || mapping->product_id != 0)) { 242 242 // check the vendor & product ID 243 if (mapping->vendor_id != NULL && mapping->product_id == NULL) {244 usb_log_warning("Missing Product ID for Vendor ID % s\n",243 if (mapping->vendor_id != 0 && mapping->product_id == 0) { 244 usb_log_warning("Missing Product ID for Vendor ID %u\n", 245 245 mapping->vendor_id); 246 246 return EINVAL; 247 247 } 248 if (mapping->product_id != NULL && mapping->vendor_id == NULL) {249 usb_log_warning("Missing Vendor ID for Product ID % s\n",248 if (mapping->product_id != 0 && mapping->vendor_id == 0) { 249 usb_log_warning("Missing Vendor ID for Product ID %u\n", 250 250 mapping->product_id); 251 251 return EINVAL; 252 252 } 253 253 254 if (mapping->vendor_id != NULL) {255 assert(mapping->product_id != NULL);256 usb_log_debug("Comparing device against vendor ID % s"257 " and product ID % s.\n", mapping->vendor_id,254 if (mapping->vendor_id != 0) { 255 assert(mapping->product_id != 0); 256 usb_log_debug("Comparing device against vendor ID %u" 257 " and product ID %u.\n", mapping->vendor_id, 258 258 mapping->product_id); 259 259 if (usb_hid_ids_match(hid_dev, mapping)) { … … 268 268 usb_log_debug("Comparing device against usage path.\n"); 269 269 if (usb_hid_path_matches(hid_dev, 270 mapping->usage_path, mapping->path_size, 271 mapping->compare)) { 270 mapping->usage_path, mapping->compare)) { 272 271 subdrivers[count++] = &mapping->subdriver; 273 272 } else {
Note:
See TracChangeset
for help on using the changeset viewer.