Monado OpenXR Runtime
Collaboration diagram for OpenXR input transformation:

Files

file  oxr_input_transform.c
 Handles transformation/filtering of input data.
 
file  oxr_input_transform.h
 Defines ways of performing (possibly multi-step) conversions of input data.
 

Data Structures

struct  oxr_input_transform_threshold_data
 Data required for INPUT_TRANSFORM_THRESHOLD. More...
 
struct  oxr_input_transform_bool_to_vec1_data
 Data required for INPUT_TRANSFORM_BOOL_TO_VEC1. More...
 
struct  oxr_input_transform_dpad_data
 Data required for INPUT_TRANSFORM_DPAD. More...
 
struct  oxr_input_transform
 Variant type for input transforms. More...
 
struct  oxr_input_value_tagged
 An input value enum with the associated tag required to interpret it. More...
 

Enumerations

enum  oxr_input_transform_type {
  INPUT_TRANSFORM_INVALID = 0 , INPUT_TRANSFORM_IDENTITY , INPUT_TRANSFORM_VEC2_GET_X , INPUT_TRANSFORM_VEC2_GET_Y ,
  INPUT_TRANSFORM_THRESHOLD , INPUT_TRANSFORM_BOOL_TO_VEC1 , INPUT_TRANSFORM_DPAD
}
 Tag for the input transform. More...
 

Functions

void oxr_input_transform::oxr_input_transform_destroy (struct oxr_input_transform **transform_ptr)
 Destroy an array of input transforms. More...
 
bool oxr_input_transform::oxr_input_transform_process (struct oxr_input_transform *transforms, size_t transform_count, const struct oxr_input_value_tagged *input, struct oxr_input_value_tagged *out)
 Apply an array of input transforms. More...
 
bool oxr_input_transform::oxr_input_transform_init_root (struct oxr_input_transform *transform, enum xrt_input_type input_type)
 Allocate an identity transform serving as the root/head of the transform chain. More...
 
bool oxr_input_transform::oxr_input_transform_init_vec2_get_x (struct oxr_input_transform *transform, const struct oxr_input_transform *parent)
 Allocate a transform to get the X component of a Vec2. More...
 
bool oxr_input_transform::oxr_input_transform_init_vec2_get_y (struct oxr_input_transform *transform, const struct oxr_input_transform *parent)
 Allocate a transform to get the Y component of a Vec2. More...
 
bool oxr_input_transform::oxr_input_transform_init_threshold (struct oxr_input_transform *transform, const struct oxr_input_transform *parent, float threshold, bool invert)
 Allocate a transform to threshold a float to a bool. More...
 
bool oxr_input_transform::oxr_input_transform_init_bool_to_vec1 (struct oxr_input_transform *transform, const struct oxr_input_transform *parent, enum xrt_input_type result_type, float true_val, float false_val)
 Allocate a transform to turn a bool into an arbitrary 1D float. More...
 
bool oxr_input_transform_create_chain (struct oxr_logger *log, struct oxr_sink_logger *slog, enum xrt_input_type input_type, XrActionType result_type, const char *action_name, const char *bound_path_string, struct oxr_input_transform **out_transforms, size_t *out_transform_count)
 Create a transform array to convert input_type to result_type. More...
 
bool oxr_input_transform_create_chain_dpad (struct oxr_logger *log, struct oxr_sink_logger *slog, enum xrt_input_type input_type, XrActionType result_type, const char *bound_path_string, struct oxr_dpad_binding_modification *dpad_binding_modification, enum oxr_dpad_region dpad_region, enum xrt_input_type activation_input_type, struct xrt_input *activation_input, struct oxr_input_transform **out_transforms, size_t *out_transform_count)
 Create a transform array to process a 2D input plus activation input to a dpad. More...
 

Detailed Description

Enumeration Type Documentation

◆ oxr_input_transform_type

#include <state_trackers/oxr/oxr_input_transform.h>

Tag for the input transform.

See also
oxr_input_transform
Enumerator
INPUT_TRANSFORM_INVALID 

Invalid value, so that zero-initialization without further assignment is caught.

INPUT_TRANSFORM_IDENTITY 

Do not modify the input.

This is only used as the root/head transform, to set the initial type.

INPUT_TRANSFORM_VEC2_GET_X 

Get the X component of a 2D float input of any range.

INPUT_TRANSFORM_VEC2_GET_Y 

Get the Y component of a 2D float input of any range.

INPUT_TRANSFORM_THRESHOLD 

Apply a threshold to any 1D float input to make a bool.

This transform type has data:

See also
oxr_input_transform_threshold_data
INPUT_TRANSFORM_BOOL_TO_VEC1 

Convert a bool to some range of 1D float input.

This transform type has data:

See also
oxr_input_transform_bool_to_vec1_data
INPUT_TRANSFORM_DPAD 

Interpret a 2D joystick or trackpad as a dpad.

This transform type has data:

See also
oxr_input_transform_dpad_data

Function Documentation

◆ oxr_input_transform_create_chain()

bool oxr_input_transform_create_chain ( struct oxr_logger log,
struct oxr_sink_logger slog,
enum xrt_input_type  input_type,
XrActionType  result_type,
const char *  action_name,
const char *  bound_path_string,
struct oxr_input_transform **  out_transforms,
size_t out_transform_count 
)
related

Create a transform array to convert input_type to result_type.

Todo:
This should be configured using knowledge from the device as well as user options/policy.
Parameters
[in]logThe logger
[in]slogThe sink logger
[in]input_typeThe type of input received from the hardware
[in]result_typeThe type of input the application requested
[in]action_nameThe action name - used for error prints only
[in]bound_path_stringThe path name string that has been bound.
[out]out_transformsA pointer that will be populated with the output array's address, or NULL.
[out]out_transform_countWhere to populate the array size
Returns
false if not possible

References OXR_MAX_INPUT_TRANSFORMS, and oxr_slog().

◆ oxr_input_transform_create_chain_dpad()

bool oxr_input_transform_create_chain_dpad ( struct oxr_logger log,
struct oxr_sink_logger slog,
enum xrt_input_type  input_type,
XrActionType  result_type,
const char *  bound_path_string,
struct oxr_dpad_binding_modification dpad_binding_modification,
enum oxr_dpad_region  dpad_region,
enum xrt_input_type  activation_input_type,
struct xrt_input activation_input,
struct oxr_input_transform **  out_transforms,
size_t out_transform_count 
)
related

Create a transform array to process a 2D input plus activation input to a dpad.

Parameters
[in]logThe logger
[in]slogThe sink logger
[in]input_typeThe type of input received from the hardware
[in]result_typeThe type of input the application requested
[in]bound_path_stringThe path name string that has been bound.
[in]dpad_settingsThe dpad settings provided by the application as a binding modification. NULL means use the defaults as per the spec.
[in]dpad_regionThe dpad region associated with this binding
[in]activation_input_typeThe type of the activation input
[in]activation_inputThe activation input, i.e. the input used to determine when the emulated dpad buttons should activate
[out]out_transformsA pointer that will be populated with the output array's address, or NULL.
[out]out_transform_countWhere to populate the array size
Returns
false if not possible

References OXR_MAX_INPUT_TRANSFORMS, and oxr_slog().

◆ oxr_input_transform_destroy()

void oxr_input_transform_destroy ( struct oxr_input_transform **  transform_ptr)

Destroy an array of input transforms.

Performs null check and sets to NULL.

◆ oxr_input_transform_init_bool_to_vec1()

bool oxr_input_transform_init_bool_to_vec1 ( struct oxr_input_transform transform,
const struct oxr_input_transform parent,
enum xrt_input_type  result_type,
float  true_val,
float  false_val 
)

Allocate a transform to turn a bool into an arbitrary 1D float.

Usually called automatically by oxr_input_transform_create_chain

Parameters
[in,out]transformA pointer to the OpenXR input transformation struct to initialize.
[in]parentThe preceding transform
[in]result_typeEither XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE or XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE
[in]true_valValue to return when true
[in]false_valValue to return when false
Precondition
parent->result_type is XRT_INPUT_TYPE_BOOLEAN

References bool_to_vec1, oxr_input_transform_bool_to_vec1_data::false_val, INPUT_TRANSFORM_BOOL_TO_VEC1, result_type, oxr_input_transform_bool_to_vec1_data::true_val, type, U_ZERO, XRT_INPUT_TYPE_BOOLEAN, XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE, and XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE.

◆ oxr_input_transform_init_root()

bool oxr_input_transform_init_root ( struct oxr_input_transform transform,
enum xrt_input_type  input_type 
)

Allocate an identity transform serving as the root/head of the transform chain.

Usually called automatically by oxr_input_transform_create_chain

Parameters
[in,out]transformA pointer to the OpenXR input transformation struct to initialize.
[in]input_typeThe native input type from the device

References INPUT_TRANSFORM_IDENTITY, result_type, type, and U_ZERO.

◆ oxr_input_transform_init_threshold()

bool oxr_input_transform_init_threshold ( struct oxr_input_transform transform,
const struct oxr_input_transform parent,
float  threshold,
bool  invert 
)

Allocate a transform to threshold a float to a bool.

Usually called automatically by oxr_input_transform_create_chain

Parameters
[in,out]transformA pointer to the OpenXR input transformation struct to initialize.
[in]parentThe preceding transform
[in]thresholdThreshold value to use
[in]invertIf true, condition is "value <= threshold" instead of "value > threshold"
Precondition
parent->result_type is XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE or XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE

References INPUT_TRANSFORM_THRESHOLD, oxr_input_transform_threshold_data::invert, result_type, oxr_input_transform_threshold_data::threshold, threshold, type, U_ZERO, XRT_INPUT_TYPE_BOOLEAN, XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE, and XRT_INPUT_TYPE_VEC1_ZERO_TO_ONE.

◆ oxr_input_transform_init_vec2_get_x()

bool oxr_input_transform_init_vec2_get_x ( struct oxr_input_transform transform,
const struct oxr_input_transform parent 
)

Allocate a transform to get the X component of a Vec2.

Usually called automatically by oxr_input_transform_create_chain

Parameters
[in,out]transformA pointer to the OpenXR input transformation struct to initialize.
[in]parentThe preceding transform
Precondition
parent->result_type is XRT_INPUT_TYPE_VEC2_MINUS_ONE_TO_ONE

References INPUT_TRANSFORM_VEC2_GET_X, result_type, type, U_ZERO, XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE, and XRT_INPUT_TYPE_VEC2_MINUS_ONE_TO_ONE.

◆ oxr_input_transform_init_vec2_get_y()

bool oxr_input_transform_init_vec2_get_y ( struct oxr_input_transform transform,
const struct oxr_input_transform parent 
)

Allocate a transform to get the Y component of a Vec2.

Usually called automatically by oxr_input_transform_create_chain

Parameters
[in,out]transformA pointer to the OpenXR input transformation struct to initialize.
[in]parentThe preceding transform
Precondition
parent->result_type is XRT_INPUT_TYPE_VEC2_MINUS_ONE_TO_ONE

References INPUT_TRANSFORM_VEC2_GET_Y, result_type, type, U_ZERO, XRT_INPUT_TYPE_VEC1_MINUS_ONE_TO_ONE, and XRT_INPUT_TYPE_VEC2_MINUS_ONE_TO_ONE.

◆ oxr_input_transform_process()

bool oxr_input_transform_process ( struct oxr_input_transform transforms,
size_t  transform_count,
const struct oxr_input_value_tagged input,
struct oxr_input_value_tagged out 
)

Apply an array of input transforms.

Parameters
[in]transformsAn array of input transforms
[in]transform_countThe number of elements in transform
[in]inputThe input value and type
[out]outThe transformed value and type
Returns
false if there was a type mismatch