Changeset e141281 in mainline for uspace/lib/usbhid/src/hidpath.c
- Timestamp:
- 2017-05-04T22:17:36Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31a30fa
- Parents:
- dc12262
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidpath.c
rdc12262 re141281 185 185 } 186 186 187 188 /** 189 * Compares two usage paths structures 190 * 191 * 192 * @param report_path usage path structure to compare with @path 193 * @param path usage patrh structure to compare 194 * @param flags Flags determining the mode of comparison 187 /** Compare two usage paths structures 188 * 189 * @param report_path Usage path structure to compare with @path 190 * @param path Usage patrh structure to compare 191 * @param flags Flags determining the mode of comparison 192 * 195 193 * @return EOK if both paths are identical, non zero number otherwise 196 * /197 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 198 usb_hid_report_path_t *path,199 194 * 195 */ 196 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 197 usb_hid_report_path_t *path, int flags) 200 198 { 201 199 usb_hid_report_usage_path_t *report_item; 202 200 usb_hid_report_usage_path_t *path_item; 203 201 204 202 link_t *report_link; 205 203 link_t *path_link; 206 204 207 205 int only_page; 208 209 if (report_path->report_id != path->report_id) {210 if (path->report_id != 0) {206 207 if (report_path->report_id != path->report_id) { 208 if (path->report_id != 0) { 211 209 return 1; 212 210 } 213 211 } 214 212 215 213 // Empty path match all others 216 if (path->depth == 0){214 if (path->depth == 0) { 217 215 return EOK; 218 216 } 219 220 221 if((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0){ 217 218 if ((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0) { 222 219 flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY; 223 220 } 224 221 225 switch (flags){226 /* path is somewhere in report_path */222 switch (flags) { 223 /* Path is somewhere in report_path */ 227 224 case USB_HID_PATH_COMPARE_ANYWHERE: 228 if (path->depth != 1){225 if (path->depth != 1) { 229 226 return 1; 230 227 } 231 228 232 229 path_link = list_first(&path->items); 233 230 path_item = list_get_instance(path_link, 234 235 231 usb_hid_report_usage_path_t, rpath_items_link); 232 236 233 list_foreach(report_path->items, rpath_items_link, 237 234 usb_hid_report_usage_path_t, report_item) { 238 239 235 if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 240 236 path_item->usage_page)) { 241 237 242 238 if (only_page == 0) { … … 244 240 path_item->usage)) 245 241 return EOK; 246 } 247 else { 242 } else { 248 243 return EOK; 249 244 } 250 245 } 251 246 } 252 247 253 248 return 1; 254 249 break; 255 256 /* the paths must be identical */250 251 /* The paths must be identical */ 257 252 case USB_HID_PATH_COMPARE_STRICT: 258 if (report_path->depth != path->depth){253 if (report_path->depth != path->depth) { 259 254 return 1; 260 255 } 261 256 /* Fallthrough */ 262 263 /* path is prefix of the report_path */257 258 /* Path is prefix of the report_path */ 264 259 case USB_HID_PATH_COMPARE_BEGIN: 265 266 260 report_link = report_path->items.head.next; 267 261 path_link = path->items.head.next; … … 270 264 (path_link != &path->items.head)) { 271 265 272 report_item = list_get_instance(report_link, 266 report_item = list_get_instance(report_link, 273 267 usb_hid_report_usage_path_t, rpath_items_link); 274 268 275 269 path_item = list_get_instance(path_link, 276 277 278 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 279 path_item->usage_page) || ((only_page == 0) && 280 !USB_HID_SAME_USAGE(report_item->usage, 270 usb_hid_report_usage_path_t, rpath_items_link); 271 272 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 273 path_item->usage_page) || ((only_page == 0) && 274 !USB_HID_SAME_USAGE(report_item->usage, 281 275 path_item->usage))) { 282 276 return 1; … … 286 280 } 287 281 } 288 289 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 290 (path_link == &path->items.head)) || 291 ((report_link == &report_path->items.head) && 282 283 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 284 (path_link == &path->items.head)) || 285 ((report_link == &report_path->items.head) && 292 286 (path_link == &path->items.head))) { 293 287 return EOK; … … 296 290 } 297 291 break; 298 299 /* path is suffix of report_path */292 293 /* Path is suffix of report_path */ 300 294 case USB_HID_PATH_COMPARE_END: 301 302 295 report_link = report_path->items.head.prev; 303 296 path_link = path->items.head.prev; 304 305 if (list_empty(&path->items)){297 298 if (list_empty(&path->items)) { 306 299 return EOK; 307 300 } 301 302 while ((report_link != &report_path->items.head) && 303 (path_link != &path->items.head)) { 304 report_item = list_get_instance(report_link, 305 usb_hid_report_usage_path_t, rpath_items_link); 308 306 309 while((report_link != &report_path->items.head) && 310 (path_link != &path->items.head)) { 311 312 report_item = list_get_instance(report_link, 313 usb_hid_report_usage_path_t, rpath_items_link); 314 315 path_item = list_get_instance(path_link, 316 usb_hid_report_usage_path_t, rpath_items_link); 317 318 if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 319 path_item->usage_page) || ((only_page == 0) && 320 !USB_HID_SAME_USAGE(report_item->usage, 321 path_item->usage))) { 322 323 return 1; 307 path_item = list_get_instance(path_link, 308 usb_hid_report_usage_path_t, rpath_items_link); 309 310 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 311 path_item->usage_page) || ((only_page == 0) && 312 !USB_HID_SAME_USAGE(report_item->usage, 313 path_item->usage))) { 314 return 1; 324 315 } else { 325 316 report_link = report_link->prev; 326 path_link = path_link->prev; 317 path_link = path_link->prev; 327 318 } 328 329 } 330 331 if(path_link == &path->items.head) { 319 } 320 321 if (path_link == &path->items.head) { 332 322 return EOK; 333 } 334 else { 323 } else { 335 324 return 1; 336 } 337 325 } 338 326 break; 339 327 340 328 default: 341 329 return EINVAL; 342 330 } 343 331 } 344 345 332 346 333 /**
Note:
See TracChangeset
for help on using the changeset viewer.