The open source OpenXR runtime

d/blubur_s1: Expose presence sensor to applications

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

authored by

Beyley Cardellio and committed by
Marge Bot
87b2e9cc 5bfa8943

+26 -3
+18 -3
src/xrt/drivers/blubur_s1/blubur_s1_hmd.c
··· 63 63 m_relation_history_destroy(&hmd->relation_history); 64 64 } 65 65 66 + os_mutex_destroy(&hmd->input_mutex); 67 + 66 68 free(hmd); 67 69 } 68 70 ··· 130 132 static xrt_result_t 131 133 blubur_s1_hmd_get_presence(struct xrt_device *xdev, bool *presence) 132 134 { 133 - // TODO: read the presence sensor from the device 134 - *presence = true; 135 + struct blubur_s1_hmd *hmd = blubur_s1_hmd(xdev); 136 + 137 + os_mutex_lock(&hmd->input_mutex); 138 + *presence = hmd->input.status & BLUBUR_S1_STATUS_PRESENCE; 139 + os_mutex_unlock(&hmd->input_mutex); 135 140 136 141 return XRT_SUCCESS; 137 142 } ··· 406 411 407 412 if (timestamp_delta_ms == 0) { 408 413 // duplicate packet? 409 - S1_TRACE(hmd, "Got duplicate timestamp packet (0 delta)!"); 410 414 return 0; 411 415 } 412 416 ··· 448 452 XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT, 449 453 }; 450 454 m_relation_history_push(hmd->relation_history, &latest_3dof_relation, hmd->fusion_3dof.last.timestamp_ns); 455 + 456 + os_mutex_lock(&hmd->input_mutex); 457 + hmd->input.status = body.status; 458 + os_mutex_unlock(&hmd->input_mutex); 451 459 452 460 // S1_DEBUG_HEX(hmd, data, result); 453 461 ··· 495 503 496 504 hmd->log_level = debug_get_log_option_blubur_s1_log(); 497 505 hmd->dev = dev; 506 + 507 + ret = os_mutex_init(&hmd->input_mutex); 508 + if (ret < 0) { 509 + S1_ERROR(hmd, "Failed to init mutex!"); 510 + free(hmd); 511 + return NULL; 512 + } 498 513 499 514 hmd->base.destroy = blubur_s1_hmd_destroy; 500 515 hmd->base.name = XRT_DEVICE_GENERIC_HMD;
+8
src/xrt/drivers/blubur_s1/blubur_s1_internal.h
··· 19 19 #include "math/m_relation_history.h" 20 20 21 21 #include "blubur_s1_interface.h" 22 + #include "blubur_s1_protocol.h" 22 23 23 24 24 25 struct blubur_s1_hmd ··· 41 42 int hw2mono_samples; 42 43 43 44 struct m_relation_history *relation_history; 45 + 46 + struct os_mutex input_mutex; 47 + 48 + struct 49 + { 50 + enum blubur_s1_status_bits status; 51 + } input; 44 52 };