Monado OpenXR Runtime
Macros | Functions | Variables
u_device.c File Reference

Misc helpers for device drivers. More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "math/m_api.h"
#include "util/u_device.h"
#include "util/u_misc.h"
Include dependency graph for u_device.c:

Macros

#define PRINT(...)   fprintf(stderr, __VA_ARGS__)
 
#define PRINT_STR(name, val)   PRINT("\t%s = %s\n", name, val)
 
#define PRINT_INT(name, val)   PRINT("\t%s = %u\n", name, val)
 
#define PRINT_MM(name, val)
 
#define PRINT_ANGLE(name, val)   PRINT("\t%s = %f (%i°)\n", name, val, (int32_t)(val * (180 / M_PI)))
 
#define PRINT_MAT2X2(name, rot)
 

Functions

void u_device_dump_config (struct xrt_device *xdev, const char *prefix, const char *prod)
 Dump the device config to stderr. More...
 
bool u_device_setup_split_side_by_side (struct xrt_device *xdev, const struct u_device_simple_info *info)
 Setup the device information given a very simple info struct. More...
 
void * u_device_allocate (enum u_device_alloc_flags flags, size_t size, size_t num_inputs, size_t num_outputs)
 Helper function to allocate a device plus inputs in the same allocation placed after the device in memory. More...
 
void u_device_free (struct xrt_device *xdev)
 Helper function to free a device and any data hanging of it. More...
 

Variables

const struct xrt_matrix_2x2 u_device_rotation_right
 
const struct xrt_matrix_2x2 u_device_rotation_left
 
const struct xrt_matrix_2x2 u_device_rotation_ident
 
const struct xrt_matrix_2x2 u_device_rotation_180
 

Detailed Description

Misc helpers for device drivers.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Macro Definition Documentation

◆ PRINT

#define PRINT (   ...)    fprintf(stderr, __VA_ARGS__)

◆ PRINT_ANGLE

#define PRINT_ANGLE (   name,
  val 
)    PRINT("\t%s = %f (%i°)\n", name, val, (int32_t)(val * (180 / M_PI)))

Referenced by u_device_dump_config().

◆ PRINT_INT

#define PRINT_INT (   name,
  val 
)    PRINT("\t%s = %u\n", name, val)

Referenced by u_device_dump_config().

◆ PRINT_MAT2X2

#define PRINT_MAT2X2 (   name,
  rot 
)
Value:
PRINT("\t%s = {%f, %f} {%f, %f}\n", name, rot.v[0], rot.v[1], \
rot.v[2], rot.v[3])
#define PRINT(...)
Definition: u_device.c:65

Referenced by u_device_dump_config().

◆ PRINT_MM

#define PRINT_MM (   name,
  val 
)
Value:
PRINT("\t%s = %f (%i.%02imm)\n", name, val, (int32_t)(val * 1000.f), \
abs((int32_t)(val * 100000.f)) % 100)
#define PRINT(...)
Definition: u_device.c:65

Referenced by u_device_dump_config().

◆ PRINT_STR

#define PRINT_STR (   name,
  val 
)    PRINT("\t%s = %s\n", name, val)

Referenced by u_device_dump_config().

Variable Documentation

◆ u_device_rotation_180

const struct xrt_matrix_2x2 u_device_rotation_180
Initial value:
= {{
.vecs =
{
{-1, 0},
{0, -1},
},
}}

◆ u_device_rotation_ident

const struct xrt_matrix_2x2 u_device_rotation_ident
Initial value:
= {{
.vecs =
{
{1, 0},
{0, 1},
},
}}

Referenced by u_device_setup_split_side_by_side().

◆ u_device_rotation_left

const struct xrt_matrix_2x2 u_device_rotation_left
Initial value:
= {{
.vecs =
{
{0, -1},
{1, 0},
},
}}

◆ u_device_rotation_right

const struct xrt_matrix_2x2 u_device_rotation_right
Initial value:
= {{
.vecs =
{
{0, 1},
{-1, 0},
},
}}