The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/wmr: Minimum to bind and return a pose

+59 -4
+59 -4
src/xrt/drivers/wmr/wmr_bt_controller.c
··· 97 97 { 98 98 // struct wmr_bt_controller *d = wmr_bt_controller(xdev); 99 99 // Todo: implement 100 + struct xrt_pose pose = {{0, 0, 0, 1}, {0, 1.2, -0.5}}; 101 + if (xdev->device_type == XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER) { 102 + pose.position.x = -0.2; 103 + } else { 104 + pose.position.x = 0.2; 105 + } 106 + 107 + out_relation->pose = pose; 108 + out_relation->relation_flags = (enum xrt_space_relation_flags)( 109 + XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | 110 + XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT | XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT); 100 111 } 101 112 102 113 static void ··· 148 159 free(d); 149 160 } 150 161 162 + 163 + /* 164 + * 165 + * Bindings 166 + * 167 + */ 168 + 169 + static struct xrt_binding_input_pair simple_inputs[4] = { 170 + {XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_WMR_TRIGGER_VALUE}, 171 + {XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_WMR_MENU_CLICK}, 172 + {XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_WMR_GRIP_POSE}, 173 + {XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_WMR_AIM_POSE}, 174 + }; 175 + 176 + static struct xrt_binding_output_pair simple_outputs[1] = { 177 + {XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_WMR_HAPTIC}, 178 + }; 179 + 180 + static struct xrt_binding_profile binding_profiles[1] = { 181 + { 182 + .name = XRT_DEVICE_SIMPLE_CONTROLLER, 183 + .inputs = simple_inputs, 184 + .input_count = ARRAY_SIZE(simple_inputs), 185 + .outputs = simple_outputs, 186 + .output_count = ARRAY_SIZE(simple_outputs), 187 + }, 188 + }; 189 + 190 + 191 + /* 192 + * 193 + * 'Exported' functions. 194 + * 195 + */ 196 + 151 197 struct xrt_device * 152 198 wmr_bt_controller_create(struct os_hid_device *controller_hid, 153 199 enum xrt_device_type controller_type, ··· 155 201 { 156 202 157 203 enum u_device_alloc_flags flags = U_DEVICE_ALLOC_TRACKING_NONE; 158 - struct wmr_bt_controller *d = U_DEVICE_ALLOCATE(struct wmr_bt_controller, flags, 1, 01); 204 + struct wmr_bt_controller *d = U_DEVICE_ALLOCATE(struct wmr_bt_controller, flags, 2, 0); 159 205 160 206 d->ll = ll; 161 207 d->controller_hid = controller_hid; 162 208 209 + if (controller_type == XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER) { 210 + snprintf(d->base.str, ARRAY_SIZE(d->base.str), "WMR Left Controller"); 211 + } else { 212 + snprintf(d->base.str, ARRAY_SIZE(d->base.str), "WMR Right Controller"); 213 + } 214 + 163 215 d->base.destroy = wmr_bt_controller_destroy; 164 216 d->base.get_tracked_pose = wmr_bt_controller_get_tracked_pose; 165 217 d->base.set_output = wmr_bt_controller_set_output; 166 218 d->base.update_inputs = wmr_bt_controller_update_inputs; 167 219 168 - d->base.inputs[0].name = XRT_INPUT_GENERIC_HAND_TRACKING_LEFT; 169 - d->base.inputs[1].name = XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT; 170 - 220 + d->base.inputs[0].name = XRT_INPUT_WMR_GRIP_POSE; 221 + d->base.inputs[0].active = true; 222 + d->base.inputs[1].name = XRT_INPUT_WMR_AIM_POSE; 223 + d->base.inputs[1].active = true; 224 + d->base.binding_profiles = binding_profiles; 225 + d->base.binding_profile_count = ARRAY_SIZE(binding_profiles); 171 226 172 227 d->base.name = XRT_DEVICE_WMR_CONTROLLER; 173 228 d->base.device_type = controller_type;