The open source OpenXR runtime
0
fork

Configure Feed

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

d/qwerty: Switch simulated controllers to WMR controllers

Previously the qwerty driver simulated Khronos simple controllers with 2 buttons. Now it simulates Windows Mixed Reality controllers with 4 buttons, a thumbstick and a trackpad. This is enough to properly control most VR games.

v2: Clarify a comment about aim pose not implemented

co-authored-by: Christoph Haag <christoph.haag@collabora.com>

v3: Re-add simple khronos controller bindings

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2355>

authored by

Tuupertunut
Christoph Haag
and committed by
Christoph Haag
815bf167 c442fc5c

+321 -40
+170 -28
src/xrt/drivers/qwerty/qwerty_device.c
··· 40 40 // clang-format on 41 41 42 42 // Indices for fake controller input components 43 - #define QWERTY_SELECT 0 43 + #define QWERTY_TRIGGER 0 44 44 #define QWERTY_MENU 1 45 - #define QWERTY_GRIP 2 46 - #define QWERTY_AIM 3 45 + #define QWERTY_SQUEEZE 2 46 + #define QWERTY_SYSTEM 3 47 + #define QWERTY_THUMBSTICK 4 48 + #define QWERTY_THUMBSTICK_CLICK 5 49 + #define QWERTY_TRACKPAD 6 50 + #define QWERTY_TRACKPAD_TOUCH 7 51 + #define QWERTY_TRACKPAD_CLICK 8 52 + #define QWERTY_GRIP 9 53 + #define QWERTY_AIM 10 47 54 #define QWERTY_VIBRATION 0 48 55 49 56 #define QWERTY_TRACE(qd, ...) U_LOG_XDEV_IFL_T(&qd->base, qd->sys->log_level, __VA_ARGS__) ··· 52 59 #define QWERTY_WARN(qd, ...) U_LOG_XDEV_IFL_W(&qd->base, qd->sys->log_level, __VA_ARGS__) 53 60 #define QWERTY_ERROR(qd, ...) U_LOG_XDEV_IFL_E(&qd->base, qd->sys->log_level, __VA_ARGS__) 54 61 62 + static struct xrt_binding_input_pair simple_inputs[4] = { 63 + {XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_WMR_TRIGGER_VALUE}, 64 + {XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_WMR_MENU_CLICK}, 65 + {XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_WMR_GRIP_POSE}, 66 + {XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_WMR_AIM_POSE}, 67 + }; 68 + 69 + static struct xrt_binding_output_pair simple_outputs[1] = { 70 + {XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_WMR_HAPTIC}, 71 + }; 72 + 73 + static struct xrt_binding_profile binding_profiles[1] = { 74 + { 75 + .name = XRT_DEVICE_SIMPLE_CONTROLLER, 76 + .inputs = simple_inputs, 77 + .input_count = ARRAY_SIZE(simple_inputs), 78 + .outputs = simple_outputs, 79 + .output_count = ARRAY_SIZE(simple_outputs), 80 + }, 81 + }; 82 + 55 83 static void 56 84 qwerty_system_remove(struct qwerty_system *qs, struct qwerty_device *qd); 57 85 ··· 106 134 static xrt_result_t 107 135 qwerty_update_inputs(struct xrt_device *xd) 108 136 { 109 - assert(xd->name == XRT_DEVICE_SIMPLE_CONTROLLER); 137 + assert(xd->name == XRT_DEVICE_WMR_CONTROLLER); 110 138 111 139 struct qwerty_controller *qc = qwerty_controller(xd); 112 140 struct qwerty_device *qd = &qc->base; 113 141 114 - QWERTY_TRACE(qd, "select: %u, menu: %u", qc->select_clicked, qc->menu_clicked); 142 + // clang-format off 143 + QWERTY_TRACE(qd, "trigger: %f, menu: %u, squeeze: %u, system %u, thumbstick: %u %f %f, trackpad: %u %f %f", 144 + 1.0f * qc->trigger_clicked, qc->menu_clicked, qc->squeeze_clicked, qc->system_clicked, 145 + qc->thumbstick_clicked, 1.0f * (qc->thumbstick_right_pressed - qc->thumbstick_left_pressed), 146 + 1.0f * (qc->thumbstick_up_pressed - qc->thumbstick_down_pressed), 147 + qc->trackpad_clicked, 1.0f * (qc->trackpad_right_pressed - qc->trackpad_left_pressed), 148 + 1.0f * (qc->trackpad_up_pressed - qc->trackpad_down_pressed)); 149 + // clang-format on 115 150 116 - xd->inputs[QWERTY_SELECT].value.boolean = qc->select_clicked; 117 - xd->inputs[QWERTY_SELECT].timestamp = qc->select_timestamp; 151 + xd->inputs[QWERTY_TRIGGER].value.vec1.x = 1.0f * qc->trigger_clicked; 152 + xd->inputs[QWERTY_TRIGGER].timestamp = qc->trigger_timestamp; 118 153 xd->inputs[QWERTY_MENU].value.boolean = qc->menu_clicked; 119 154 xd->inputs[QWERTY_MENU].timestamp = qc->menu_timestamp; 155 + xd->inputs[QWERTY_SQUEEZE].value.boolean = qc->squeeze_clicked; 156 + xd->inputs[QWERTY_SQUEEZE].timestamp = qc->squeeze_timestamp; 157 + xd->inputs[QWERTY_SYSTEM].value.boolean = qc->system_clicked; 158 + xd->inputs[QWERTY_SYSTEM].timestamp = qc->system_timestamp; 159 + 160 + xd->inputs[QWERTY_THUMBSTICK].value.vec2.x = 161 + 1.0f * (qc->thumbstick_right_pressed - qc->thumbstick_left_pressed); 162 + xd->inputs[QWERTY_THUMBSTICK].value.vec2.y = 1.0f * (qc->thumbstick_up_pressed - qc->thumbstick_down_pressed); 163 + xd->inputs[QWERTY_THUMBSTICK].timestamp = qc->thumbstick_timestamp; 164 + xd->inputs[QWERTY_THUMBSTICK_CLICK].value.boolean = qc->thumbstick_clicked; 165 + xd->inputs[QWERTY_THUMBSTICK_CLICK].timestamp = qc->thumbstick_click_timestamp; 166 + 167 + xd->inputs[QWERTY_TRACKPAD].value.vec2.x = 1.0f * (qc->trackpad_right_pressed - qc->trackpad_left_pressed); 168 + xd->inputs[QWERTY_TRACKPAD].value.vec2.y = 1.0f * (qc->trackpad_up_pressed - qc->trackpad_down_pressed); 169 + xd->inputs[QWERTY_TRACKPAD].timestamp = qc->trackpad_timestamp; 170 + xd->inputs[QWERTY_TRACKPAD_TOUCH].value.boolean = qc->trackpad_right_pressed || qc->trackpad_left_pressed || 171 + qc->trackpad_up_pressed || qc->trackpad_down_pressed || 172 + qc->trackpad_clicked; 173 + xd->inputs[QWERTY_TRACKPAD_TOUCH].timestamp = MAX(qc->trackpad_timestamp, qc->trackpad_click_timestamp); 174 + xd->inputs[QWERTY_TRACKPAD_CLICK].value.boolean = qc->trackpad_clicked; 175 + xd->inputs[QWERTY_TRACKPAD_CLICK].timestamp = qc->trackpad_click_timestamp; 120 176 121 177 return XRT_SUCCESS; 122 178 } ··· 144 200 { 145 201 struct qwerty_device *qd = qwerty_device(xd); 146 202 147 - if (name != XRT_INPUT_GENERIC_HEAD_POSE && name != XRT_INPUT_SIMPLE_GRIP_POSE && 148 - name != XRT_INPUT_SIMPLE_AIM_POSE) { 203 + if (name != XRT_INPUT_GENERIC_HEAD_POSE && name != XRT_INPUT_WMR_GRIP_POSE && name != XRT_INPUT_WMR_AIM_POSE) { 149 204 U_LOG_XDEV_UNSUPPORTED_INPUT(&qd->base, qd->sys->log_level, name); 150 205 return XRT_ERROR_INPUT_UNSUPPORTED; 151 206 } ··· 187 242 188 243 // HMD Parenting 189 244 190 - bool qd_is_ctrl = name == XRT_INPUT_SIMPLE_GRIP_POSE || name == XRT_INPUT_SIMPLE_AIM_POSE; 245 + bool qd_is_ctrl = name == XRT_INPUT_WMR_GRIP_POSE || name == XRT_INPUT_WMR_AIM_POSE; 191 246 struct qwerty_controller *qc = qd_is_ctrl ? qwerty_controller(&qd->base) : NULL; 192 247 if (qd_is_ctrl && qc->follow_hmd) { 193 248 struct xrt_relation_chain relation_chain = {0}; ··· 272 327 struct qwerty_controller * 273 328 qwerty_controller_create(bool is_left, struct qwerty_hmd *qhmd) 274 329 { 275 - struct qwerty_controller *qc = U_DEVICE_ALLOCATE(struct qwerty_controller, U_DEVICE_ALLOC_TRACKING_NONE, 4, 1); 330 + struct qwerty_controller *qc = U_DEVICE_ALLOCATE(struct qwerty_controller, U_DEVICE_ALLOC_TRACKING_NONE, 11, 1); 276 331 assert(qc); 277 - qc->select_clicked = false; 278 - qc->menu_clicked = false; 279 332 qc->follow_hmd = qhmd != NULL; 280 333 281 334 struct qwerty_device *qd = &qc->base; ··· 286 339 287 340 struct xrt_device *xd = &qd->base; 288 341 289 - xd->name = XRT_DEVICE_SIMPLE_CONTROLLER; 342 + xd->name = XRT_DEVICE_WMR_CONTROLLER; 290 343 xd->device_type = is_left ? XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER : XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER; 291 344 292 345 char *controller_name = is_left ? QWERTY_LEFT_STR : QWERTY_RIGHT_STR; ··· 297 350 char *tracker_name = is_left ? QWERTY_LEFT_TRACKER_STR : QWERTY_RIGHT_TRACKER_STR; 298 351 snprintf(xd->tracking_origin->name, XRT_TRACKING_NAME_LEN, "%s", tracker_name); 299 352 300 - xd->inputs[QWERTY_SELECT].name = XRT_INPUT_SIMPLE_SELECT_CLICK; 301 - xd->inputs[QWERTY_MENU].name = XRT_INPUT_SIMPLE_MENU_CLICK; 302 - xd->inputs[QWERTY_GRIP].name = XRT_INPUT_SIMPLE_GRIP_POSE; 303 - xd->inputs[QWERTY_AIM].name = XRT_INPUT_SIMPLE_AIM_POSE; //!< @todo: aim input not implemented 304 - xd->outputs[QWERTY_VIBRATION].name = XRT_OUTPUT_NAME_SIMPLE_VIBRATION; 353 + xd->inputs[QWERTY_TRIGGER].name = XRT_INPUT_WMR_TRIGGER_VALUE; 354 + xd->inputs[QWERTY_MENU].name = XRT_INPUT_WMR_MENU_CLICK; 355 + xd->inputs[QWERTY_SQUEEZE].name = XRT_INPUT_WMR_SQUEEZE_CLICK; 356 + xd->inputs[QWERTY_SYSTEM].name = XRT_INPUT_WMR_HOME_CLICK; 357 + xd->inputs[QWERTY_THUMBSTICK].name = XRT_INPUT_WMR_THUMBSTICK; 358 + xd->inputs[QWERTY_THUMBSTICK_CLICK].name = XRT_INPUT_WMR_THUMBSTICK_CLICK; 359 + xd->inputs[QWERTY_TRACKPAD].name = XRT_INPUT_WMR_TRACKPAD; 360 + xd->inputs[QWERTY_TRACKPAD_TOUCH].name = XRT_INPUT_WMR_TRACKPAD_TOUCH; 361 + xd->inputs[QWERTY_TRACKPAD_CLICK].name = XRT_INPUT_WMR_TRACKPAD_CLICK; 362 + xd->inputs[QWERTY_GRIP].name = XRT_INPUT_WMR_GRIP_POSE; 363 + //!< @todo: aim input offset not implemented, equal to grip pose 364 + xd->inputs[QWERTY_AIM].name = XRT_INPUT_WMR_AIM_POSE; 365 + xd->outputs[QWERTY_VIBRATION].name = XRT_OUTPUT_NAME_WMR_HAPTIC; 366 + 367 + xd->binding_profiles = binding_profiles; 368 + xd->binding_profile_count = ARRAY_SIZE(binding_profiles); 305 369 306 370 xd->update_inputs = qwerty_update_inputs; 307 371 xd->get_tracked_pose = qwerty_get_tracked_pose; ··· 359 423 u_var_add_ro_text(qs, "Modify FD movement speed", "Mouse wheel"); 360 424 u_var_add_ro_text(qs, "Modify FD movement speed", "Numpad +/-"); 361 425 u_var_add_ro_text(qs, "Reset both or FC pose", "R"); 362 - u_var_add_ro_text(qs, "Toggle both or FC parenting to HMD", "F"); 363 - u_var_add_ro_text(qs, "FC Select click", "Left Click"); 364 - u_var_add_ro_text(qs, "FC Menu click", "Middle Click"); 426 + u_var_add_ro_text(qs, "Toggle both or FC parenting to HMD", "C"); 427 + u_var_add_ro_text(qs, "FC Trigger click", "Left Click"); 428 + u_var_add_ro_text(qs, "FC Squeeze click", "Middle Click"); 429 + u_var_add_ro_text(qs, "FC Menu click", "N"); 430 + u_var_add_ro_text(qs, "FC System click", "B"); 431 + u_var_add_ro_text(qs, "FC Joystick direction", "TFGH"); 432 + u_var_add_ro_text(qs, "FC Joystick click", "V"); 433 + u_var_add_ro_text(qs, "FC Trackpad touch direction", "IJKL"); 434 + u_var_add_ro_text(qs, "FC Trackpad click", "M"); 365 435 } 366 436 367 437 struct qwerty_system * ··· 493 563 // Controller methods 494 564 495 565 void 496 - qwerty_press_select(struct qwerty_controller *qc) 566 + qwerty_press_trigger(struct qwerty_controller *qc) 497 567 { 498 - qc->select_clicked = true; 499 - qc->select_timestamp = os_monotonic_get_ns(); 568 + qc->trigger_clicked = true; 569 + qc->trigger_timestamp = os_monotonic_get_ns(); 500 570 } 501 571 502 572 void 503 - qwerty_release_select(struct qwerty_controller *qc) 573 + qwerty_release_trigger(struct qwerty_controller *qc) 504 574 { 505 - qc->select_clicked = false; 506 - qc->select_timestamp = os_monotonic_get_ns(); 575 + qc->trigger_clicked = false; 576 + qc->trigger_timestamp = os_monotonic_get_ns(); 507 577 } 508 578 509 579 void ··· 519 589 qc->menu_clicked = false; 520 590 qc->menu_timestamp = os_monotonic_get_ns(); 521 591 } 592 + 593 + void 594 + qwerty_press_squeeze(struct qwerty_controller *qc) 595 + { 596 + qc->squeeze_clicked = true; 597 + qc->squeeze_timestamp = os_monotonic_get_ns(); 598 + } 599 + 600 + void 601 + qwerty_release_squeeze(struct qwerty_controller *qc) 602 + { 603 + qc->squeeze_clicked = false; 604 + qc->squeeze_timestamp = os_monotonic_get_ns(); 605 + } 606 + 607 + void 608 + qwerty_press_system(struct qwerty_controller *qc) 609 + { 610 + qc->system_clicked = true; 611 + qc->system_timestamp = os_monotonic_get_ns(); 612 + } 613 + 614 + void 615 + qwerty_release_system(struct qwerty_controller *qc) 616 + { 617 + qc->system_clicked = false; 618 + qc->system_timestamp = os_monotonic_get_ns(); 619 + } 620 + 621 + // clang-format off 622 + void qwerty_press_thumbstick_left(struct qwerty_controller *qc) { qc->thumbstick_left_pressed = true; 623 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 624 + void qwerty_release_thumbstick_left(struct qwerty_controller *qc) { qc->thumbstick_left_pressed = false; 625 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 626 + void qwerty_press_thumbstick_right(struct qwerty_controller *qc) { qc->thumbstick_right_pressed = true; 627 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 628 + void qwerty_release_thumbstick_right(struct qwerty_controller *qc) { qc->thumbstick_right_pressed = false; 629 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 630 + void qwerty_press_thumbstick_up(struct qwerty_controller *qc) { qc->thumbstick_up_pressed = true; 631 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 632 + void qwerty_release_thumbstick_up(struct qwerty_controller *qc) { qc->thumbstick_up_pressed = false; 633 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 634 + void qwerty_press_thumbstick_down(struct qwerty_controller *qc) { qc->thumbstick_down_pressed = true; 635 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 636 + void qwerty_release_thumbstick_down(struct qwerty_controller *qc) { qc->thumbstick_down_pressed = false; 637 + qc->thumbstick_timestamp = os_monotonic_get_ns(); } 638 + void qwerty_press_thumbstick_click(struct qwerty_controller *qc) { qc->thumbstick_clicked = true; 639 + qc->thumbstick_click_timestamp = os_monotonic_get_ns(); } 640 + void qwerty_release_thumbstick_click(struct qwerty_controller *qc) { qc->thumbstick_clicked = false; 641 + qc->thumbstick_click_timestamp = os_monotonic_get_ns(); } 642 + 643 + void qwerty_press_trackpad_left(struct qwerty_controller *qc) { qc->trackpad_left_pressed = true; 644 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 645 + void qwerty_release_trackpad_left(struct qwerty_controller *qc) { qc->trackpad_left_pressed = false; 646 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 647 + void qwerty_press_trackpad_right(struct qwerty_controller *qc) { qc->trackpad_right_pressed = true; 648 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 649 + void qwerty_release_trackpad_right(struct qwerty_controller *qc) { qc->trackpad_right_pressed = false; 650 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 651 + void qwerty_press_trackpad_up(struct qwerty_controller *qc) { qc->trackpad_up_pressed = true; 652 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 653 + void qwerty_release_trackpad_up(struct qwerty_controller *qc) { qc->trackpad_up_pressed = false; 654 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 655 + void qwerty_press_trackpad_down(struct qwerty_controller *qc) { qc->trackpad_down_pressed = true; 656 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 657 + void qwerty_release_trackpad_down(struct qwerty_controller *qc) { qc->trackpad_down_pressed = false; 658 + qc->trackpad_timestamp = os_monotonic_get_ns(); } 659 + void qwerty_press_trackpad_click(struct qwerty_controller *qc) { qc->trackpad_clicked = true; 660 + qc->trackpad_click_timestamp = os_monotonic_get_ns(); } 661 + void qwerty_release_trackpad_click(struct qwerty_controller *qc) { qc->trackpad_clicked = false; 662 + qc->trackpad_click_timestamp = os_monotonic_get_ns(); } 663 + // clang-format on 522 664 523 665 void 524 666 qwerty_follow_hmd(struct qwerty_controller *qc, bool follow)
+116 -6
src/xrt/drivers/qwerty/qwerty_device.h
··· 90 90 { 91 91 struct qwerty_device base; 92 92 93 - bool select_clicked; 94 - int64_t select_timestamp; 93 + bool trigger_clicked; 94 + int64_t trigger_timestamp; 95 95 bool menu_clicked; 96 96 int64_t menu_timestamp; 97 + bool squeeze_clicked; 98 + int64_t squeeze_timestamp; 99 + bool system_clicked; 100 + int64_t system_timestamp; 101 + 102 + bool thumbstick_left_pressed; 103 + bool thumbstick_right_pressed; 104 + bool thumbstick_up_pressed; 105 + bool thumbstick_down_pressed; 106 + int64_t thumbstick_timestamp; 107 + bool thumbstick_clicked; 108 + int64_t thumbstick_click_timestamp; 109 + 110 + bool trackpad_left_pressed; 111 + bool trackpad_right_pressed; 112 + bool trackpad_up_pressed; 113 + bool trackpad_down_pressed; 114 + int64_t trackpad_timestamp; 115 + bool trackpad_clicked; 116 + int64_t trackpad_click_timestamp; 97 117 98 118 /*! 99 119 * Only used when a qwerty_hmd exists in the system. ··· 256 276 qwerty_controller(struct xrt_device *xd); 257 277 258 278 /*! 259 - * Simulate pressing input/select/click 279 + * Simulate pressing input/trigger/value to 1.0 260 280 * @public @memberof qwerty_controller 261 281 */ 262 282 void 263 - qwerty_press_select(struct qwerty_controller *qc); 283 + qwerty_press_trigger(struct qwerty_controller *qc); 264 284 265 285 /*! 266 - * Simulate releasing input/select/click 286 + * Simulate releasing input/trigger/value to 0.0 267 287 * @public @memberof qwerty_controller 268 288 */ 269 289 void 270 - qwerty_release_select(struct qwerty_controller *qc); 290 + qwerty_release_trigger(struct qwerty_controller *qc); 271 291 272 292 /*! 273 293 * Simulate pressing input/menu/click ··· 282 302 */ 283 303 void 284 304 qwerty_release_menu(struct qwerty_controller *qc); 305 + 306 + /*! 307 + * Simulate pressing input/squeeze/click 308 + * @public @memberof qwerty_controller 309 + */ 310 + void 311 + qwerty_press_squeeze(struct qwerty_controller *qc); 312 + 313 + /*! 314 + * Simulate releasing input/squeeze/click 315 + * @public @memberof qwerty_controller 316 + */ 317 + void 318 + qwerty_release_squeeze(struct qwerty_controller *qc); 319 + 320 + /*! 321 + * Simulate pressing input/system/click 322 + * @public @memberof qwerty_controller 323 + */ 324 + void 325 + qwerty_press_system(struct qwerty_controller *qc); 326 + 327 + /*! 328 + * Simulate releasing input/system/click 329 + * @public @memberof qwerty_controller 330 + */ 331 + void 332 + qwerty_release_system(struct qwerty_controller *qc); 333 + 334 + //! @public @memberof qwerty_controller 335 + void 336 + qwerty_press_thumbstick_left(struct qwerty_controller *qc); 337 + //! @public @memberof qwerty_controller 338 + void 339 + qwerty_release_thumbstick_left(struct qwerty_controller *qc); 340 + //! @public @memberof qwerty_controller 341 + void 342 + qwerty_press_thumbstick_right(struct qwerty_controller *qc); 343 + //! @public @memberof qwerty_controller 344 + void 345 + qwerty_release_thumbstick_right(struct qwerty_controller *qc); 346 + //! @public @memberof qwerty_controller 347 + void 348 + qwerty_press_thumbstick_up(struct qwerty_controller *qc); 349 + //! @public @memberof qwerty_controller 350 + void 351 + qwerty_release_thumbstick_up(struct qwerty_controller *qc); 352 + //! @public @memberof qwerty_controller 353 + void 354 + qwerty_press_thumbstick_down(struct qwerty_controller *qc); 355 + //! @public @memberof qwerty_controller 356 + void 357 + qwerty_release_thumbstick_down(struct qwerty_controller *qc); 358 + //! @public @memberof qwerty_controller 359 + void 360 + qwerty_press_thumbstick_click(struct qwerty_controller *qc); 361 + //! @public @memberof qwerty_controller 362 + void 363 + qwerty_release_thumbstick_click(struct qwerty_controller *qc); 364 + 365 + //! @public @memberof qwerty_controller 366 + void 367 + qwerty_press_trackpad_left(struct qwerty_controller *qc); 368 + //! @public @memberof qwerty_controller 369 + void 370 + qwerty_release_trackpad_left(struct qwerty_controller *qc); 371 + //! @public @memberof qwerty_controller 372 + void 373 + qwerty_press_trackpad_right(struct qwerty_controller *qc); 374 + //! @public @memberof qwerty_controller 375 + void 376 + qwerty_release_trackpad_right(struct qwerty_controller *qc); 377 + //! @public @memberof qwerty_controller 378 + void 379 + qwerty_press_trackpad_up(struct qwerty_controller *qc); 380 + //! @public @memberof qwerty_controller 381 + void 382 + qwerty_release_trackpad_up(struct qwerty_controller *qc); 383 + //! @public @memberof qwerty_controller 384 + void 385 + qwerty_press_trackpad_down(struct qwerty_controller *qc); 386 + //! @public @memberof qwerty_controller 387 + void 388 + qwerty_release_trackpad_down(struct qwerty_controller *qc); 389 + //! @public @memberof qwerty_controller 390 + void 391 + qwerty_press_trackpad_click(struct qwerty_controller *qc); 392 + //! @public @memberof qwerty_controller 393 + void 394 + qwerty_release_trackpad_click(struct qwerty_controller *qc); 285 395 286 396 /*! 287 397 * Attach/detach the pose of `qc` to its HMD. Only works when a qwerty_hmd is present.
+35 -6
src/xrt/drivers/qwerty/qwerty_sdl.c
··· 209 209 qwerty_add_look_delta(qdev, yaw, pitch); 210 210 } 211 211 212 - // Select and menu clicks only for controllers. 213 - if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) qwerty_press_select(qctrl); 214 - if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT) qwerty_release_select(qctrl); 215 - if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_MIDDLE) qwerty_press_menu(qctrl); 216 - if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_MIDDLE) qwerty_release_menu(qctrl); 212 + // Trigger, squeeze and menu clicks only for controllers. 213 + if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) qwerty_press_trigger(qctrl); 214 + if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT) qwerty_release_trigger(qctrl); 215 + if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_MIDDLE) qwerty_press_squeeze(qctrl); 216 + if (event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_MIDDLE) qwerty_release_squeeze(qctrl); 217 + 218 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_n) qwerty_press_menu(qctrl); 219 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_n) qwerty_release_menu(qctrl); 220 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_b) qwerty_press_system(qctrl); 221 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_b) qwerty_release_system(qctrl); 222 + 223 + // Thumbstick 224 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_f) qwerty_press_thumbstick_left(qctrl); 225 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_f) qwerty_release_thumbstick_left(qctrl); 226 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_h) qwerty_press_thumbstick_right(qctrl); 227 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_h) qwerty_release_thumbstick_right(qctrl); 228 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_t) qwerty_press_thumbstick_up(qctrl); 229 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_t) qwerty_release_thumbstick_up(qctrl); 230 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_g) qwerty_press_thumbstick_down(qctrl); 231 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_g) qwerty_release_thumbstick_down(qctrl); 232 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_v) qwerty_press_thumbstick_click(qctrl); 233 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_v) qwerty_release_thumbstick_click(qctrl); 234 + 235 + // Trackpad 236 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_j) qwerty_press_trackpad_left(qctrl); 237 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_j) qwerty_release_trackpad_left(qctrl); 238 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_l) qwerty_press_trackpad_right(qctrl); 239 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_l) qwerty_release_trackpad_right(qctrl); 240 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_i) qwerty_press_trackpad_up(qctrl); 241 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_i) qwerty_release_trackpad_up(qctrl); 242 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_k) qwerty_press_trackpad_down(qctrl); 243 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_k) qwerty_release_trackpad_down(qctrl); 244 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_m) qwerty_press_trackpad_click(qctrl); 245 + if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_m) qwerty_release_trackpad_click(qctrl); 217 246 218 247 // clang-format on 219 248 220 249 // Controllers follow/unfollow HMD 221 - if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_f && event.key.repeat == 0) { 250 + if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_c && event.key.repeat == 0) { 222 251 if (qdev != qd_hmd) { 223 252 qwerty_follow_hmd(qctrl, !qctrl->follow_hmd); 224 253 } else { // If no controller is focused, set both to the same state