The open source OpenXR runtime
0
fork

Configure Feed

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

t/libmonado: Add property enum and getters for devices

+180 -1
+86
src/xrt/targets/libmonado/monado.c
··· 295 295 } 296 296 297 297 mnd_result_t 298 + mnd_root_get_device_info_bool(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, bool *out_bool) 299 + { 300 + CHECK_NOT_NULL(root); 301 + CHECK_NOT_NULL(out_bool); 302 + 303 + if (device_index >= root->ipc_c.ism->isdev_count) { 304 + PE("Invalid device index (%u)", device_index); 305 + return MND_ERROR_INVALID_VALUE; 306 + } 307 + 308 + PE("Is not a valid boolean property (%u)", prop); 309 + 310 + return MND_ERROR_INVALID_PROPERTY; 311 + } 312 + 313 + mnd_result_t 314 + mnd_root_get_device_info_i32(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, uint32_t *out_i32) 315 + { 316 + CHECK_NOT_NULL(root); 317 + CHECK_NOT_NULL(out_i32); 318 + 319 + if (device_index >= root->ipc_c.ism->isdev_count) { 320 + PE("Invalid device index (%u)", device_index); 321 + return MND_ERROR_INVALID_VALUE; 322 + } 323 + 324 + PE("Is not a valid i32 property (%u)", prop); 325 + 326 + return MND_ERROR_INVALID_PROPERTY; 327 + } 328 + 329 + mnd_result_t 330 + mnd_root_get_device_info_u32(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, uint32_t *out_u32) 331 + { 332 + CHECK_NOT_NULL(root); 333 + CHECK_NOT_NULL(out_u32); 334 + 335 + if (device_index >= root->ipc_c.ism->isdev_count) { 336 + PE("Invalid device index (%u)", device_index); 337 + return MND_ERROR_INVALID_VALUE; 338 + } 339 + 340 + PE("Is not a valid u32 property (%u)", prop); 341 + 342 + return MND_ERROR_INVALID_PROPERTY; 343 + } 344 + 345 + mnd_result_t 346 + mnd_root_get_device_info_float(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, float *out_float) 347 + { 348 + CHECK_NOT_NULL(root); 349 + CHECK_NOT_NULL(out_float); 350 + 351 + if (device_index >= root->ipc_c.ism->isdev_count) { 352 + PE("Invalid device index (%u)", device_index); 353 + return MND_ERROR_INVALID_VALUE; 354 + } 355 + 356 + PE("Is not a valid float property (%u)", prop); 357 + 358 + return MND_ERROR_INVALID_PROPERTY; 359 + } 360 + 361 + mnd_result_t 362 + mnd_root_get_device_info_string(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, const char **out_string) 363 + { 364 + CHECK_NOT_NULL(root); 365 + CHECK_NOT_NULL(out_string); 366 + 367 + if (device_index >= root->ipc_c.ism->isdev_count) { 368 + PE("Invalid device index (%u)", device_index); 369 + return MND_ERROR_INVALID_VALUE; 370 + } 371 + 372 + const struct ipc_shared_device *shared_device = &root->ipc_c.ism->isdevs[device_index]; 373 + 374 + switch (prop) { 375 + case MND_PROPERTY_NAME_STRING: *out_string = shared_device->str; break; 376 + case MND_PROPERTY_SERIAL_STRING: *out_string = shared_device->serial; break; 377 + default: PE("Is not a valid string property (%u)", prop); return MND_ERROR_INVALID_PROPERTY; 378 + } 379 + 380 + return MND_SUCCESS; 381 + } 382 + 383 + mnd_result_t 298 384 mnd_root_get_device_info(mnd_root_t *root, uint32_t device_index, uint32_t *out_device_id, const char **out_dev_name) 299 385 { 300 386 CHECK_NOT_NULL(root);
+94 -1
src/xrt/targets/libmonado/monado.h
··· 8 8 */ 9 9 10 10 #include <stdint.h> 11 + #include <stdbool.h> 11 12 12 13 13 14 #ifdef __cplusplus ··· 24 25 //! Major version of the API. 25 26 #define MND_API_VERSION_MAJOR 1 26 27 //! Minor version of the API. 27 - #define MND_API_VERSION_MINOR 1 28 + #define MND_API_VERSION_MINOR 2 28 29 //! Patch version of the API. 29 30 #define MND_API_VERSION_PATCH 0 30 31 ··· 41 42 MND_ERROR_OPERATION_FAILED = -4, 42 43 //! Supported in version 1.1 and above. 43 44 MND_ERROR_RECENTERING_NOT_SUPPORTED = -5, 45 + //! Supported in version 1.2 and above. 46 + MND_ERROR_INVALID_PROPERTY = -6, 44 47 } mnd_result_t; 45 48 46 49 /*! ··· 55 58 MND_CLIENT_SESSION_OVERLAY = (1u << 4u), 56 59 MND_CLIENT_IO_ACTIVE = (1u << 5u), 57 60 } mnd_client_flags_t; 61 + 62 + /*! 63 + * A property to get from a thing (currently only devices). 64 + * 65 + * Supported in version 1.2 and above. 66 + */ 67 + typedef enum mnd_property 68 + { 69 + //! Supported in version 1.2 and above. 70 + MND_PROPERTY_NAME_STRING = 0, 71 + //! Supported in version 1.2 and above. 72 + MND_PROPERTY_SERIAL_STRING = 1, 73 + } mnd_property_t; 58 74 59 75 /*! 60 76 * Opaque type for libmonado state ··· 217 233 mnd_root_get_device_count(mnd_root_t *root, uint32_t *out_device_count); 218 234 219 235 /*! 236 + * Get boolean property for the device at the given index. 237 + * 238 + * Supported in version 1.2 and above. 239 + * 240 + * @param root The libmonado state. 241 + * @param device_index Index of device to retrieve name from. 242 + * @param prop A boolean property enum. 243 + * @param[out] out_bool Pointer to populate with the boolean. 244 + * 245 + * @return MND_SUCCESS on success 246 + */ 247 + mnd_result_t 248 + mnd_root_get_device_info_bool(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, bool *out_bool); 249 + 250 + /*! 251 + * Get int32_t property for the device at the given index. 252 + * 253 + * Supported in version 1.2 and above. 254 + * 255 + * @param root The libmonado state. 256 + * @param device_index Index of device to retrieve name from. 257 + * @param prop A int32_t property enum. 258 + * @param[out] out_i32 Pointer to populate with the int32_t. 259 + * 260 + * @return MND_SUCCESS on success 261 + */ 262 + mnd_result_t 263 + mnd_root_get_device_info_i32(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, uint32_t *out_i32); 264 + 265 + /*! 266 + * Get uint32_t property for the device at the given index. 267 + * 268 + * Supported in version 1.2 and above. 269 + * 270 + * @param root The libmonado state. 271 + * @param device_index Index of device to retrieve name from. 272 + * @param prop A uint32_t property enum. 273 + * @param[out] out_u32 Pointer to populate with the uint32_t. 274 + * 275 + * @return MND_SUCCESS on success 276 + */ 277 + mnd_result_t 278 + mnd_root_get_device_info_u32(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, uint32_t *out_u32); 279 + 280 + /*! 281 + * Get float property for the device at the given index. 282 + * 283 + * Supported in version 1.2 and above. 284 + * 285 + * @param root The libmonado state. 286 + * @param device_index Index of device to retrieve name from. 287 + * @param prop A float property enum. 288 + * @param[out] out_float Pointer to populate with the float. 289 + * 290 + * @return MND_SUCCESS on success 291 + */ 292 + mnd_result_t 293 + mnd_root_get_device_info_float(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, float *out_float); 294 + 295 + /*! 296 + * Get string property for the device at the given index. 297 + * 298 + * Supported in version 1.2 and above. 299 + * 300 + * @param root The libmonado state. 301 + * @param device_index Index of device to retrieve name from. 302 + * @param prop A string property enum. 303 + * @param[out] out_string Pointer to populate with the string. 304 + * 305 + * @return MND_SUCCESS on success 306 + */ 307 + mnd_result_t 308 + mnd_root_get_device_info_string(mnd_root_t *root, uint32_t device_index, mnd_property_t prop, const char **out_string); 309 + 310 + /*! 220 311 * Get device info at the given index. 312 + * 313 + * @deprecated Deprecated in version 1.2, scheduled for removal in version 2.0.0 currently. 221 314 * 222 315 * @param root The libmonado state. 223 316 * @param device_index Index of device to retrieve name from.