The open source OpenXR runtime
0
fork

Configure Feed

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

xrt: adapt driver to new set_output api change

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2360>

Simon Zeni aa5b75cd 24e3ca2c

+70 -97
+3 -2
src/xrt/auxiliary/util/u_device.c
··· 527 527 return XRT_ERROR_NOT_IMPLEMENTED; 528 528 } 529 529 530 - void 530 + xrt_result_t 531 531 u_device_ni_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 532 532 { 533 - E(get_hand_tracking); 533 + E(set_output); 534 + return XRT_ERROR_NOT_IMPLEMENTED; 534 535 } 535 536 536 537 xrt_result_t
+1 -1
src/xrt/auxiliary/util/u_device.h
··· 226 226 * 227 227 * @ingroup aux_util 228 228 */ 229 - void 229 + xrt_result_t 230 230 u_device_ni_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value); 231 231 232 232 /*!
+1 -7
src/xrt/drivers/ht_ctrl_emu/ht_ctrl_emu.cpp
··· 368 368 return xret; 369 369 } 370 370 371 - static void 372 - cemu_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 373 - { 374 - // No-op, needed to avoid crash. 375 - } 376 - 377 371 //! @todo This is flickery; investigate once we get better hand tracking 378 372 static void 379 373 decide(xrt_vec3 one, xrt_vec3 two, bool *out) ··· 457 451 458 452 cemud[i]->base.update_inputs = cemu_device_update_inputs; 459 453 cemud[i]->base.get_tracked_pose = cemu_device_get_tracked_pose; 460 - cemud[i]->base.set_output = cemu_device_set_output; 454 + cemud[i]->base.set_output = u_device_ni_set_output; 461 455 cemud[i]->base.get_hand_tracking = cemu_device_get_hand_tracking; 462 456 cemud[i]->base.destroy = cemu_device_destroy; 463 457
+1 -1
src/xrt/drivers/hydra/hydra_driver.c
··· 793 793 hd->base.destroy = hydra_device_destroy; 794 794 hd->base.update_inputs = hydra_device_update_inputs; 795 795 hd->base.get_tracked_pose = hydra_device_get_tracked_pose; 796 - // hs->base.set_output = hydra_device_set_output; 796 + hd->base.set_output = u_device_ni_set_output; 797 797 hd->base.name = XRT_DEVICE_HYDRA; 798 798 snprintf(hd->base.str, XRT_DEVICE_NAME_LEN, "%s %i", "Razer Hydra Controller", (int)(i + 1)); 799 799 snprintf(hd->base.serial, XRT_DEVICE_NAME_LEN, "%s%i", "RZRHDRC", (int)(i + 1));
+2 -2
src/xrt/drivers/multi_wrapper/multi.c
··· 185 185 return XRT_SUCCESS; 186 186 } 187 187 188 - static void 188 + static xrt_result_t 189 189 set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 190 190 { 191 191 struct multi_device *d = (struct multi_device *)xdev; 192 192 struct xrt_device *target = d->tracking_override.target; 193 - xrt_device_set_output(target, name, value); 193 + return xrt_device_set_output(target, name, value); 194 194 } 195 195 196 196 static xrt_result_t
+7 -3
src/xrt/drivers/ohmd/oh_device.c
··· 326 326 return XRT_SUCCESS; 327 327 } 328 328 329 - static void 329 + static xrt_result_t 330 330 oh_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 331 331 { 332 332 struct oh_device *ohd = oh_device(xdev); ··· 342 342 frequency = DEFAULT_HAPTIC_FREQ; 343 343 } 344 344 345 - ohmd_device_set_haptics_on(ohd->dev, (float)value->vibration.duration_ns / 1e9f, frequency, 346 - value->vibration.amplitude); 345 + int result = ohmd_device_set_haptics_on(ohd->dev, (float)value->vibration.duration_ns / 1e9f, frequency, 346 + value->vibration.amplitude); 347 + if (result == -1) { 348 + return XRT_ERROR_OUTPUT_REQUEST_FAILURE; 349 + } 347 350 #else 348 351 // There is no official OpenHMD Haptic API. 349 352 (void)ohd; 350 353 #endif 354 + return XRT_SUCCESS; 351 355 } 352 356 353 357 static bool
+10 -3
src/xrt/drivers/opengloves/opengloves_device.c
··· 174 174 } 175 175 } 176 176 177 - static void 177 + static xrt_result_t 178 178 opengloves_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 179 179 { 180 180 struct opengloves_device *od = opengloves_device(xdev); ··· 194 194 char buff[64]; 195 195 opengloves_alpha_encoding_encode(&out, buff); 196 196 197 - opengloves_communication_device_write(od->ocd, buff, strlen(buff)); 197 + int ret = opengloves_communication_device_write(od->ocd, buff, strlen(buff)); 198 + if (ret == -1) { 199 + return XRT_ERROR_OUTPUT_REQUEST_FAILURE; 200 + } 201 + return XRT_SUCCESS; 198 202 } 199 - default: break; 203 + default: 204 + U_LOG_XDEV_UNSUPPORTED_OUTPUT(&od->base, od->log_level, name); 205 + return XRT_ERROR_OUTPUT_UNSUPPORTED; 206 + break; 200 207 } 201 208 } 202 209
+4 -2
src/xrt/drivers/psmv/psmv_driver.c
··· 921 921 return amp * (max - min) + min; 922 922 } 923 923 924 - static void 924 + static xrt_result_t 925 925 psmv_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 926 926 { 927 927 struct psmv_device *psmv = psmv_device(xdev); 928 928 929 929 if (name != XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION) { 930 - return; 930 + U_LOG_XDEV_UNSUPPORTED_OUTPUT(&psmv->base, psmv->log_level, name); 931 + return XRT_ERROR_OUTPUT_UNSUPPORTED; 931 932 } 932 933 933 934 os_mutex_lock(&psmv->lock); ··· 944 945 psmv_led_and_trigger_update_locked(psmv, now); 945 946 946 947 os_mutex_unlock(&psmv->lock); 948 + return XRT_SUCCESS; 947 949 } 948 950 949 951
+5 -3
src/xrt/drivers/pssense/pssense_driver.c
··· 676 676 return XRT_SUCCESS; 677 677 } 678 678 679 - static void 679 + static xrt_result_t 680 680 pssense_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 681 681 { 682 682 struct pssense_device *pssense = (struct pssense_device *)xdev; ··· 710 710 } 711 711 } 712 712 } else { 713 - PSSENSE_ERROR(pssense, "Unknown output name requested %u", name); 714 - return; 713 + U_LOG_XDEV_UNSUPPORTED_OUTPUT(&pssense->base, pssense->log_level, name); 714 + return XRT_ERROR_OUTPUT_UNSUPPORTED; 715 715 } 716 716 717 717 os_mutex_lock(&pssense->lock); ··· 730 730 pssense_send_output_report_locked(pssense); 731 731 } 732 732 os_mutex_unlock(&pssense->lock); 733 + 734 + return XRT_SUCCESS; 733 735 } 734 736 735 737 static void
+3 -1
src/xrt/drivers/qwerty/qwerty_device.c
··· 177 177 return XRT_SUCCESS; 178 178 } 179 179 180 - static void 180 + static xrt_result_t 181 181 qwerty_set_output(struct xrt_device *xd, enum xrt_output_name name, const struct xrt_output_value *value) 182 182 { 183 183 struct qwerty_device *qd = qwerty_device(xd); ··· 190 190 "\tfrequency=%.2f amplitude=%.2f duration=%" PRId64, 191 191 xd->str, frequency, amplitude, duration); 192 192 } 193 + 194 + return XRT_SUCCESS; 193 195 } 194 196 195 197 static xrt_result_t
+1 -8
src/xrt/drivers/remote/r_device.c
··· 179 179 return XRT_SUCCESS; 180 180 } 181 181 182 - static void 183 - r_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 184 - { 185 - struct r_device *rd = r_device(xdev); 186 - (void)rd; 187 - } 188 - 189 182 /*! 190 183 * @public @memberof r_device 191 184 */ ··· 204 197 rd->base.get_tracked_pose = r_device_get_tracked_pose; 205 198 rd->base.get_hand_tracking = r_device_get_hand_tracking; 206 199 rd->base.get_view_poses = u_device_ni_get_view_poses; 207 - rd->base.set_output = r_device_set_output; 200 + rd->base.set_output = u_device_ni_set_output; 208 201 rd->base.destroy = r_device_destroy; 209 202 rd->base.tracking_origin = &r->origin; 210 203 rd->base.supported.orientation_tracking = true;
+1 -7
src/xrt/drivers/remote/r_hmd.c
··· 108 108 return XRT_SUCCESS; 109 109 } 110 110 111 - static void 112 - r_hmd_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 113 - { 114 - // Empty 115 - } 116 - 117 111 /*! 118 112 * @public @memberof r_hmd 119 113 */ ··· 132 126 rh->base.get_tracked_pose = r_hmd_get_tracked_pose; 133 127 rh->base.get_hand_tracking = u_device_ni_get_hand_tracking; 134 128 rh->base.get_view_poses = r_hmd_get_view_poses; 135 - rh->base.set_output = r_hmd_set_output; 129 + rh->base.set_output = u_device_ni_set_output; 136 130 rh->base.destroy = r_hmd_destroy; 137 131 rh->base.tracking_origin = &r->origin; 138 132 rh->base.supported.orientation_tracking = true;
+1 -7
src/xrt/drivers/rift_s/rift_s_controller.c
··· 510 510 } 511 511 512 512 static void 513 - rift_s_controller_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 514 - { 515 - /* TODO: Implement haptic sending */ 516 - } 517 - 518 - static void 519 513 rift_s_controller_get_fusion_pose(struct rift_s_controller *ctrl, 520 514 enum xrt_input_name name, 521 515 int64_t at_timestamp_ns, ··· 613 607 os_mutex_init(&ctrl->mutex); 614 608 615 609 ctrl->base.update_inputs = rift_s_controller_update_inputs; 616 - ctrl->base.set_output = rift_s_controller_set_output; 610 + ctrl->base.set_output = u_device_ni_set_output; 617 611 ctrl->base.get_tracked_pose = rift_s_controller_get_tracked_pose; 618 612 ctrl->base.get_view_poses = u_device_get_view_poses; 619 613 ctrl->base.destroy = rift_s_controller_destroy;
+1 -8
src/xrt/drivers/simulated/simulated_controller.c
··· 166 166 return XRT_SUCCESS; 167 167 } 168 168 169 - static void 170 - simulated_device_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 171 - { 172 - struct simulated_device *sd = simulated_device(xdev); 173 - (void)sd; 174 - } 175 - 176 169 177 170 /* 178 171 * ··· 358 351 sd->base.get_tracked_pose = simulated_device_get_tracked_pose; 359 352 sd->base.get_hand_tracking = u_device_ni_get_hand_tracking; 360 353 sd->base.get_view_poses = u_device_ni_get_view_poses; 361 - sd->base.set_output = simulated_device_set_output; 354 + sd->base.set_output = u_device_ni_set_output; 362 355 sd->base.destroy = simulated_device_destroy; 363 356 sd->base.tracking_origin = origin; 364 357 sd->base.supported.orientation_tracking = true;
+4 -5
src/xrt/drivers/steamvr_lh/device.cpp
··· 187 187 188 188 this->xrt_device::get_hand_tracking = 189 189 &device_bouncer<ControllerDevice, &ControllerDevice::get_hand_tracking, xrt_result_t>; 190 - #define SETUP_MEMBER_FUNC(name) this->xrt_device::name = &device_bouncer<ControllerDevice, &ControllerDevice::name> 191 - SETUP_MEMBER_FUNC(set_output); 192 - #undef SETUP_MEMBER_FUNC 190 + this->xrt_device::set_output = &device_bouncer<ControllerDevice, &ControllerDevice::set_output, xrt_result_t>; 193 191 } 194 192 195 193 Device::~Device() ··· 461 459 return XRT_SUCCESS; 462 460 } 463 461 464 - void 462 + xrt_result_t 465 463 ControllerDevice::set_output(xrt_output_name name, const xrt_output_value *value) 466 464 467 465 { 468 466 const auto &vib = value->vibration; 469 467 if (vib.amplitude == 0.0) 470 - return; 468 + return XRT_SUCCESS; 471 469 vr::VREvent_HapticVibration_t event; 472 470 event.containerHandle = container_handle; 473 471 event.componentHandle = haptic_handle; ··· 478 476 event.fAmplitude = vib.amplitude; 479 477 480 478 ctx->add_haptic_event(event); 479 + return XRT_SUCCESS; 481 480 } 482 481 483 482 void
+1 -1
src/xrt/drivers/steamvr_lh/device.hpp
··· 162 162 public: 163 163 ControllerDevice(vr::PropertyContainerHandle_t container_handle, const DeviceBuilder &builder); 164 164 165 - void 165 + xrt_result_t 166 166 set_output(xrt_output_name name, const xrt_output_value *value); 167 167 168 168 void
+7 -4
src/xrt/drivers/survive/survive_driver.c
··· 404 404 duration_seconds); 405 405 } 406 406 407 - static void 407 + static xrt_result_t 408 408 survive_controller_device_set_output(struct xrt_device *xdev, 409 409 enum xrt_output_name name, 410 410 const struct xrt_output_value *value) ··· 412 412 struct survive_device *survive = (struct survive_device *)xdev; 413 413 414 414 if (name != XRT_OUTPUT_NAME_VIVE_HAPTIC && name != XRT_OUTPUT_NAME_INDEX_HAPTIC) { 415 - SURVIVE_ERROR(survive, "Unknown output"); 416 - return; 415 + U_LOG_XDEV_UNSUPPORTED_OUTPUT(&survive->base, survive->sys->log_level, name); 416 + return XRT_ERROR_OUTPUT_UNSUPPORTED; 417 417 } 418 418 419 419 bool pulse = value->vibration.amplitude > 0.01; 420 420 if (!pulse) { 421 - return; 421 + return XRT_SUCCESS; 422 422 } 423 423 424 424 int ret = survive_controller_haptic_pulse(survive, value); 425 425 426 426 if (ret != 0) { 427 427 SURVIVE_ERROR(survive, "haptic failed %d", ret); 428 + return XRT_ERROR_OUTPUT_REQUEST_FAILURE; 428 429 } 430 + 431 + return XRT_SUCCESS; 429 432 } 430 433 431 434 struct Button
+8 -9
src/xrt/drivers/vive/vive_controller.c
··· 487 487 return os_hid_set_feature(d->controller_hid, (uint8_t *)&report, sizeof(report)); 488 488 } 489 489 490 - static void 490 + static xrt_result_t 491 491 vive_controller_device_set_output(struct xrt_device *xdev, 492 492 enum xrt_output_name name, 493 493 const struct xrt_output_value *value) ··· 495 495 struct vive_controller_device *d = vive_controller_device(xdev); 496 496 497 497 if (name != XRT_OUTPUT_NAME_VIVE_HAPTIC && name != XRT_OUTPUT_NAME_INDEX_HAPTIC) { 498 - VIVE_ERROR(d, "Unknown output\n"); 499 - return; 498 + U_LOG_XDEV_UNSUPPORTED_OUTPUT(&d->base, d->log_level, name); 499 + return XRT_ERROR_OUTPUT_UNSUPPORTED; 500 500 } 501 501 502 - bool pulse = value->vibration.amplitude > 0.01; 503 - if (!pulse) { 504 - return; 502 + if (value->vibration.amplitude > 0.01) { 503 + os_mutex_lock(&d->lock); 504 + vive_controller_haptic_pulse(d, value); 505 + os_mutex_unlock(&d->lock); 505 506 } 506 507 507 - os_mutex_lock(&d->lock); 508 - vive_controller_haptic_pulse(d, value); 509 - os_mutex_unlock(&d->lock); 508 + return XRT_SUCCESS; 510 509 } 511 510 512 511
+1 -10
src/xrt/drivers/wmr/wmr_controller_hp.c
··· 340 340 } 341 341 342 342 static void 343 - wmr_controller_hp_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 344 - { 345 - DRV_TRACE_MARKER(); 346 - 347 - // struct wmr_controller_base *d = wmr_controller_base(xdev); 348 - // Todo: implement 349 - } 350 - 351 - static void 352 343 wmr_controller_hp_destroy(struct xrt_device *xdev) 353 344 { 354 345 struct wmr_controller_base *wcb = (struct wmr_controller_base *)(xdev); ··· 386 377 387 378 wcb->base.destroy = wmr_controller_hp_destroy; 388 379 wcb->base.update_inputs = wmr_controller_hp_update_inputs; 389 - wcb->base.set_output = wmr_controller_hp_set_output; 380 + wcb->base.set_output = u_device_ni_set_output; 390 381 391 382 SET_INPUT(wcb, MENU_CLICK, MENU_CLICK); 392 383 SET_INPUT(wcb, HOME_CLICK, HOME_CLICK);
+1 -10
src/xrt/drivers/wmr/wmr_controller_og.c
··· 320 320 } 321 321 322 322 static void 323 - wmr_controller_og_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 324 - { 325 - DRV_TRACE_MARKER(); 326 - 327 - // struct wmr_controller_base *d = wmr_controller_base(xdev); 328 - // Todo: implement 329 - } 330 - 331 - static void 332 323 wmr_controller_og_destroy(struct xrt_device *xdev) 333 324 { 334 325 struct wmr_controller_base *wcb = (struct wmr_controller_base *)(xdev); ··· 363 354 } 364 355 wcb->base.destroy = wmr_controller_og_destroy; 365 356 wcb->base.update_inputs = wmr_controller_og_update_inputs; 366 - wcb->base.set_output = wmr_controller_og_set_output; 357 + wcb->base.set_output = u_device_ni_set_output; 367 358 368 359 if (pid == ODYSSEY_CONTROLLER_PID) { 369 360 SET_ODYSSEY_INPUT(wcb, MENU_CLICK);
+3 -1
src/xrt/include/xrt/xrt_device.h
··· 441 441 * @param[in] value The value to set the output to. 442 442 * @see xrt_output_name 443 443 */ 444 - void (*set_output)(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value); 444 + xrt_result_t (*set_output)(struct xrt_device *xdev, 445 + enum xrt_output_name name, 446 + const struct xrt_output_value *value); 445 447 446 448 /*! 447 449 * Gets limits of this devices outputs.
+4 -2
src/xrt/ipc/client/ipc_client_xdev.c
··· 127 127 IPC_CHK_ALWAYS_RET(icx->ipc_c, xret, "ipc_call_device_get_body_joints"); 128 128 } 129 129 130 - static void 130 + static xrt_result_t 131 131 ipc_client_xdev_set_output(struct xrt_device *xdev, enum xrt_output_name name, const struct xrt_output_value *value) 132 132 { 133 133 struct ipc_client_xdev *icx = ipc_client_xdev(xdev); ··· 146 146 ipc_client_connection_lock(ipc_c); 147 147 148 148 xret = ipc_send_device_set_haptic_output_locked(ipc_c, icx->device_id, name, &samples); 149 - IPC_CHK_WITH_RET(ipc_c, xret, "ipc_send_device_set_haptic_output_locked", ); 149 + IPC_CHK_WITH_GOTO(ipc_c, xret, "ipc_send_device_set_haptic_output_locked", send_haptic_output_end); 150 150 151 151 xrt_result_t alloc_xret; 152 152 xret = ipc_receive(&ipc_c->imc, &alloc_xret, sizeof alloc_xret); ··· 171 171 xret = ipc_call_device_set_output(ipc_c, icx->device_id, name, value); 172 172 IPC_CHK_ONLY_PRINT(ipc_c, xret, "ipc_call_device_set_output"); 173 173 } 174 + 175 + return xret; 174 176 } 175 177 176 178 xrt_result_t