[9d05599] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Matej Klonfar
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[160b75e] | 29 | /** @addtogroup libusbhid
|
---|
[9d05599] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * HID report descriptor and report data parser implementation.
|
---|
| 34 | */
|
---|
[faa44e58] | 35 | #include <usb/hid/hidparser.h>
|
---|
[9d05599] | 36 | #include <errno.h>
|
---|
| 37 | #include <stdio.h>
|
---|
| 38 | #include <malloc.h>
|
---|
| 39 | #include <mem.h>
|
---|
| 40 | #include <usb/debug.h>
|
---|
| 41 | #include <assert.h>
|
---|
| 42 |
|
---|
[5499a8b] | 43 | /*---------------------------------------------------------------------------*/
|
---|
| 44 | /**
|
---|
| 45 | * Compares two usages if they are same or not or one of the usages is not
|
---|
| 46 | * set.
|
---|
| 47 | *
|
---|
| 48 | * @param usage1
|
---|
| 49 | * @param usage2
|
---|
| 50 | * @return boolean
|
---|
| 51 | */
|
---|
| 52 | #define USB_HID_SAME_USAGE(usage1, usage2) \
|
---|
| 53 | ((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))
|
---|
[9d05599] | 54 |
|
---|
[5499a8b] | 55 | /**
|
---|
| 56 | * Compares two usage pages if they are same or not or one of them is not set.
|
---|
| 57 | *
|
---|
| 58 | * @param page1
|
---|
| 59 | * @param page2
|
---|
| 60 | * @return boolean
|
---|
| 61 | */
|
---|
| 62 | #define USB_HID_SAME_USAGE_PAGE(page1, page2) \
|
---|
| 63 | ((page1 == page2) || (page1 == 0) || (page2 == 0))
|
---|
[3a6e423] | 64 |
|
---|
[5499a8b] | 65 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 66 | /**
|
---|
| 67 | * Appends one item (couple of usage_path and usage) into the usage path
|
---|
| 68 | * structure
|
---|
| 69 | *
|
---|
| 70 | * @param usage_path Usage path structure
|
---|
| 71 | * @param usage_page Usage page constant
|
---|
| 72 | * @param usage Usage constant
|
---|
| 73 | * @return Error code
|
---|
| 74 | */
|
---|
| 75 | int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path,
|
---|
| 76 | int32_t usage_page, int32_t usage)
|
---|
| 77 | {
|
---|
[4bb7ffe] | 78 | usb_hid_report_usage_path_t *item
|
---|
| 79 | = malloc(sizeof(usb_hid_report_usage_path_t));
|
---|
[9d05599] | 80 |
|
---|
[4bb7ffe] | 81 | if (item == NULL) {
|
---|
[9d05599] | 82 | return ENOMEM;
|
---|
| 83 | }
|
---|
[b72efe8] | 84 | link_initialize(&item->rpath_items_link);
|
---|
[9d05599] | 85 |
|
---|
| 86 | item->usage = usage;
|
---|
| 87 | item->usage_page = usage_page;
|
---|
| 88 | item->flags = 0;
|
---|
| 89 |
|
---|
[b72efe8] | 90 | list_append (&item->rpath_items_link, &usage_path->items);
|
---|
[9d05599] | 91 | usage_path->depth++;
|
---|
| 92 | return EOK;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[5499a8b] | 95 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 96 | /**
|
---|
| 97 | * Removes last item from the usage path structure
|
---|
| 98 | * @param usage_path
|
---|
| 99 | * @return void
|
---|
| 100 | */
|
---|
| 101 | void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path)
|
---|
| 102 | {
|
---|
[b72efe8] | 103 | link_t *item_link;
|
---|
[9d05599] | 104 | usb_hid_report_usage_path_t *item;
|
---|
| 105 |
|
---|
[b72efe8] | 106 | if(!list_empty(&usage_path->items)){
|
---|
| 107 | item_link = list_last(&usage_path->items);
|
---|
| 108 | item = list_get_instance(item_link,
|
---|
| 109 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
| 110 | list_remove(item_link);
|
---|
[9d05599] | 111 | usage_path->depth--;
|
---|
| 112 | free(item);
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[5499a8b] | 116 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 117 | /**
|
---|
| 118 | * Nulls last item of the usage path structure.
|
---|
| 119 | *
|
---|
| 120 | * @param usage_path
|
---|
| 121 | * @return void
|
---|
| 122 | */
|
---|
| 123 | void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path)
|
---|
| 124 | {
|
---|
| 125 | usb_hid_report_usage_path_t *item;
|
---|
| 126 |
|
---|
[b72efe8] | 127 | if(!list_empty(&usage_path->items)){
|
---|
| 128 | item = list_get_instance(list_last(&usage_path->items),
|
---|
| 129 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[5499a8b] | 130 |
|
---|
[9d05599] | 131 | memset(item, 0, sizeof(usb_hid_report_usage_path_t));
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 |
|
---|
[5499a8b] | 135 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 136 | /**
|
---|
| 137 | * Modifies last item of usage path structure by given usage page or usage
|
---|
| 138 | *
|
---|
| 139 | * @param usage_path Opaque usage path structure
|
---|
| 140 | * @param tag Class of currently processed tag (Usage page tag falls into Global
|
---|
| 141 | * class but Usage tag into the Local)
|
---|
| 142 | * @param data Value of the processed tag
|
---|
| 143 | * @return void
|
---|
| 144 | */
|
---|
| 145 | void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path,
|
---|
| 146 | int32_t tag, int32_t data)
|
---|
| 147 | {
|
---|
| 148 | usb_hid_report_usage_path_t *item;
|
---|
| 149 |
|
---|
[b72efe8] | 150 | if(!list_empty(&usage_path->items)){
|
---|
| 151 | item = list_get_instance(list_last(&usage_path->items),
|
---|
| 152 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[9d05599] | 153 |
|
---|
| 154 | switch(tag) {
|
---|
| 155 | case USB_HID_TAG_CLASS_GLOBAL:
|
---|
| 156 | item->usage_page = data;
|
---|
| 157 | break;
|
---|
| 158 | case USB_HID_TAG_CLASS_LOCAL:
|
---|
| 159 | item->usage = data;
|
---|
| 160 | break;
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | }
|
---|
| 165 |
|
---|
[5499a8b] | 166 | /*---------------------------------------------------------------------------*/
|
---|
| 167 | /**
|
---|
| 168 | *
|
---|
| 169 | *
|
---|
| 170 | *
|
---|
| 171 | *
|
---|
| 172 | */
|
---|
[9d05599] | 173 | void usb_hid_print_usage_path(usb_hid_report_path_t *path)
|
---|
| 174 | {
|
---|
| 175 | usb_log_debug("USAGE_PATH FOR RId(%d):\n", path->report_id);
|
---|
| 176 | usb_log_debug("\tLENGTH: %d\n", path->depth);
|
---|
| 177 |
|
---|
| 178 | usb_hid_report_usage_path_t *path_item;
|
---|
| 179 |
|
---|
[b72efe8] | 180 | list_foreach(path->items, item) {
|
---|
| 181 | path_item = list_get_instance(item, usb_hid_report_usage_path_t,
|
---|
| 182 | rpath_items_link);
|
---|
[5499a8b] | 183 |
|
---|
[9d05599] | 184 | usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
|
---|
| 185 | usb_log_debug("\tUSAGE: %X\n", path_item->usage);
|
---|
[b72efe8] | 186 | usb_log_debug("\tFLAGS: %d\n", path_item->flags);
|
---|
[9d05599] | 187 | }
|
---|
| 188 | }
|
---|
| 189 |
|
---|
[5499a8b] | 190 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 191 | /**
|
---|
| 192 | * Compares two usage paths structures
|
---|
| 193 | *
|
---|
| 194 | *
|
---|
[5f7b75a] | 195 | * @param report_path usage path structure to compare with @path
|
---|
[9d05599] | 196 | * @param path usage patrh structure to compare
|
---|
| 197 | * @param flags Flags determining the mode of comparison
|
---|
| 198 | * @return EOK if both paths are identical, non zero number otherwise
|
---|
| 199 | */
|
---|
| 200 | int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path,
|
---|
| 201 | usb_hid_report_path_t *path,
|
---|
| 202 | int flags)
|
---|
| 203 | {
|
---|
| 204 | usb_hid_report_usage_path_t *report_item;
|
---|
| 205 | usb_hid_report_usage_path_t *path_item;
|
---|
| 206 |
|
---|
| 207 | link_t *report_link;
|
---|
| 208 | link_t *path_link;
|
---|
| 209 |
|
---|
| 210 | int only_page;
|
---|
| 211 |
|
---|
| 212 | if(report_path->report_id != path->report_id) {
|
---|
[dcb7d7cd] | 213 | if(path->report_id != 0) {
|
---|
| 214 | return 1;
|
---|
| 215 | }
|
---|
[9d05599] | 216 | }
|
---|
| 217 |
|
---|
[5f7b75a] | 218 | // Empty path match all others
|
---|
[9d05599] | 219 | if(path->depth == 0){
|
---|
| 220 | return EOK;
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 |
|
---|
| 224 | if((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0){
|
---|
| 225 | flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY;
|
---|
| 226 | }
|
---|
| 227 |
|
---|
| 228 | switch(flags){
|
---|
[f3b39b4] | 229 | /* path is somewhere in report_path */
|
---|
| 230 | case USB_HID_PATH_COMPARE_ANYWHERE:
|
---|
| 231 | if(path->depth != 1){
|
---|
| 232 | return 1;
|
---|
| 233 | }
|
---|
[5f7b75a] | 234 |
|
---|
[b72efe8] | 235 | path_link = list_first(&path->items);
|
---|
| 236 | path_item = list_get_instance(path_link,
|
---|
| 237 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[5f7b75a] | 238 |
|
---|
[b72efe8] | 239 | list_foreach(report_path->items, report_link) {
|
---|
| 240 | report_item = list_get_instance(report_link,
|
---|
| 241 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[5499a8b] | 242 |
|
---|
[b72efe8] | 243 | if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
|
---|
[f3b39b4] | 244 | path_item->usage_page)){
|
---|
[5499a8b] | 245 |
|
---|
[f3b39b4] | 246 | if(only_page == 0){
|
---|
| 247 | if(USB_HID_SAME_USAGE(
|
---|
| 248 | report_item->usage,
|
---|
| 249 | path_item->usage)) {
|
---|
[5499a8b] | 250 |
|
---|
[5f7b75a] | 251 | return EOK;
|
---|
| 252 | }
|
---|
| 253 | }
|
---|
[f3b39b4] | 254 | else {
|
---|
| 255 | return EOK;
|
---|
| 256 | }
|
---|
[5f7b75a] | 257 | }
|
---|
[f3b39b4] | 258 | }
|
---|
| 259 |
|
---|
| 260 | return 1;
|
---|
| 261 | break;
|
---|
| 262 |
|
---|
| 263 | /* the paths must be identical */
|
---|
| 264 | case USB_HID_PATH_COMPARE_STRICT:
|
---|
| 265 | if(report_path->depth != path->depth){
|
---|
[5f7b75a] | 266 | return 1;
|
---|
[f3b39b4] | 267 | }
|
---|
[5f7b75a] | 268 |
|
---|
[f3b39b4] | 269 | /* path is prefix of the report_path */
|
---|
| 270 | case USB_HID_PATH_COMPARE_BEGIN:
|
---|
[5f7b75a] | 271 |
|
---|
[b72efe8] | 272 | report_link = report_path->items.head.next;
|
---|
| 273 | path_link = path->items.head.next;
|
---|
[9d05599] | 274 |
|
---|
[b72efe8] | 275 | while((report_link != &report_path->items.head) &&
|
---|
| 276 | (path_link != &path->items.head)) {
|
---|
[f3b39b4] | 277 |
|
---|
| 278 | report_item = list_get_instance(report_link,
|
---|
[b72efe8] | 279 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[f3b39b4] | 280 |
|
---|
| 281 | path_item = list_get_instance(path_link,
|
---|
[b72efe8] | 282 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[f3b39b4] | 283 |
|
---|
| 284 | if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
|
---|
| 285 | path_item->usage_page) || ((only_page == 0) &&
|
---|
| 286 | !USB_HID_SAME_USAGE(report_item->usage,
|
---|
| 287 | path_item->usage))) {
|
---|
| 288 |
|
---|
| 289 | return 1;
|
---|
| 290 | }
|
---|
| 291 | else {
|
---|
| 292 | report_link = report_link->next;
|
---|
| 293 | path_link = path_link->next;
|
---|
| 294 | }
|
---|
[9d05599] | 295 |
|
---|
[b72efe8] | 296 | }
|
---|
[9d05599] | 297 |
|
---|
[f3b39b4] | 298 | if((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
|
---|
[b72efe8] | 299 | (path_link == &path->items.head)) ||
|
---|
| 300 | ((report_link == &report_path->items.head) &&
|
---|
| 301 | (path_link == &path->items.head))) {
|
---|
[f3b39b4] | 302 |
|
---|
| 303 | return EOK;
|
---|
| 304 | }
|
---|
| 305 | else {
|
---|
| 306 | return 1;
|
---|
| 307 | }
|
---|
| 308 | break;
|
---|
[9d05599] | 309 |
|
---|
[f3b39b4] | 310 | /* path is suffix of report_path */
|
---|
| 311 | case USB_HID_PATH_COMPARE_END:
|
---|
[9d05599] | 312 |
|
---|
[b72efe8] | 313 | report_link = report_path->items.head.prev;
|
---|
| 314 | path_link = path->items.head.prev;
|
---|
[9d05599] | 315 |
|
---|
[b72efe8] | 316 | if(list_empty(&path->items)){
|
---|
[f3b39b4] | 317 | return EOK;
|
---|
| 318 | }
|
---|
[9d05599] | 319 |
|
---|
[b72efe8] | 320 | while((report_link != &report_path->items.head) &&
|
---|
| 321 | (path_link != &path->items.head)) {
|
---|
[9d05599] | 322 |
|
---|
[b72efe8] | 323 | report_item = list_get_instance(report_link,
|
---|
| 324 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[5499a8b] | 325 |
|
---|
[f3b39b4] | 326 | path_item = list_get_instance(path_link,
|
---|
[b72efe8] | 327 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[3a6e423] | 328 |
|
---|
[f3b39b4] | 329 | if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
|
---|
| 330 | path_item->usage_page) || ((only_page == 0) &&
|
---|
| 331 | !USB_HID_SAME_USAGE(report_item->usage,
|
---|
| 332 | path_item->usage))) {
|
---|
[5499a8b] | 333 |
|
---|
[9d05599] | 334 | return 1;
|
---|
[f3b39b4] | 335 | } else {
|
---|
| 336 | report_link = report_link->prev;
|
---|
| 337 | path_link = path_link->prev;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | }
|
---|
| 341 |
|
---|
[b72efe8] | 342 | if(path_link == &path->items.head) {
|
---|
[f3b39b4] | 343 | return EOK;
|
---|
| 344 | }
|
---|
| 345 | else {
|
---|
| 346 | return 1;
|
---|
| 347 | }
|
---|
[9d05599] | 348 |
|
---|
[f3b39b4] | 349 | break;
|
---|
[9d05599] | 350 |
|
---|
[f3b39b4] | 351 | default:
|
---|
| 352 | return EINVAL;
|
---|
[9d05599] | 353 | }
|
---|
| 354 | }
|
---|
| 355 |
|
---|
[5499a8b] | 356 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 357 | /**
|
---|
| 358 | * Allocates and initializes new usage path structure.
|
---|
| 359 | *
|
---|
| 360 | * @return Initialized usage path structure
|
---|
| 361 | */
|
---|
| 362 | usb_hid_report_path_t *usb_hid_report_path(void)
|
---|
| 363 | {
|
---|
| 364 | usb_hid_report_path_t *path;
|
---|
| 365 | path = malloc(sizeof(usb_hid_report_path_t));
|
---|
| 366 | if(path == NULL){
|
---|
| 367 | return NULL;
|
---|
| 368 | }
|
---|
| 369 | else {
|
---|
| 370 | path->depth = 0;
|
---|
| 371 | path->report_id = 0;
|
---|
[b72efe8] | 372 | link_initialize(&path->cpath_link);
|
---|
| 373 | list_initialize(&path->items);
|
---|
[9d05599] | 374 | return path;
|
---|
| 375 | }
|
---|
| 376 | }
|
---|
| 377 |
|
---|
[5499a8b] | 378 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 379 | /**
|
---|
| 380 | * Releases given usage path structure.
|
---|
| 381 | *
|
---|
| 382 | * @param path usage path structure to release
|
---|
| 383 | * @return void
|
---|
| 384 | */
|
---|
| 385 | void usb_hid_report_path_free(usb_hid_report_path_t *path)
|
---|
| 386 | {
|
---|
[b72efe8] | 387 | while(!list_empty(&path->items)){
|
---|
[9d05599] | 388 | usb_hid_report_remove_last_item(path);
|
---|
| 389 | }
|
---|
| 390 |
|
---|
[b72efe8] | 391 | assert_link_not_used(&path->cpath_link);
|
---|
[9d05599] | 392 | free(path);
|
---|
| 393 | }
|
---|
| 394 |
|
---|
[5499a8b] | 395 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 396 | /**
|
---|
| 397 | * Clone content of given usage path to the new one
|
---|
| 398 | *
|
---|
| 399 | * @param usage_path Usage path structure to clone
|
---|
| 400 | * @return New copy of given usage path structure
|
---|
| 401 | */
|
---|
[5499a8b] | 402 | usb_hid_report_path_t *usb_hid_report_path_clone(
|
---|
| 403 | usb_hid_report_path_t *usage_path)
|
---|
[9d05599] | 404 | {
|
---|
| 405 | usb_hid_report_usage_path_t *path_item;
|
---|
| 406 | usb_hid_report_usage_path_t *new_path_item;
|
---|
| 407 | usb_hid_report_path_t *new_usage_path = usb_hid_report_path ();
|
---|
| 408 |
|
---|
| 409 | if(new_usage_path == NULL){
|
---|
| 410 | return NULL;
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | new_usage_path->report_id = usage_path->report_id;
|
---|
| 414 |
|
---|
[b72efe8] | 415 | if(list_empty(&usage_path->items)){
|
---|
[9d05599] | 416 | return new_usage_path;
|
---|
| 417 | }
|
---|
| 418 |
|
---|
[b72efe8] | 419 | list_foreach(usage_path->items, path_link) {
|
---|
| 420 | path_item = list_get_instance(path_link,
|
---|
| 421 | usb_hid_report_usage_path_t, rpath_items_link);
|
---|
[f3b39b4] | 422 |
|
---|
[9d05599] | 423 | new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
|
---|
| 424 | if(new_path_item == NULL) {
|
---|
| 425 | return NULL;
|
---|
| 426 | }
|
---|
| 427 |
|
---|
[b72efe8] | 428 | link_initialize(&new_path_item->rpath_items_link);
|
---|
[9d05599] | 429 | new_path_item->usage_page = path_item->usage_page;
|
---|
| 430 | new_path_item->usage = path_item->usage;
|
---|
| 431 | new_path_item->flags = path_item->flags;
|
---|
| 432 |
|
---|
[b72efe8] | 433 | list_append(&new_path_item->rpath_items_link,
|
---|
| 434 | &new_usage_path->items);
|
---|
[9d05599] | 435 | new_usage_path->depth++;
|
---|
| 436 | }
|
---|
| 437 |
|
---|
| 438 | return new_usage_path;
|
---|
| 439 | }
|
---|
| 440 |
|
---|
[5499a8b] | 441 | /*---------------------------------------------------------------------------*/
|
---|
[9d05599] | 442 | /**
|
---|
| 443 | * Sets report id in usage path structure
|
---|
| 444 | *
|
---|
| 445 | * @param path Usage path structure
|
---|
| 446 | * @param report_id Report id to set
|
---|
| 447 | * @return Error code
|
---|
| 448 | */
|
---|
[5499a8b] | 449 | int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path,
|
---|
| 450 | uint8_t report_id)
|
---|
[9d05599] | 451 | {
|
---|
| 452 | if(path == NULL){
|
---|
| 453 | return EINVAL;
|
---|
| 454 | }
|
---|
| 455 |
|
---|
| 456 | path->report_id = report_id;
|
---|
| 457 | return EOK;
|
---|
| 458 | }
|
---|
| 459 |
|
---|
| 460 | /**
|
---|
| 461 | * @}
|
---|
| 462 | */
|
---|