Monado OpenXR Runtime
Loading...
Searching...
No Matches
contactglove_internal.h
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Implementation of ContactGlove device driver.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup drv_contactglove
8 */
9
10#pragma once
11
12#include "xrt/xrt_device.h"
13#include "xrt/xrt_defines.h"
14
15#include "os/os_threading.h"
16
17#include "util/u_cobs.h"
18#include "util/u_var.h"
19#include "util/u_logging.h"
21
23
27
28
29/*!
30 * A dongle for ContactGlove gloves.
31 *
32 * @implements xrt_reference
33 */
35{
36 struct xrt_reference base;
37
38 enum u_logging_level log_level;
39
40 struct os_mutex data_lock;
42
43 struct os_serial_device *dongle_serial;
44 enum contactglove_type type;
45
46 struct u_cobs_decoder cobs_decoder;
47
48 uint8_t last_sent_ping_nonce;
49 timepoint_ns last_ping_send;
50
51 struct contactglove_version version;
52 uint8_t channel;
53
54 struct contactglove_device *left_glove;
55 struct contactglove_device *right_glove;
56};
57
58enum contactglove_device_inputs
59{
60 CONTACTGLOVE_DEVICE_INPUT_HT_UNOBSTRUCTED = 0,
61 CONTACTGLOVE_DEVICE_INPUT_A_CLICK,
62 CONTACTGLOVE_DEVICE_INPUT_B_CLICK,
63 CONTACTGLOVE_DEVICE_INPUT_X_CLICK,
64 CONTACTGLOVE_DEVICE_INPUT_Y_CLICK,
65 CONTACTGLOVE_DEVICE_INPUT_SYSTEM_CLICK,
66 CONTACTGLOVE_DEVICE_INPUT_PAIRING_CLICK,
67 CONTACTGLOVE_DEVICE_INPUT_TRIGGER_VALUE,
68 CONTACTGLOVE_DEVICE_INPUT_TRIGGER_CLICK,
69 CONTACTGLOVE_DEVICE_INPUT_SQUEEZE_VALUE,
70 CONTACTGLOVE_DEVICE_INPUT_THUMBSTICK,
71 CONTACTGLOVE_DEVICE_INPUT_THUMBSTICK_CLICK,
72 CONTACTGLOVE_DEVICE_INPUT_GRIP_POSE,
73 CONTACTGLOVE_DEVICE_INPUT_AIM_POSE,
74 CONTACTGLOVE_DEVICE_INPUT_COUNT,
75};
76
77/*!
78 * A single ContactGlove glove.
79 *
80 * @implements xrt_device
81 */
83{
84 struct xrt_device base;
85
86 struct contactglove_dongle *dongle;
87
88 struct contactglove_version version;
89 struct contactglove_raw_battery_info raw_battery;
90
91 uint8_t last_received_ping_nonce;
92 timepoint_ns last_ping_receive;
93 uint16_t glove_to_dongle_ms;
94
95 //! Whether this glove is actively connected to the dongle
97
98 bool magnetra2_connected;
99
100 timepoint_ns raw_input_update_time_ns;
102
103 timepoint_ns avg_glove_to_dongle_offset_ns;
104
105 bool module_state_valid[CONTACTGLOVE_MODULE_MAX];
106 struct contactglove_module_state_magnetra2 module_state_magnetra2;
107 struct contactglove_module_state_sleep_manager module_state_sleep_manager;
108 struct contactglove_module_state_led_manager module_state_led_manager;
109
110 struct m_relation_history *relation_history;
111 struct xrt_quat latest_orientation;
112
113 uint16_t raw_flex_adc_values[CONTACTGLOVE2_SENSOR_COUNT];
114 struct u_var_u16_arr u_var_flex_adc_values;
115
116 struct contactglove_calibration_wizard calibration_wizard;
117
118 enum xrt_hand hand;
119 enum contactglove_device_role role;
120};
ContactGlove device calibration implementation.
Interface to drv_contactglove.
Implementation of ContactGlove device driver.
u_logging_level
Logging level enum.
Definition u_logging.h:45
int64_t timepoint_ns
Integer timestamp type.
Definition u_time.h:77
xrt_hand
Enumeration for left and right hand.
Definition xrt_defines.h:1568
Small utility for keeping track of the history of an xrt_space_relation, ie.
Wrapper around OS threading native functions.
A type which manages the state of the currently-running calibration step.
Definition contactglove_calibration.h:226
A single ContactGlove glove.
Definition contactglove_internal.h:83
bool connected
Whether this glove is actively connected to the dongle.
Definition contactglove_internal.h:96
A dongle for ContactGlove gloves.
Definition contactglove_internal.h:35
Definition contactglove_protocol.h:198
Definition contactglove_protocol.h:183
Definition contactglove_protocol.h:189
Definition contactglove_protocol.h:75
Definition contactglove_protocol.h:151
Definition contactglove_protocol.h:61
Definition m_relation_history.cpp:50
A wrapper around a native mutex.
Definition os_threading.h:69
Representing a single serial interface on a device.
Definition os_serial.h:33
All in one helper that handles locking, waiting for change and starting a thread.
Definition os_threading.h:500
Definition u_worker.c:38
A streaming COBS (Consistent Overhead Byte Stuffing) decoder with automatic error recovery.
Definition u_cobs.h:32
Definition u_var.h:42
A single HMD or input device.
Definition xrt_device.h:328
A quaternion with single floats.
Definition xrt_defines.h:246
A base class for reference counted objects.
Definition xrt_defines.h:99
Code to decode and encode COBS (Consistent Overhead Byte Stuffing) packet data.
Hand Tracking API interface.
Basic logging functionality.
Variable tracking code.
Common defines and enums for XRT.
Header defining an xrt display or controller device.