Monado OpenXR Runtime
Loading...
Searching...
No Matches
contactglove.c File Reference

Implementation of ContactGlove device driver. More...

#include <xrt/xrt_device.h>
#include <util/u_logging.h>
#include <util/u_misc.h>
#include <util/u_device.h>
#include <util/u_debug.h>
#include <util/u_var.h>
#include <util/u_cobs.h>
#include <util/u_hand_simulation.h>
#include <math/m_api.h>
#include "contactglove_interface.h"
#include "contactglove.h"
#include <unistd.h>
#include <errno.h>
Include dependency graph for contactglove.c:

Macros

#define DONGLE_TRACE(dongle, ...)   U_LOG_IFL_T(dongle->log_level, __VA_ARGS__)
 
#define DONGLE_DEBUG(dongle, ...)   U_LOG_IFL_D(dongle->log_level, __VA_ARGS__)
 
#define DONGLE_INFO(dongle, ...)   U_LOG_IFL_I(dongle->log_level, __VA_ARGS__)
 
#define DONGLE_WARN(dongle, ...)   U_LOG_IFL_W(dongle->log_level, __VA_ARGS__)
 
#define DONGLE_ERROR(dongle, ...)   U_LOG_IFL_E(dongle->log_level, __VA_ARGS__)
 
#define GLOVE_TRACE(glove, ...)   U_LOG_XDEV_IFL_T(&glove->base, glove->dongle->log_level, __VA_ARGS__)
 
#define GLOVE_DEBUG(glove, ...)   U_LOG_XDEV_IFL_D(&glove->base, glove->dongle->log_level, __VA_ARGS__)
 
#define GLOVE_INFO(glove, ...)   U_LOG_XDEV_IFL_I(&glove->base, glove->dongle->log_level, __VA_ARGS__)
 
#define GLOVE_WARN(glove, ...)   U_LOG_XDEV_IFL_W(&glove->base, glove->dongle->log_level, __VA_ARGS__)
 
#define GLOVE_ERROR(glove, ...)   U_LOG_XDEV_IFL_E(&glove->base, glove->dongle->log_level, __VA_ARGS__)
 
#define UPDATE_TIME(name)    glove->base.inputs[CONTACTGLOVE_DEVICE_INPUT_##name].timestamp = glove->raw_input_update_time_ns;
 
#define UPDATE_BOOL(name, exp)
 
#define CHECK_RANGE(range)
 
#define SET_INPUT(input_name)    contactglove->base.inputs[CONTACTGLOVE_DEVICE_INPUT_##input_name].name = XRT_INPUT_MAGNETRA2_##input_name;
 

Functions

static void contactglove_none_curl_cal_callback (void *ptr)
 
static void contactglove_full_curl_cal_callback (void *ptr)
 
static void contactglove_dongle_destroy (struct contactglove_dongle *dongle)
 
static void contactglove_dongle_decrement (struct contactglove_dongle *dongle)
 
static uint8_t crc8 (const uint8_t *data, size_t length)
 
static ssize_t contactglove_dongle_write (struct contactglove_dongle *dongle, const uint8_t *data, size_t length)
 
static int contactglove_dongle_send_packet_locked (struct contactglove_dongle *dongle, enum contactglove_to_device_packet_mode mode, const uint8_t *payload, size_t payload_length)
 
static int contactglove_send_ping (struct contactglove_dongle *dongle, uint8_t nonce)
 
static void contactglove_ping_handle_glove_timeout (struct contactglove_dongle *dongle, struct contactglove_device *glove, timepoint_ns now)
 
static int contactglove_request_module_state_locked (struct contactglove_dongle *dongle, struct contactglove_device *glove, enum contactglove_module_kind module_kind)
 
static int contactglove_set_module_state_locked (struct contactglove_dongle *dongle, struct contactglove_device *glove, enum contactglove_module_kind module, const uint8_t *data, size_t length)
 
static int contactglove_request_update_module_state_locked (struct contactglove_dongle *dongle, struct contactglove_device *glove)
 
static int contactglove_ping_tick (struct contactglove_dongle *dongle, timepoint_ns now)
 
static int contactglove_dongle_thread_tick (struct contactglove_dongle *dongle)
 
static void contactglove_dongle_handle_packet (void *user_data, const uint8_t *data, size_t length)
 
void * contactglove_dongle_thread (void *ptr)
 
static void contactglove_get_curl_values (struct contactglove_device *glove, struct u_hand_tracking_curl_values *curl_values)
 
static xrt_result_t contactglove_get_tracked_pose (struct xrt_device *xdev, const enum xrt_input_name name, const int64_t at_timestamp_ns, struct xrt_space_relation *out_relation)
 
static void contactglove_destroy (struct xrt_device *xdev)
 
static xrt_result_t contactglove_get_battery_status (struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
 
static xrt_result_t contactglove_get_hand_tracking (struct xrt_device *xdev, enum xrt_input_name name, int64_t desired_timestamp_ns, struct xrt_hand_joint_set *out_value, int64_t *out_timestamp_ns)
 
static xrt_result_t contactglove_update_inputs (struct xrt_device *xdev)
 
static int contactglove_create_glove (struct contactglove_dongle *dongle, enum contactglove_type type, const char *serial_number, enum xrt_hand hand, struct contactglove_device **out_glove)
 
int contactglove_create (enum contactglove_type type, const char *serial_number, struct os_serial_device *dongle_serial, struct contactglove_dongle **out_dongle, struct xrt_device **out_xdevs)
 
int contactglove_dongle_pair (struct contactglove_dongle *dongle)
 Enable pairing mode on the ContactGlove dongle.
 

Detailed Description

Implementation of ContactGlove device driver.

Author
Beyley Cardellio ep1cm.nosp@m.1n10.nosp@m.n123@.nosp@m.gmai.nosp@m.l.com

Macro Definition Documentation

◆ CHECK_RANGE

#define CHECK_RANGE (   range)
Value:
(glove->raw_input.multi_ch_value >= MAGNETRA2_MULTI_CH_RANGE_##range##_START && \
glove->raw_input.multi_ch_value <= MAGNETRA2_MULTI_CH_RANGE_##range##_END)

◆ UPDATE_BOOL

#define UPDATE_BOOL (   name,
  exp 
)
Value:
glove->base.inputs[CONTACTGLOVE_DEVICE_INPUT_##name].value.boolean = (exp); \
UPDATE_TIME(name)

Function Documentation

◆ contactglove_dongle_pair()

int contactglove_dongle_pair ( struct contactglove_dongle dongle)

Enable pairing mode on the ContactGlove dongle.