The open source OpenXR runtime

d/vive_controller: index controller trackpad: send 0,0 position after release

authored by

Christoph Haag and committed by
Jakob Bornecrantz
f8b2e179 344846b3

+11 -4
+11 -4
src/xrt/drivers/vive/vive_controller_driver.c
··· 302 302 printf("\n"); 303 303 */ 304 304 305 + bool was_trackpad_touched = 306 + d->base.inputs[VIVE_CONTROLLER_INDEX_TRACKPAD_TOUCH].value.boolean; 307 + 305 308 uint64_t now = os_monotonic_get_ns(); 306 309 307 310 /* d->state.buttons is bitmask of currently pressed buttons. ··· 333 336 } 334 337 d->state.last_buttons = d->state.buttons; 335 338 339 + bool is_trackpad_touched = 340 + d->base.inputs[VIVE_CONTROLLER_INDEX_TRACKPAD_TOUCH].value.boolean; 336 341 337 342 /* trackpad and thumbstick position are the same usb events. 338 343 * report trackpad position when trackpad has been touched last, and 339 344 * thumbstick position when trackpad touch has been released 340 345 */ 341 346 struct xrt_input *thumb_input; 342 - bool trackpad_touched = 343 - d->base.inputs[VIVE_CONTROLLER_INDEX_TRACKPAD_TOUCH].value.boolean; 344 - if (trackpad_touched) 347 + 348 + // after releasing trackpad, next 0,0 position still goes to trackpad 349 + if (is_trackpad_touched || was_trackpad_touched) 345 350 thumb_input = &d->base.inputs[VIVE_CONTROLLER_INDEX_TRACKPAD]; 346 351 else 347 352 thumb_input = &d->base.inputs[VIVE_CONTROLLER_INDEX_THUMBSTICK]; ··· 349 354 thumb_input->value.vec2.x = d->state.trackpad.x; 350 355 thumb_input->value.vec2.y = d->state.trackpad.y; 351 356 352 - const char *component = trackpad_touched ? "Trackpad" : "Thumbstick"; 357 + const char *component = is_trackpad_touched || was_trackpad_touched 358 + ? "Trackpad" 359 + : "Thumbstick"; 353 360 VIVE_CONTROLLER_SPEW(d, "%s: %f, %f", component, d->state.trackpad.x, 354 361 d->state.trackpad.y); 355 362