Monado OpenXR Runtime
simulated_controller.c File Reference

Simulated controller device. More...

#include "xrt/xrt_device.h"
#include "os/os_time.h"
#include "math/m_api.h"
#include "math/m_mathinclude.h"
#include "util/u_var.h"
#include "util/u_misc.h"
#include "util/u_time.h"
#include "util/u_debug.h"
#include "util/u_device.h"
#include "util/u_logging.h"
#include "util/u_distortion_mesh.h"
#include "simulated_interface.h"
#include <stdio.h>
#include <assert.h>
Include dependency graph for simulated_controller.c:

Data Structures

struct  simulated_device
 

Macros

#define CHECK_THAT_NAME_IS_AND_ERROR(NAME)
 

Functions

static struct simulated_devicesimulated_device (struct xrt_device *xdev)
 
static const char * device_type_to_printable_handedness (enum xrt_device_type type)
 
static void simulated_device_destroy (struct xrt_device *xdev)
 
static xrt_result_t simulated_device_update_inputs (struct xrt_device *xdev)
 
static xrt_result_t simulated_device_get_tracked_pose (struct xrt_device *xdev, enum xrt_input_name name, int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
 
static void simulated_device_get_hand_tracking (struct xrt_device *xdev, enum xrt_input_name name, int64_t requested_timestamp_ns, struct xrt_hand_joint_set *out_value, int64_t *out_timestamp_ns)
 
static void simulated_device_get_view_poses (struct xrt_device *xdev, const struct xrt_vec3 *default_eye_relation, int64_t at_timestamp_ns, uint32_t view_count, struct xrt_space_relation *out_head_relation, struct xrt_fov *out_fovs, struct xrt_pose *out_poses)
 
static void simulated_device_set_output (struct xrt_device *xdev, enum xrt_output_name name, const union xrt_output_value *value)
 
struct xrt_devicesimulated_create_controller (enum xrt_device_name name, enum xrt_device_type type, const struct xrt_pose *center, struct xrt_tracking_origin *origin)
 Create a simulated controller. More...
 

Variables

static enum xrt_input_name simple_inputs_array []
 
static enum xrt_output_name simple_outputs_array []
 
static enum xrt_input_name wmr_inputs_array []
 
static enum xrt_output_name wmr_outputs_array []
 
static struct xrt_binding_input_pair wmr_to_simple_inputs [4]
 
static struct xrt_binding_output_pair wmr_to_simple_outputs [1]
 
static struct xrt_binding_profile wmr_binding_profiles [1]
 
static enum xrt_input_name ml2_inputs_array []
 
static enum xrt_output_name ml2_outputs_array []
 
static struct xrt_binding_input_pair ml2_to_simple_inputs [4]
 
static struct xrt_binding_output_pair ml2_to_simple_outputs [1]
 
static struct xrt_binding_input_pair ml2_to_vive_wand_inputs [9]
 
static struct xrt_binding_output_pair ml2_to_vive_wand_outputs [1]
 
static struct xrt_binding_profile ml2_binding_profiles [2]
 

Detailed Description

Simulated controller device.

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

Macro Definition Documentation

◆ CHECK_THAT_NAME_IS_AND_ERROR

#define CHECK_THAT_NAME_IS_AND_ERROR (   NAME)
Value:
do { \
if (sd->base.name != NAME) { \
U_LOG_XDEV_UNSUPPORTED_INPUT(&sd->base, u_log_get_global_level(), name); \
} \
} while (false)
enum u_logging_level u_log_get_global_level(void)
Returns the global logging level, subsystems own logging level take precedence.
Definition: u_logging.c:68
@ XRT_ERROR_INPUT_UNSUPPORTED
The input provided is a valid value from the enum xrt_input_name but is not supported by the driver.
Definition: xrt_results.h:206

Variable Documentation

◆ ml2_binding_profiles

struct xrt_binding_profile ml2_binding_profiles[2]
static
Initial value:
= {
{
.name = XRT_DEVICE_SIMPLE_CONTROLLER,
.inputs = ml2_to_simple_inputs,
.input_count = ARRAY_SIZE(ml2_to_simple_inputs),
.outputs = ml2_to_simple_outputs,
.output_count = ARRAY_SIZE(ml2_to_simple_outputs),
},
{
.name = XRT_DEVICE_VIVE_WAND,
.inputs = ml2_to_vive_wand_inputs,
.input_count = ARRAY_SIZE(ml2_to_vive_wand_inputs),
.outputs = ml2_to_vive_wand_outputs,
.output_count = ARRAY_SIZE(ml2_to_vive_wand_outputs),
},
}
#define ARRAY_SIZE(a)
Array size helper.
Definition: xrt_compiler.h:30

◆ ml2_inputs_array

enum xrt_input_name ml2_inputs_array[]
static
Initial value:
= {
XRT_INPUT_ML2_CONTROLLER_MENU_CLICK, XRT_INPUT_ML2_CONTROLLER_SELECT_CLICK,
XRT_INPUT_ML2_CONTROLLER_TRIGGER_CLICK, XRT_INPUT_ML2_CONTROLLER_TRIGGER_VALUE,
XRT_INPUT_ML2_CONTROLLER_TRACKPAD_CLICK, XRT_INPUT_ML2_CONTROLLER_TRACKPAD_TOUCH,
XRT_INPUT_ML2_CONTROLLER_TRACKPAD_FORCE, XRT_INPUT_ML2_CONTROLLER_TRACKPAD,
XRT_INPUT_ML2_CONTROLLER_GRIP_POSE, XRT_INPUT_ML2_CONTROLLER_AIM_POSE,
XRT_INPUT_ML2_CONTROLLER_SHOULDER_CLICK,
}

◆ ml2_outputs_array

enum xrt_output_name ml2_outputs_array[]
static
Initial value:
= {
XRT_OUTPUT_NAME_ML2_CONTROLLER_VIBRATION,
}

◆ ml2_to_simple_inputs

struct xrt_binding_input_pair ml2_to_simple_inputs[4]
static
Initial value:
= {
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_ML2_CONTROLLER_TRIGGER_VALUE},
{XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_ML2_CONTROLLER_MENU_CLICK},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_ML2_CONTROLLER_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_ML2_CONTROLLER_AIM_POSE},
}

◆ ml2_to_simple_outputs

struct xrt_binding_output_pair ml2_to_simple_outputs[1]
static
Initial value:
= {
{XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_INDEX_HAPTIC},
}

◆ ml2_to_vive_wand_inputs

struct xrt_binding_input_pair ml2_to_vive_wand_inputs[9]
static
Initial value:
= {
{XRT_INPUT_VIVE_GRIP_POSE, XRT_INPUT_ML2_CONTROLLER_GRIP_POSE},
{XRT_INPUT_VIVE_AIM_POSE, XRT_INPUT_ML2_CONTROLLER_AIM_POSE},
{XRT_INPUT_VIVE_TRIGGER_CLICK, XRT_INPUT_ML2_CONTROLLER_TRIGGER_CLICK},
{XRT_INPUT_VIVE_TRIGGER_VALUE, XRT_INPUT_ML2_CONTROLLER_TRIGGER_VALUE},
{XRT_INPUT_VIVE_SQUEEZE_CLICK, XRT_INPUT_ML2_CONTROLLER_SHOULDER_CLICK},
{XRT_INPUT_VIVE_MENU_CLICK, XRT_INPUT_ML2_CONTROLLER_MENU_CLICK},
{XRT_INPUT_VIVE_TRACKPAD, XRT_INPUT_ML2_CONTROLLER_TRACKPAD},
{XRT_INPUT_VIVE_TRACKPAD_TOUCH, XRT_INPUT_ML2_CONTROLLER_TRACKPAD_TOUCH},
{XRT_INPUT_VIVE_TRACKPAD_CLICK, XRT_INPUT_ML2_CONTROLLER_TRACKPAD_CLICK},
}

◆ ml2_to_vive_wand_outputs

struct xrt_binding_output_pair ml2_to_vive_wand_outputs[1]
static
Initial value:
= {
{XRT_OUTPUT_NAME_VIVE_HAPTIC, XRT_OUTPUT_NAME_ML2_CONTROLLER_VIBRATION},
}

◆ simple_inputs_array

enum xrt_input_name simple_inputs_array[]
static
Initial value:
= {
XRT_INPUT_SIMPLE_SELECT_CLICK,
XRT_INPUT_SIMPLE_MENU_CLICK,
XRT_INPUT_SIMPLE_GRIP_POSE,
XRT_INPUT_SIMPLE_AIM_POSE,
}

◆ simple_outputs_array

enum xrt_output_name simple_outputs_array[]
static
Initial value:
= {
XRT_OUTPUT_NAME_SIMPLE_VIBRATION,
}

◆ wmr_binding_profiles

struct xrt_binding_profile wmr_binding_profiles[1]
static
Initial value:
= {
{
.name = XRT_DEVICE_SIMPLE_CONTROLLER,
.inputs = wmr_to_simple_inputs,
.input_count = ARRAY_SIZE(wmr_to_simple_inputs),
.outputs = wmr_to_simple_outputs,
.output_count = ARRAY_SIZE(wmr_to_simple_outputs),
},
}

◆ wmr_inputs_array

enum xrt_input_name wmr_inputs_array[]
static
Initial value:
= {
XRT_INPUT_WMR_MENU_CLICK, XRT_INPUT_WMR_SQUEEZE_CLICK, XRT_INPUT_WMR_TRIGGER_VALUE,
XRT_INPUT_WMR_THUMBSTICK_CLICK, XRT_INPUT_WMR_THUMBSTICK, XRT_INPUT_WMR_TRACKPAD_CLICK,
XRT_INPUT_WMR_TRACKPAD_TOUCH, XRT_INPUT_WMR_TRACKPAD, XRT_INPUT_WMR_GRIP_POSE,
XRT_INPUT_WMR_AIM_POSE,
}

◆ wmr_outputs_array

enum xrt_output_name wmr_outputs_array[]
static
Initial value:
= {
XRT_OUTPUT_NAME_WMR_HAPTIC,
}

◆ wmr_to_simple_inputs

struct xrt_binding_input_pair wmr_to_simple_inputs[4]
static
Initial value:
= {
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_WMR_TRIGGER_VALUE},
{XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_WMR_MENU_CLICK},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_WMR_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_WMR_AIM_POSE},
}

◆ wmr_to_simple_outputs

struct xrt_binding_output_pair wmr_to_simple_outputs[1]
static
Initial value:
= {
{XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_INDEX_HAPTIC},
}