The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Use new xdev providing binding

+224 -961
+5 -55
src/xrt/state_trackers/oxr/oxr_binding.c
··· 41 41 } 42 42 } 43 43 44 - static void 45 - setup_inputs(struct oxr_logger *log, 46 - struct oxr_instance *inst, 47 - struct binding_template *templ, 48 - struct oxr_binding *binding) 49 - { 50 - size_t count = 0; 51 - while (templ->inputs[count] != 0) { 52 - count++; 53 - } 54 - 55 - if (count == 0) { 56 - return; 57 - } 58 - 59 - binding->num_inputs = count; 60 - binding->inputs = U_TYPED_ARRAY_CALLOC(enum xrt_input_name, count); 61 - 62 - for (size_t x = 0; x < binding->num_inputs; x++) { 63 - binding->inputs[x] = templ->inputs[x]; 64 - } 65 - } 66 - 67 - static void 68 - setup_outputs(struct oxr_logger *log, 69 - struct oxr_instance *inst, 70 - struct binding_template *templ, 71 - struct oxr_binding *binding) 72 - { 73 - size_t count = 0; 74 - while (templ->outputs[count] != 0) { 75 - count++; 76 - } 77 - 78 - if (count == 0) { 79 - return; 80 - } 81 - 82 - binding->num_outputs = count; 83 - binding->outputs = U_TYPED_ARRAY_CALLOC(enum xrt_output_name, count); 84 - 85 - for (size_t x = 0; x < binding->num_outputs; x++) { 86 - binding->outputs[x] = templ->outputs[x]; 87 - } 88 - } 89 - 90 44 static bool 91 45 interaction_profile_find(struct oxr_logger *log, 92 46 struct oxr_instance *inst, ··· 137 91 struct oxr_interaction_profile *p = 138 92 U_TYPED_CALLOC(struct oxr_interaction_profile); 139 93 94 + p->xname = templ->name; 140 95 p->num_bindings = templ->num_bindings; 141 96 p->bindings = U_TYPED_ARRAY_CALLOC(struct oxr_binding, p->num_bindings); 142 97 p->path = path; ··· 149 104 b->sub_path = t->sub_path; 150 105 b->localized_name = t->localized_name; 151 106 setup_paths(log, inst, t, b); 152 - setup_inputs(log, inst, t, b); 153 - setup_outputs(log, inst, t, b); 107 + b->input = t->input; 108 + b->output = t->output; 154 109 } 155 110 156 111 // Add to the list of currently created interaction profiles. ··· 422 377 423 378 reset_binding_keys(b); 424 379 free(b->paths); 425 - free(b->inputs); 426 - free(b->outputs); 427 - 428 380 b->paths = NULL; 429 - b->inputs = NULL; 430 - b->outputs = NULL; 431 381 b->num_paths = 0; 432 - b->num_inputs = 0; 433 - b->num_outputs = 0; 382 + b->input = 0; 383 + b->output = 0; 434 384 } 435 385 436 386 free(p->bindings);
+85 -862
src/xrt/state_trackers/oxr/oxr_binding_data.h
··· 7 7 * @ingroup oxr_main 8 8 */ 9 9 10 - // #include "xrt/xrt_compiler.h" 11 - 12 10 #include "oxr_objects.h" 13 11 14 12 ··· 19 17 const char *localized_name; 20 18 21 19 const char *paths[8]; 22 - enum xrt_input_name inputs[8]; 23 - enum xrt_output_name outputs[8]; 20 + enum xrt_input_name input; 21 + enum xrt_output_name output; 24 22 }; 25 23 26 24 struct profile_template 27 25 { 26 + enum xrt_device_name name; 27 + 28 28 const char *path; 29 29 30 30 const char *localized_name; ··· 33 33 size_t num_bindings; 34 34 }; 35 35 36 - /* 37 - * 38 - * Shipped bindings. 39 - * 40 - */ 41 36 42 37 /* 43 38 * 44 - * 45 - * 46 - * KHR Simple Controller 47 - * 48 - * 49 - * 50 - */ 51 - 52 - static struct binding_template khr_simple_controller_bindings[10] = { 53 - { 54 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 55 - .localized_name = "Select", 56 - .paths = 57 - { 58 - "/user/hand/left/input/select/click", 59 - "/user/hand/left/input/select", 60 - NULL, 61 - }, 62 - .inputs = 63 - { 64 - XRT_INPUT_SIMPLE_SELECT_CLICK, 65 - XRT_INPUT_PSMV_TRIGGER_VALUE, 66 - XRT_INPUT_HYDRA_TRIGGER_VALUE, 67 - XRT_INPUT_DAYDREAM_TOUCHPAD_CLICK, 68 - XRT_INPUT_INDEX_TRIGGER_VALUE, 69 - XRT_INPUT_VIVE_TRIGGER_VALUE, 70 - (enum xrt_input_name)0, 71 - }, 72 - }, 73 - { 74 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 75 - .localized_name = "Menu", 76 - .paths = 77 - { 78 - "/user/hand/left/input/menu/click", 79 - "/user/hand/left/input/menu", 80 - NULL, 81 - }, 82 - .inputs = 83 - { 84 - XRT_INPUT_SIMPLE_MENU_CLICK, 85 - XRT_INPUT_PSMV_MOVE_CLICK, 86 - XRT_INPUT_HYDRA_MIDDLE_CLICK, 87 - XRT_INPUT_DAYDREAM_BAR_CLICK, 88 - XRT_INPUT_INDEX_B_CLICK, 89 - XRT_INPUT_VIVE_MENU_CLICK, 90 - (enum xrt_input_name)0, 91 - }, 92 - }, 93 - { 94 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 95 - .localized_name = "Grip", 96 - .paths = 97 - { 98 - "/user/hand/left/input/grip/pose", 99 - "/user/hand/left/input/grip", 100 - NULL, 101 - }, 102 - .inputs = 103 - { 104 - XRT_INPUT_SIMPLE_GRIP_POSE, 105 - XRT_INPUT_PSMV_GRIP_POSE, 106 - XRT_INPUT_HYDRA_POSE, 107 - XRT_INPUT_DAYDREAM_POSE, 108 - XRT_INPUT_INDEX_GRIP_POSE, 109 - XRT_INPUT_VIVE_GRIP_POSE, 110 - (enum xrt_input_name)0, 111 - }, 112 - }, 113 - { 114 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 115 - .localized_name = "Aim", 116 - .paths = 117 - { 118 - "/user/hand/left/input/aim/pose", 119 - "/user/hand/left/input/aim", 120 - NULL, 121 - }, 122 - .inputs = 123 - { 124 - XRT_INPUT_SIMPLE_AIM_POSE, 125 - XRT_INPUT_PSMV_AIM_POSE, 126 - XRT_INPUT_HYDRA_POSE, 127 - XRT_INPUT_DAYDREAM_POSE, 128 - XRT_INPUT_INDEX_AIM_POSE, 129 - XRT_INPUT_VIVE_AIM_POSE, 130 - (enum xrt_input_name)0, 131 - }, 132 - }, 133 - { 134 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 135 - .localized_name = "Haptic", 136 - .paths = 137 - { 138 - "/user/hand/left/output/haptic", 139 - NULL, 140 - }, 141 - .outputs = 142 - { 143 - XRT_OUTPUT_NAME_SIMPLE_VIBRATION, 144 - XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION, 145 - XRT_OUTPUT_NAME_INDEX_HAPTIC, 146 - XRT_OUTPUT_NAME_VIVE_HAPTIC, 147 - (enum xrt_output_name)0, 148 - }, 149 - }, 150 - { 151 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 152 - .localized_name = "Select", 153 - .paths = 154 - { 155 - "/user/hand/right/input/select/click", 156 - "/user/hand/right/input/select", 157 - NULL, 158 - }, 159 - .inputs = 160 - { 161 - XRT_INPUT_SIMPLE_SELECT_CLICK, 162 - XRT_INPUT_PSMV_TRIGGER_VALUE, 163 - XRT_INPUT_HYDRA_TRIGGER_VALUE, 164 - XRT_INPUT_DAYDREAM_TOUCHPAD_CLICK, 165 - XRT_INPUT_INDEX_TRIGGER_VALUE, 166 - XRT_INPUT_VIVE_TRIGGER_VALUE, 167 - (enum xrt_input_name)0, 168 - }, 169 - }, 170 - { 171 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 172 - .localized_name = "Menu", 173 - .paths = 174 - { 175 - "/user/hand/right/input/menu/click", 176 - "/user/hand/right/input/menu", 177 - NULL, 178 - }, 179 - .inputs = 180 - { 181 - XRT_INPUT_SIMPLE_MENU_CLICK, 182 - XRT_INPUT_PSMV_MOVE_CLICK, 183 - XRT_INPUT_HYDRA_MIDDLE_CLICK, 184 - XRT_INPUT_DAYDREAM_BAR_CLICK, 185 - XRT_INPUT_INDEX_B_CLICK, 186 - XRT_INPUT_VIVE_MENU_CLICK, 187 - (enum xrt_input_name)0, 188 - }, 189 - }, 190 - { 191 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 192 - .localized_name = "Grip", 193 - .paths = 194 - { 195 - "/user/hand/right/input/grip/pose", 196 - "/user/hand/right/input/grip", 197 - NULL, 198 - }, 199 - .inputs = 200 - { 201 - XRT_INPUT_SIMPLE_GRIP_POSE, 202 - XRT_INPUT_PSMV_GRIP_POSE, 203 - XRT_INPUT_HYDRA_POSE, 204 - XRT_INPUT_DAYDREAM_POSE, 205 - XRT_INPUT_INDEX_GRIP_POSE, 206 - XRT_INPUT_VIVE_GRIP_POSE, 207 - (enum xrt_input_name)0, 208 - }, 209 - }, 210 - { 211 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 212 - .localized_name = "Aim", 213 - .paths = 214 - { 215 - "/user/hand/right/input/aim/pose", 216 - "/user/hand/right/input/aim", 217 - NULL, 218 - }, 219 - .inputs = 220 - { 221 - XRT_INPUT_SIMPLE_AIM_POSE, 222 - XRT_INPUT_PSMV_AIM_POSE, 223 - XRT_INPUT_HYDRA_POSE, 224 - XRT_INPUT_DAYDREAM_POSE, 225 - XRT_INPUT_INDEX_AIM_POSE, 226 - XRT_INPUT_VIVE_AIM_POSE, 227 - (enum xrt_input_name)0, 228 - }, 229 - }, 230 - { 231 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 232 - .localized_name = "Haptic", 233 - .paths = 234 - { 235 - "/user/hand/right/output/haptic", 236 - NULL, 237 - }, 238 - .outputs = 239 - { 240 - XRT_OUTPUT_NAME_SIMPLE_VIBRATION, 241 - XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION, 242 - XRT_OUTPUT_NAME_INDEX_HAPTIC, 243 - XRT_OUTPUT_NAME_VIVE_HAPTIC, 244 - (enum xrt_output_name)0, 245 - }, 246 - }, 247 - }; 248 - 249 - 250 - /* 251 - * 252 - * 253 - * 254 - * Google Daydream Controller 255 - * 256 - * 257 - * 258 - */ 259 - 260 - static struct binding_template google_daydream_controller_bindings[12] = { 261 - { 262 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 263 - .localized_name = "Select", 264 - .paths = 265 - { 266 - "/user/hand/left/input/select/click", 267 - "/user/hand/left/input/select", 268 - NULL, 269 - }, 270 - .inputs = 271 - { 272 - #if 0 273 - XRT_INPUT_PSMV_TRIGGER_VALUE, 274 - XRT_INPUT_HYDRA_TRIGGER_VALUE, 275 - #endif 276 - (enum xrt_input_name)0, 277 - }, 278 - }, 279 - { 280 - //! @todo Flag that this is a trackpad 281 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 282 - .localized_name = "Trackpad", 283 - .paths = 284 - { 285 - "/user/hand/left/input/trackpad", 286 - "/user/hand/left/input/trackpad/x", 287 - "/user/hand/left/input/trackpad/y", 288 - NULL, 289 - }, 290 - .inputs = 291 - { 292 - (enum xrt_input_name)0, 293 - }, 294 - }, 295 - { 296 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 297 - .localized_name = "Trackpad Click", 298 - .paths = 299 - { 300 - "/user/hand/left/input/trackpad/click", 301 - "/user/hand/left/input/trackpad", 302 - NULL, 303 - }, 304 - .inputs = 305 - { 306 - (enum xrt_input_name)0, 307 - }, 308 - }, 309 - { 310 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 311 - .localized_name = "Trackpad Touch", 312 - .paths = 313 - { 314 - "/user/hand/left/input/trackpad/touch", 315 - NULL, 316 - }, 317 - .inputs = 318 - { 319 - (enum xrt_input_name)0, 320 - }, 321 - }, 322 - { 323 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 324 - .localized_name = "Grip", 325 - .paths = 326 - { 327 - "/user/hand/left/input/grip/pose", 328 - "/user/hand/left/input/grip", 329 - NULL, 330 - }, 331 - .inputs = 332 - { 333 - #if 0 334 - XRT_INPUT_PSMV_GRIP_POSE, 335 - XRT_INPUT_HYDRA_POSE, 336 - #endif 337 - (enum xrt_input_name)0, 338 - }, 339 - }, 340 - { 341 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 342 - .localized_name = "Aim", 343 - .paths = 344 - { 345 - "/user/hand/left/input/aim/pose", 346 - "/user/hand/left/input/aim", 347 - NULL, 348 - }, 349 - .inputs = 350 - { 351 - #if 0 352 - XRT_INPUT_PSMV_AIM_POSE, 353 - XRT_INPUT_HYDRA_POSE, 354 - #endif 355 - (enum xrt_input_name)0, 356 - }, 357 - }, 358 - { 359 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 360 - .localized_name = "Select", 361 - .paths = 362 - { 363 - "/user/hand/right/input/select/click", 364 - "/user/hand/right/input/select", 365 - NULL, 366 - }, 367 - .inputs = 368 - { 369 - #if 0 370 - XRT_INPUT_PSMV_TRIGGER_VALUE, 371 - XRT_INPUT_HYDRA_TRIGGER_VALUE, 372 - #endif 373 - (enum xrt_input_name)0, 374 - }, 375 - }, 376 - { 377 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 378 - .localized_name = "Trackpad", 379 - .paths = 380 - { 381 - "/user/hand/right/input/trackpad", 382 - "/user/hand/right/input/trackpad/x", 383 - "/user/hand/right/input/trackpad/y", 384 - NULL, 385 - }, 386 - .inputs = 387 - { 388 - (enum xrt_input_name)0, 389 - }, 390 - }, 391 - { 392 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 393 - .localized_name = "Trackpad Click", 394 - .paths = 395 - { 396 - "/user/hand/right/input/trackpad/click", 397 - "/user/hand/right/input/trackpad", 398 - NULL, 399 - }, 400 - .inputs = 401 - { 402 - (enum xrt_input_name)0, 403 - }, 404 - }, 405 - { 406 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 407 - .localized_name = "Trackpad Touch", 408 - .paths = 409 - { 410 - "/user/hand/right/input/trackpad/touch", 411 - NULL, 412 - }, 413 - .inputs = 414 - { 415 - (enum xrt_input_name)0, 416 - }, 417 - }, 418 - { 419 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 420 - .localized_name = "Grip", 421 - .paths = 422 - { 423 - "/user/hand/right/input/grip/pose", 424 - "/user/hand/right/input/grip", 425 - NULL, 426 - }, 427 - .inputs = 428 - { 429 - #if 0 430 - XRT_INPUT_PSMV_GRIP_POSE, 431 - XRT_INPUT_HYDRA_POSE, 432 - #endif 433 - (enum xrt_input_name)0, 434 - }, 435 - }, 436 - { 437 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 438 - .localized_name = "Aim", 439 - .paths = 440 - { 441 - "/user/hand/right/input/aim/pose", 442 - "/user/hand/right/input/aim", 443 - NULL, 444 - }, 445 - .inputs = 446 - { 447 - #if 0 448 - XRT_INPUT_PSMV_AIM_POSE, 449 - XRT_INPUT_HYDRA_POSE, 450 - #endif 451 - (enum xrt_input_name)0, 452 - }, 453 - }, 454 - }; 455 - 456 - 457 - /* 458 - * 459 - * 460 - * 461 - * Monado ball on a stick controller 462 - * 463 - * 39 + * Shipped bindings. 464 40 * 465 41 */ 466 42 467 - static struct binding_template mndx_ball_on_a_stick_controller_bindings[26] = { 468 - { 469 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 470 - .localized_name = "PS™ Logo", 471 - .paths = 472 - { 473 - "/user/hand/left/input/system/click", 474 - "/user/hand/left/input/system", 475 - NULL, 476 - }, 477 - .inputs = 478 - { 479 - XRT_INPUT_PSMV_PS_CLICK, 480 - (enum xrt_input_name)0, 481 - }, 482 - }, 483 - { 484 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 485 - .localized_name = "Move™ Logo", 486 - .paths = 487 - { 488 - "/user/hand/left/input/menu/click", 489 - "/user/hand/left/input/menu", 490 - NULL, 491 - }, 492 - .inputs = 493 - { 494 - XRT_INPUT_PSMV_MOVE_CLICK, 495 - (enum xrt_input_name)0, 496 - }, 497 - }, 498 - { 499 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 500 - .localized_name = "Start/Options", 501 - .paths = 502 - { 503 - "/user/hand/left/input/start/click", 504 - "/user/hand/left/input/start", 505 - NULL, 506 - }, 507 - .inputs = 508 - { 509 - XRT_INPUT_PSMV_START_CLICK, 510 - (enum xrt_input_name)0, 511 - }, 512 - }, 513 - { 514 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 515 - .localized_name = "Select", 516 - .paths = 517 - { 518 - "/user/hand/left/input/select/click", 519 - "/user/hand/left/input/select", 520 - NULL, 521 - }, 522 - .inputs = 523 - { 524 - XRT_INPUT_PSMV_SELECT_CLICK, 525 - (enum xrt_input_name)0, 526 - }, 527 - }, 528 - { 529 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 530 - .localized_name = "Square™", 531 - .paths = 532 - { 533 - "/user/hand/left/input/square_mndx/click", 534 - "/user/hand/left/input/square_mndx", 535 - NULL, 536 - }, 537 - .inputs = 538 - { 539 - XRT_INPUT_PSMV_SQUARE_CLICK, 540 - (enum xrt_input_name)0, 541 - }, 542 - }, 543 - { 544 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 545 - .localized_name = "Cross™", 546 - .paths = 547 - { 548 - "/user/hand/left/input/cross_mndx/click", 549 - "/user/hand/left/input/cross_mndx", 550 - NULL, 551 - }, 552 - .inputs = 553 - { 554 - XRT_INPUT_PSMV_CROSS_CLICK, 555 - (enum xrt_input_name)0, 556 - }, 557 - }, 558 - { 559 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 560 - .localized_name = "Circle™", 561 - .paths = 562 - { 563 - "/user/hand/left/input/circle_mndx/click", 564 - "/user/hand/left/input/circle_mndx", 565 - NULL, 566 - }, 567 - .inputs = 568 - { 569 - XRT_INPUT_PSMV_CIRCLE_CLICK, 570 - (enum xrt_input_name)0, 571 - }, 572 - }, 573 - { 574 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 575 - .localized_name = "Trinangle™", 576 - .paths = 577 - { 578 - "/user/hand/left/input/triangle_mndx/click", 579 - "/user/hand/left/input/triangle_mndx", 580 - NULL, 581 - }, 582 - .inputs = 583 - { 584 - XRT_INPUT_PSMV_TRIANGLE_CLICK, 585 - (enum xrt_input_name)0, 586 - }, 587 - }, 588 - { 589 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 590 - .localized_name = "Trigger", 591 - .paths = 592 - { 593 - "/user/hand/left/input/trigger/value", 594 - "/user/hand/left/input/trigger", 595 - NULL, 596 - }, 597 - .inputs = 598 - { 599 - XRT_INPUT_PSMV_TRIGGER_VALUE, 600 - (enum xrt_input_name)0, 601 - }, 602 - }, 603 - { 604 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 605 - .localized_name = "Grip", 606 - .paths = 607 - { 608 - "/user/hand/left/input/grip/pose", 609 - "/user/hand/left/input/grip", 610 - NULL, 611 - }, 612 - .inputs = 613 - { 614 - XRT_INPUT_PSMV_GRIP_POSE, 615 - (enum xrt_input_name)0, 616 - }, 617 - }, 618 - { 619 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 620 - .localized_name = "Ball", 621 - .paths = 622 - { 623 - "/user/hand/left/input/ball_mndx/pose", 624 - "/user/hand/left/input/ball_mndx", 625 - NULL, 626 - }, 627 - .inputs = 628 - { 629 - XRT_INPUT_PSMV_BALL_CENTER_POSE, 630 - (enum xrt_input_name)0, 631 - }, 632 - }, 633 - { 634 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 635 - .localized_name = "Aim", 636 - .paths = 637 - { 638 - "/user/hand/left/input/aim/pose", 639 - "/user/hand/left/input/aim", 640 - NULL, 641 - }, 642 - .inputs = 643 - { 644 - XRT_INPUT_PSMV_AIM_POSE, 645 - (enum xrt_input_name)0, 646 - }, 647 - }, 648 - { 649 - .sub_path = OXR_SUB_ACTION_PATH_LEFT, 650 - .localized_name = "Haptic", 651 - .paths = 652 - { 653 - "/user/hand/left/output/haptic", 654 - NULL, 655 - }, 656 - .outputs = 657 - { 658 - XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION, 659 - (enum xrt_output_name)0, 660 - }, 661 - }, 662 - { 663 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 664 - .localized_name = "PS™ Logo", 665 - .paths = 666 - { 667 - "/user/hand/right/input/system/click", 668 - "/user/hand/right/input/system", 669 - NULL, 670 - }, 671 - .inputs = 672 - { 673 - XRT_INPUT_PSMV_PS_CLICK, 674 - (enum xrt_input_name)0, 675 - }, 676 - }, 677 - { 678 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 679 - .localized_name = "Move™ Logo", 680 - .paths = 681 - { 682 - "/user/hand/right/input/menu/click", 683 - "/user/hand/right/input/menu", 684 - NULL, 685 - }, 686 - .inputs = 687 - { 688 - XRT_INPUT_PSMV_MOVE_CLICK, 689 - (enum xrt_input_name)0, 690 - }, 691 - }, 692 - { 693 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 694 - .localized_name = "Start/Options", 695 - .paths = 696 - { 697 - "/user/hand/right/input/start/click", 698 - "/user/hand/right/input/start", 699 - NULL, 700 - }, 701 - .inputs = 702 - { 703 - XRT_INPUT_PSMV_START_CLICK, 704 - (enum xrt_input_name)0, 705 - }, 706 - }, 707 - { 708 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 709 - .localized_name = "Select", 710 - .paths = 711 - { 712 - "/user/hand/right/input/select/click", 713 - "/user/hand/right/input/select", 714 - NULL, 715 - }, 716 - .inputs = 717 - { 718 - XRT_INPUT_PSMV_SELECT_CLICK, 719 - (enum xrt_input_name)0, 720 - }, 721 - }, 722 - { 723 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 724 - .localized_name = "Square™", 725 - .paths = 726 - { 727 - "/user/hand/right/input/square_mndx/click", 728 - "/user/hand/right/input/square_mndx", 729 - NULL, 730 - }, 731 - .inputs = 732 - { 733 - XRT_INPUT_PSMV_SQUARE_CLICK, 734 - (enum xrt_input_name)0, 735 - }, 736 - }, 737 - { 738 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 739 - .localized_name = "Cross™", 740 - .paths = 741 - { 742 - "/user/hand/right/input/cross_mndx/click", 743 - "/user/hand/right/input/cross_mndx", 744 - NULL, 745 - }, 746 - .inputs = 747 - { 748 - XRT_INPUT_PSMV_CROSS_CLICK, 749 - (enum xrt_input_name)0, 750 - }, 751 - }, 752 - { 753 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 754 - .localized_name = "Circle™", 755 - .paths = 756 - { 757 - "/user/hand/right/input/circle_mndx/click", 758 - "/user/hand/right/input/circle_mndx", 759 - NULL, 760 - }, 761 - .inputs = 762 - { 763 - XRT_INPUT_PSMV_CIRCLE_CLICK, 764 - (enum xrt_input_name)0, 765 - }, 766 - }, 767 - { 768 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 769 - .localized_name = "Triangle™", 770 - .paths = 771 - { 772 - "/user/hand/right/input/triangle_mndx/click", 773 - "/user/hand/right/input/triangle_mndx", 774 - NULL, 775 - }, 776 - .inputs = 777 - { 778 - XRT_INPUT_PSMV_TRIANGLE_CLICK, 779 - (enum xrt_input_name)0, 780 - }, 781 - }, 782 - { 783 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 784 - .localized_name = "Trigger", 785 - .paths = 786 - { 787 - "/user/hand/right/input/trigger/value", 788 - "/user/hand/right/input/trigger", 789 - NULL, 790 - }, 791 - .inputs = 792 - { 793 - XRT_INPUT_PSMV_TRIGGER_VALUE, 794 - (enum xrt_input_name)0, 795 - }, 796 - }, 797 - { 798 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 799 - .localized_name = "Grip", 800 - .paths = 801 - { 802 - "/user/hand/right/input/grip/pose", 803 - "/user/hand/right/input/grip", 804 - NULL, 805 - }, 806 - .inputs = 807 - { 808 - XRT_INPUT_PSMV_GRIP_POSE, 809 - (enum xrt_input_name)0, 810 - }, 811 - }, 812 - { 813 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 814 - .localized_name = "Ball", 815 - .paths = 816 - { 817 - "/user/hand/right/input/ball_mndx/pose", 818 - "/user/hand/right/input/ball_mndx", 819 - NULL, 820 - }, 821 - .inputs = 822 - { 823 - XRT_INPUT_PSMV_BALL_CENTER_POSE, 824 - (enum xrt_input_name)0, 825 - }, 826 - }, 827 - { 828 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 829 - .localized_name = "Aim", 830 - .paths = 831 - { 832 - "/user/hand/right/input/aim/pose", 833 - "/user/hand/right/input/aim", 834 - NULL, 835 - }, 836 - .inputs = 837 - { 838 - XRT_INPUT_PSMV_AIM_POSE, 839 - (enum xrt_input_name)0, 840 - }, 841 - }, 842 - { 843 - .sub_path = OXR_SUB_ACTION_PATH_RIGHT, 844 - .localized_name = "Haptic", 845 - .paths = 846 - { 847 - "/user/hand/right/output/haptic", 848 - NULL, 849 - }, 850 - .outputs = 851 - { 852 - XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION, 853 - (enum xrt_output_name)0, 854 - }, 855 - }, 856 - }; 857 - 858 - 859 43 #define MAKE_INPUT(COMPONENT, NAME, SUFFIX, INPUT) \ 860 44 { \ 861 45 .sub_path = OXR_SUB_ACTION_PATH_LEFT, \ ··· 866 50 "/user/hand/left/input/" #COMPONENT, \ 867 51 NULL, \ 868 52 }, \ 869 - .inputs = \ 870 - { \ 871 - INPUT, \ 872 - (enum xrt_input_name)0, \ 873 - }, \ 53 + .input = INPUT, \ 874 54 }, \ 875 55 { \ 876 56 .sub_path = OXR_SUB_ACTION_PATH_RIGHT, \ ··· 881 61 "/user/hand/right/input/" #COMPONENT, \ 882 62 NULL, \ 883 63 }, \ 884 - .inputs = \ 885 - { \ 886 - INPUT, \ 887 - (enum xrt_input_name)0, \ 888 - }, \ 64 + .input = INPUT, \ 889 65 }, 890 66 891 67 // creates an input that can not be "downgraded" to the top level path. ··· 899 75 "/user/hand/left/input/" #COMPONENT "/" #SUFFIX, \ 900 76 NULL, \ 901 77 }, \ 902 - .inputs = \ 903 - { \ 904 - INPUT, \ 905 - (enum xrt_input_name)0, \ 906 - }, \ 78 + .input = INPUT, \ 907 79 }, \ 908 80 { \ 909 81 .sub_path = OXR_SUB_ACTION_PATH_RIGHT, \ ··· 913 85 "/user/hand/right/input/" #COMPONENT "/" #SUFFIX, \ 914 86 NULL, \ 915 87 }, \ 916 - .inputs = \ 917 - { \ 918 - INPUT, \ 919 - (enum xrt_input_name)0, \ 920 - }, \ 88 + .input = INPUT, \ 921 89 }, 922 90 923 91 // creates an input with a top level path and /x and /y sub paths ··· 932 100 "/user/hand/left/input/" #COMPONENT "/y", \ 933 101 NULL, \ 934 102 }, \ 935 - .inputs = \ 936 - { \ 937 - INPUT, \ 938 - (enum xrt_input_name)0, \ 939 - }, \ 103 + .input = INPUT, \ 940 104 }, \ 941 105 { \ 942 106 .sub_path = OXR_SUB_ACTION_PATH_RIGHT, \ ··· 948 112 "/user/hand/right/input/" #COMPONENT "/y", \ 949 113 NULL, \ 950 114 }, \ 951 - .inputs = \ 952 - { \ 953 - INPUT, \ 954 - (enum xrt_input_name)0, \ 955 - }, \ 115 + .input = INPUT, \ 956 116 }, 957 117 958 118 #define MAKE_OUTPUT(COMPONENT, NAME, OUTPUT) \ ··· 964 124 "/user/hand/left/output/" #COMPONENT, \ 965 125 NULL, \ 966 126 }, \ 967 - .outputs = \ 968 - { \ 969 - OUTPUT, \ 970 - (enum xrt_output_name)0, \ 971 - }, \ 127 + .output = OUTPUT, \ 972 128 }, \ 973 129 { \ 974 130 .sub_path = OXR_SUB_ACTION_PATH_RIGHT, \ ··· 978 134 "/user/hand/right/output/" #COMPONENT, \ 979 135 NULL, \ 980 136 }, \ 981 - .outputs = \ 982 - { \ 983 - OUTPUT, \ 984 - (enum xrt_output_name)0, \ 985 - }, \ 137 + .output = OUTPUT, \ 986 138 }, 987 139 140 + 141 + /* 142 + * 143 + * KHR Simple Controller 144 + * 145 + */ 146 + 147 + static struct binding_template khr_simple_controller_bindings[10] = { 148 + // clang-format off 149 + MAKE_INPUT(select, "Select", click, XRT_INPUT_SIMPLE_SELECT_CLICK) 150 + MAKE_INPUT(menu, "Menu", click, XRT_INPUT_SIMPLE_MENU_CLICK) 151 + MAKE_INPUT(grip, "Grip", pose, XRT_INPUT_SIMPLE_GRIP_POSE) 152 + MAKE_INPUT(aim, "Aim", pose, XRT_INPUT_SIMPLE_AIM_POSE) 153 + 154 + MAKE_OUTPUT(haptic, "Haptic", XRT_OUTPUT_NAME_SIMPLE_VIBRATION) 155 + // clang-format on 156 + }; 157 + 158 + 159 + /* 160 + * 161 + * Monado ball on a stick controller 162 + * 163 + */ 164 + 165 + static struct binding_template mndx_ball_on_a_stick_controller_bindings[26] = { 166 + // clang-format off 167 + MAKE_INPUT(system, "PS™ Logo", click, XRT_INPUT_PSMV_PS_CLICK) 168 + MAKE_INPUT(menu, "Move™ Logo", click, XRT_INPUT_PSMV_MOVE_CLICK) 169 + MAKE_INPUT(start, "Start/Options", click, XRT_INPUT_PSMV_START_CLICK) 170 + MAKE_INPUT(select, "Select", click, XRT_INPUT_PSMV_SELECT_CLICK) 171 + MAKE_INPUT(square_mndx, "Square™", click, XRT_INPUT_PSMV_SQUARE_CLICK) 172 + MAKE_INPUT(cross_mndx, "Cross™", click, XRT_INPUT_PSMV_CROSS_CLICK) 173 + MAKE_INPUT(circle_mndx, "Circle™", click, XRT_INPUT_PSMV_CIRCLE_CLICK) 174 + MAKE_INPUT(triangle_mndx, "Trinangle™", click, XRT_INPUT_PSMV_TRIANGLE_CLICK) 175 + MAKE_INPUT(trigger, "Trigger", value, XRT_INPUT_PSMV_TRIGGER_VALUE) 176 + MAKE_INPUT(grip, "Grip", pose, XRT_INPUT_PSMV_GRIP_POSE) 177 + MAKE_INPUT(ball_mndx, "Ball", pose, XRT_INPUT_PSMV_BALL_CENTER_POSE) 178 + MAKE_INPUT(aim, "Aim", pose, XRT_INPUT_PSMV_AIM_POSE) 179 + 180 + MAKE_OUTPUT(haptic, "Haptic", XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION) 181 + // clang-format on 182 + }; 183 + 184 + 185 + /* 186 + * 187 + * Valve Index controller 188 + * 189 + */ 190 + 988 191 static struct binding_template valve_index_controller_bindings[44] = { 989 192 // clang-format off 990 193 MAKE_INPUT(system, "System", click, XRT_INPUT_INDEX_SYSTEM_CLICK) ··· 1011 214 // clang-format on 1012 215 }; 1013 216 217 + 218 + /* 219 + * 220 + * HTC Vive controller 221 + * 222 + */ 223 + 1014 224 static struct binding_template htc_vive_controller_bindings[24] = { 1015 225 // clang-format off 1016 226 MAKE_INPUT(system, "System", click, XRT_INPUT_VIVE_SYSTEM_CLICK) ··· 1028 238 // clang-format on 1029 239 }; 1030 240 1031 - static struct profile_template profiles[5] = { 241 + 242 + /* 243 + * 244 + * Profiles 245 + * 246 + */ 247 + 248 + static struct profile_template profiles[4] = { 1032 249 { 250 + .name = XRT_DEVICE_SIMPLE_CONTROLLER, 1033 251 .path = "/interaction_profiles/khr/simple_controller", 1034 252 .localized_name = "Simple Controller", 1035 253 .bindings = khr_simple_controller_bindings, 1036 254 .num_bindings = ARRAY_SIZE(khr_simple_controller_bindings), 1037 255 }, 256 + #if 0 1038 257 { 1039 258 .path = "/interaction_profiles/google/daydream_controller", 1040 259 .localized_name = "Daydream Controller", 1041 260 .bindings = google_daydream_controller_bindings, 1042 261 .num_bindings = ARRAY_SIZE(google_daydream_controller_bindings), 1043 262 }, 263 + #endif 1044 264 { 265 + .name = XRT_DEVICE_PSMV, 1045 266 .path = "/interaction_profiles/mndx/ball_on_a_stick_controller", 1046 267 .localized_name = "PS Move", 1047 268 .bindings = mndx_ball_on_a_stick_controller_bindings, 1048 269 .num_bindings = ARRAY_SIZE(mndx_ball_on_a_stick_controller_bindings), 1049 270 }, 1050 271 { 272 + .name = XRT_DEVICE_INDEX_CONTROLLER, 1051 273 .path = "/interaction_profiles/valve/index_controller", 1052 274 .localized_name = "Index Controller", 1053 275 .bindings = valve_index_controller_bindings, 1054 276 .num_bindings = ARRAY_SIZE(valve_index_controller_bindings), 1055 277 }, 1056 278 { 279 + .name = XRT_DEVICE_VIVE_WAND, 1057 280 .path = "/interaction_profiles/htc/vive_controller", 1058 281 .localized_name = "Vive Wand", 1059 282 .bindings = htc_vive_controller_bindings,
+129 -40
src/xrt/state_trackers/oxr/oxr_input.c
··· 484 484 */ 485 485 486 486 static bool 487 - do_inputs(struct oxr_binding *bind, 487 + do_inputs(struct oxr_binding *binding_point, 488 488 struct xrt_device *xdev, 489 + struct xrt_binding_profile *xbp, 489 490 XrPath matched_path, 490 491 struct oxr_action_input inputs[OXR_MAX_BINDINGS_PER_ACTION], 491 492 uint32_t *num_inputs) 492 493 { 493 - struct xrt_input *input = NULL; 494 - bool found = false; 494 + enum xrt_input_name name = 0; 495 + if (xbp == NULL) { 496 + name = binding_point->input; 497 + } else { 498 + for (size_t i = 0; i < xbp->num_inputs; i++) { 499 + if (binding_point->input != xbp->inputs[i].from) { 500 + continue; 501 + } 495 502 496 - for (size_t i = 0; i < bind->num_inputs; i++) { 497 - if (oxr_xdev_find_input(xdev, bind->inputs[i], &input)) { 498 - uint32_t index = (*num_inputs)++; 499 - inputs[index].input = input; 500 - inputs[index].xdev = xdev; 501 - inputs[index].bound_path = matched_path; 502 - found = true; 503 + // We have found a device mapping. 504 + name = xbp->inputs[i].device; 505 + break; 506 + } 507 + 508 + // Didn't find a mapping. 509 + if (name == 0) { 510 + return false; 503 511 } 504 512 } 505 513 506 - return found; 514 + struct xrt_input *input = NULL; 515 + if (oxr_xdev_find_input(xdev, name, &input)) { 516 + uint32_t index = (*num_inputs)++; 517 + inputs[index].input = input; 518 + inputs[index].xdev = xdev; 519 + inputs[index].bound_path = matched_path; 520 + return true; 521 + } 522 + 523 + return false; 507 524 } 508 525 509 526 static bool 510 - do_outputs(struct oxr_binding *bind, 527 + do_outputs(struct oxr_binding *binding_point, 511 528 struct xrt_device *xdev, 529 + struct xrt_binding_profile *xbp, 512 530 XrPath matched_path, 513 531 struct oxr_action_output outputs[OXR_MAX_BINDINGS_PER_ACTION], 514 532 uint32_t *num_outputs) 515 533 { 516 - struct xrt_output *output = NULL; 517 - bool found = false; 534 + enum xrt_output_name name = 0; 535 + if (xbp == NULL) { 536 + name = binding_point->output; 537 + } else { 538 + for (size_t i = 0; i < xbp->num_outputs; i++) { 539 + if (binding_point->output != xbp->outputs[i].from) { 540 + continue; 541 + } 518 542 519 - for (size_t i = 0; i < bind->num_outputs; i++) { 520 - if (oxr_xdev_find_output(xdev, bind->outputs[i], &output)) { 521 - uint32_t index = (*num_outputs)++; 522 - outputs[index].name = output->name; 523 - outputs[index].xdev = xdev; 524 - outputs[index].bound_path = matched_path; 525 - found = true; 543 + // We have found a device mapping. 544 + name = xbp->outputs[i].device; 545 + break; 546 + } 547 + 548 + // Didn't find a mapping. 549 + if (name == 0) { 550 + return false; 526 551 } 527 552 } 528 553 529 - return found; 554 + struct xrt_output *output = NULL; 555 + if (oxr_xdev_find_output(xdev, name, &output)) { 556 + uint32_t index = (*num_outputs)++; 557 + outputs[index].name = name; 558 + outputs[index].xdev = xdev; 559 + outputs[index].bound_path = matched_path; 560 + return true; 561 + } 562 + 563 + return false; 530 564 } 531 565 532 566 /*! ··· 534 568 * is output or input. 535 569 */ 536 570 static bool 537 - do_io_bindings(struct oxr_binding *b, 571 + do_io_bindings(struct oxr_binding *binding_point, 538 572 struct oxr_action *act, 539 573 struct xrt_device *xdev, 574 + struct xrt_binding_profile *xbp, 540 575 XrPath matched_path, 541 576 struct oxr_action_input inputs[OXR_MAX_BINDINGS_PER_ACTION], 542 577 uint32_t *num_inputs, 543 578 struct oxr_action_output outputs[OXR_MAX_BINDINGS_PER_ACTION], 544 579 uint32_t *num_outputs) 545 580 { 546 - bool found = false; 547 - 548 581 if (act->data->action_type == XR_ACTION_TYPE_VIBRATION_OUTPUT) { 549 - found |= 550 - do_outputs(b, xdev, matched_path, outputs, num_outputs); 582 + return do_outputs( // 583 + binding_point, // 584 + xdev, // 585 + xbp, // 586 + matched_path, // 587 + outputs, // 588 + num_outputs); // 551 589 } else { 552 - found |= do_inputs(b, xdev, matched_path, inputs, num_inputs); 590 + return do_inputs( // 591 + binding_point, // 592 + xdev, // 593 + xbp, // 594 + matched_path, // 595 + inputs, // 596 + num_inputs); // 553 597 } 598 + } 554 599 555 - return found; 600 + static struct xrt_binding_profile * 601 + get_matching_binding_profile(struct oxr_interaction_profile *profile, 602 + struct xrt_device *xdev) 603 + { 604 + for (size_t i = 0; i < xdev->num_binding_profiles; i++) { 605 + if (xdev->binding_profiles[i].name == profile->xname) { 606 + return &xdev->binding_profiles[i]; 607 + } 608 + } 609 + 610 + return NULL; 556 611 } 557 612 558 613 static XrPath ··· 584 639 uint32_t *num_outputs) 585 640 { 586 641 struct xrt_device *xdev = NULL; 587 - struct oxr_binding *bindings[OXR_MAX_BINDINGS_PER_ACTION]; 642 + struct oxr_binding *binding_points[OXR_MAX_BINDINGS_PER_ACTION]; 588 643 const char *profile_str; 589 644 const char *user_path_str; 590 645 size_t length; ··· 626 681 627 682 oxr_slog(slog, "\t\tProfile: %s\n", profile_str); 628 683 684 + /*! 685 + * Lookup device binding that matches the interactive profile, this 686 + * is used as a fallback should the device not match the interactive 687 + * profile. This allows the device to provide a mapping from one device 688 + * to itself. 689 + */ 690 + struct xrt_binding_profile *xbp = 691 + get_matching_binding_profile(profile, xdev); 692 + 693 + // No point in proceeding here without either. 694 + if (profile->xname != xdev->name && xbp == NULL) { 695 + oxr_slog(slog, 696 + "\t\t\tProfile not for device and no xbp fallback!\n"); 697 + return; 698 + } 699 + 629 700 size_t num = 0; 630 - oxr_binding_find_bindings_from_key(log, profile, act->act_key, bindings, 631 - &num); 701 + oxr_binding_find_bindings_from_key(log, profile, act->act_key, 702 + binding_points, &num); 632 703 if (num == 0) { 633 - oxr_slog(slog, "\t\tNo bindings\n"); 704 + oxr_slog(slog, "\t\t\tNo bindings!\n"); 634 705 return; 635 706 } 707 + 636 708 for (size_t i = 0; i < num; i++) { 637 709 const char *str = NULL; 638 - struct oxr_binding *b = bindings[i]; 710 + struct oxr_binding *binding_point = binding_points[i]; 639 711 640 - XrPath matched_path = get_matched_xrpath(b, act); 712 + XrPath matched_path = get_matched_xrpath(binding_point, act); 641 713 642 714 oxr_path_get_string(log, sess->sys->inst, matched_path, &str, 643 715 &length); 644 716 oxr_slog(slog, "\t\t\tBinding: %s\n", str); 645 717 646 - if (b->sub_path != sub_path) { 718 + if (binding_point->sub_path != sub_path) { 647 719 oxr_slog(slog, "\t\t\t\tRejected! (SUB PATH)\n"); 648 720 continue; 649 721 } 650 722 651 - bool found = do_io_bindings(b, act, xdev, matched_path, inputs, 652 - num_inputs, outputs, num_outputs); 723 + bool found = do_io_bindings( // 724 + binding_point, // 725 + act, // 726 + xdev, // 727 + xbp, // 728 + matched_path, // 729 + inputs, // 730 + num_inputs, // 731 + outputs, // 732 + num_outputs); // 653 733 654 734 if (found) { 655 - oxr_slog(slog, "\t\t\t\tBound!\n"); 735 + if (xbp == NULL) { 736 + oxr_slog(slog, "\t\t\t\tBound (xdev)!\n"); 737 + } else { 738 + oxr_slog(slog, "\t\t\t\tBound (xbp)!\n"); 739 + } 740 + continue; 741 + } 742 + 743 + if (xbp == NULL) { 744 + oxr_slog(slog, "\t\t\t\tRejected! (NO XDEV NAME)\n"); 656 745 } else { 657 - oxr_slog(slog, "\t\t\t\tRejected! (NO XDEV MAPPING)\n"); 746 + oxr_slog(slog, "\t\t\t\tRejected! (NO XBINDING)\n"); 658 747 } 659 748 } 660 749 }
+5 -4
src/xrt/state_trackers/oxr/oxr_objects.h
··· 1380 1380 { 1381 1381 XrPath path; 1382 1382 1383 + //! Used to lookup @ref xrt_binding for fallback. 1384 + enum xrt_device_name xname; 1385 + 1383 1386 //! Name presented to the user. 1384 1387 const char *localized_name; 1385 1388 ··· 1405 1408 //! store which entry in paths was suggested, for each action key 1406 1409 uint32_t *preferred_binding_path_index; 1407 1410 1408 - enum xrt_input_name *inputs; 1409 - size_t num_inputs; 1411 + enum xrt_input_name input; 1410 1412 1411 - enum xrt_output_name *outputs; 1412 - size_t num_outputs; 1413 + enum xrt_output_name output; 1413 1414 }; 1414 1415 1415 1416 /*!