The open source OpenXR runtime
0
fork

Configure Feed

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

d/psmv: Move led and rumble update to thread

+56 -44
+2
doc/changes/drivers/mr.287.md
··· 1 + psvm: Move the led and rumble updating from the application facing update_inputs 2 + function to the internal thread instead.
+54 -44
src/xrt/drivers/psmv/psmv_driver.c
··· 598 598 * 599 599 */ 600 600 601 + /*! 602 + * Does the actual sending of the led control package to the device. 603 + */ 604 + static int 605 + psmv_send_led_control(struct psmv_device *psmv, 606 + uint8_t red, 607 + uint8_t green, 608 + uint8_t blue, 609 + uint8_t rumble) 610 + { 611 + struct psmv_set_led msg; 612 + U_ZERO(&msg); 613 + msg.id = 0x06; 614 + msg.red = red; 615 + msg.green = green; 616 + msg.blue = blue; 617 + msg.rumble = rumble; 618 + 619 + return os_hid_write(psmv->hid, (uint8_t *)&msg, sizeof(msg)); 620 + } 621 + 622 + static void 623 + psmv_led_and_trigger_update_locked(struct psmv_device *psmv, int64_t time) 624 + { 625 + // Need to keep sending led control packets to keep the leds on. 626 + if (psmv->wants.resend_time > time && 627 + psmv->state.led.r == psmv->wants.led.r && 628 + psmv->state.led.g == psmv->wants.led.g && 629 + psmv->state.led.b == psmv->wants.led.b && 630 + psmv->state.rumble == psmv->wants.rumble) { 631 + return; 632 + } 633 + 634 + psmv->state.led.r = psmv->wants.led.r; 635 + psmv->state.led.g = psmv->wants.led.g; 636 + psmv->state.led.b = psmv->wants.led.b; 637 + psmv->state.rumble = psmv->wants.rumble; 638 + 639 + psmv->wants.resend_time = time + 1000000000; 640 + psmv_send_led_control(psmv, psmv->state.led.r, psmv->state.led.g, 641 + psmv->state.led.b, psmv->state.rumble); 642 + } 643 + 644 + static void 645 + psmv_led_and_trigger_update(struct psmv_device *psmv, int64_t time) 646 + { 647 + os_mutex_lock(&psmv->lock); 648 + psmv_led_and_trigger_update_locked(psmv, time); 649 + os_mutex_unlock(&psmv->lock); 650 + } 651 + 601 652 static void 602 653 update_fusion(struct psmv_device *psmv, 603 654 struct psmv_parsed_sample *sample, ··· 710 761 // Lock last and the fusion. 711 762 os_mutex_lock(&psmv->lock); 712 763 764 + // Make sure the leds stays on. 765 + psmv_led_and_trigger_update_locked(psmv, now_ns); 766 + 713 767 // Copy to device. 714 768 psmv->last = input; 715 769 ··· 735 789 return NULL; 736 790 } 737 791 738 - /*! 739 - * Does the actual sending of the led control package to the device. 740 - */ 741 - static int 742 - psmv_send_led_control(struct psmv_device *psmv, 743 - uint8_t red, 744 - uint8_t green, 745 - uint8_t blue, 746 - uint8_t rumble) 747 - { 748 - struct psmv_set_led msg; 749 - U_ZERO(&msg); 750 - msg.id = 0x06; 751 - msg.red = red; 752 - msg.green = green; 753 - msg.blue = blue; 754 - msg.rumble = rumble; 755 - 756 - return os_hid_write(psmv->hid, (uint8_t *)&msg, sizeof(msg)); 757 - } 758 - 759 - static void 760 - psmv_led_and_trigger_update(struct psmv_device *psmv, int64_t time) 761 - { 762 - // Need to keep sending led control packets to keep the leds on. 763 - if (psmv->wants.resend_time > time && 764 - psmv->state.led.r == psmv->wants.led.r && 765 - psmv->state.led.g == psmv->wants.led.g && 766 - psmv->state.led.b == psmv->wants.led.b && 767 - psmv->state.rumble == psmv->wants.rumble) { 768 - return; 769 - } 770 - 771 - psmv->state.led.r = psmv->wants.led.r; 772 - psmv->state.led.g = psmv->wants.led.g; 773 - psmv->state.led.b = psmv->wants.led.b; 774 - psmv->state.rumble = psmv->wants.rumble; 775 - 776 - psmv->wants.resend_time = time + 1000000000; 777 - psmv_send_led_control(psmv, psmv->state.led.r, psmv->state.led.g, 778 - psmv->state.led.b, psmv->state.rumble); 779 - } 780 - 781 792 static void 782 793 psmv_get_fusion_pose(struct psmv_device *psmv, 783 794 enum xrt_input_name name, ··· 836 847 837 848 int64_t now = os_monotonic_get_ns(); 838 849 839 - psmv_led_and_trigger_update(psmv, now); 840 850 841 851 // Lock the data. 842 852 os_mutex_lock(&psmv->lock);