The open source OpenXR runtime
at prediction 93 lines 1.7 kB view raw
1// Copyright 2020, Collabora, Ltd. 2// SPDX-License-Identifier: BSL-1.0 3/*! 4 * @file 5 * @brief Interface to Android sensors prober code. 6 * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com> 7 * @ingroup drv_android 8 */ 9 10#include <stdio.h> 11#include <stdlib.h> 12#include <wchar.h> 13 14#include "xrt/xrt_prober.h" 15 16#include "util/u_misc.h" 17#include "util/u_debug.h" 18#include "util/u_logging.h" 19 20#include "android_prober.h" 21#include "android_sensors.h" 22 23 24 25/* 26 * 27 * Defines & structs. 28 * 29 */ 30 31/*! 32 * Android prober struct. 33 * 34 * @ingroup drv_android 35 * @implements xrt_auto_prober 36 */ 37struct android_prober 38{ 39 struct xrt_auto_prober base; 40}; 41 42 43/* 44 * 45 * Static functions. 46 * 47 */ 48 49//! @private @memberof android_prober 50static inline struct android_prober * 51android_prober(struct xrt_auto_prober *p) 52{ 53 return (struct android_prober *)p; 54} 55 56//! @public @memberof android_prober 57static void 58android_prober_destroy(struct xrt_auto_prober *p) 59{ 60 struct android_prober *pandroid = android_prober(p); 61 free(pandroid); 62} 63 64//! @public @memberof android_prober 65static int 66android_prober_autoprobe(struct xrt_auto_prober *xap, 67 cJSON *attached_data, 68 bool no_hmds, 69 struct xrt_prober *xp, 70 struct xrt_device **out_xdevs) 71{ 72 struct android_device *dd = android_device_create(); 73 out_xdevs[0] = &dd->base; 74 return 1; 75} 76 77 78/* 79 * 80 * Exported functions. 81 * 82 */ 83 84struct xrt_auto_prober * 85android_create_auto_prober(void) 86{ 87 struct android_prober *p = U_TYPED_CALLOC(struct android_prober); 88 p->base.name = "Android"; 89 p->base.destroy = android_prober_destroy; 90 p->base.lelo_dallas_autoprobe = android_prober_autoprobe; 91 92 return &p->base; 93}