- Timestamp:
- Mar 30, 2010 5:52:53 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/UsbKbd.cpp
r27129 r27838 13 13 * Header Files * 14 14 *******************************************************************************/ 15 #define LOG_GROUP LOG_GROUP_USB_ MSD15 #define LOG_GROUP LOG_GROUP_USB_KBD 16 16 #include <VBox/pdmusb.h> 17 17 #include <VBox/log.h> … … 160 160 /** Someone is waiting on the done queue. */ 161 161 bool fHaveDoneQueueWaiter; 162 /** If no URB since last key press */ 163 bool fNoUrbSinceLastPress; 164 /* Keys released since last URB */ 165 uint8_t aReleasedKeys[6]; 162 166 163 167 /** … … 603 607 pThis->bIdle = 0; 604 608 memset(&pThis->Report, 0, sizeof(pThis->Report)); 609 pThis->fNoUrbSinceLastPress = false; 610 memset(&pThis->aReleasedKeys, 0, sizeof(pThis->aReleasedKeys)); 605 611 606 612 for (unsigned i = 0; i < RT_ELEMENTS(pThis->aEps); i++) … … 625 631 } 626 632 633 static void usbHidUpdateReportReleased(PUSBHID pThis, uint8_t u8HidCode) 634 { 635 unsigned i; 636 637 for (i = 0; i < RT_ELEMENTS(pThis->Report.aKeys); ++i) 638 { 639 if (pThis->Report.aKeys[i] == u8HidCode) 640 { 641 pThis->Report.aKeys[i] = 0; 642 break; /* Remove key down. */ 643 } 644 } 645 646 if (i == RT_ELEMENTS(pThis->Report.aKeys)) 647 { 648 // AssertMsgFailed(("Key is up but was never down!?")); 649 } 650 } 627 651 628 652 /** … … 636 660 PUSBHIDK_REPORT pReport = &pThis->Report; 637 661 size_t cbCopy; 662 unsigned i; 638 663 639 664 cbCopy = sizeof(*pReport); 640 665 memcpy(&pUrb->abData[0], pReport, cbCopy); 666 pThis->fNoUrbSinceLastPress = false; 667 for (i=0; i < RT_ELEMENTS(pThis->aReleasedKeys); ++i) 668 { 669 if (pThis->aReleasedKeys[i] != 0) 670 { 671 usbHidUpdateReportReleased(pThis, pThis->aReleasedKeys[i]); 672 pThis->aReleasedKeys[i] = 0; 673 } 674 } 641 675 // LogRel(("Sent report: %x : %x %x, size %d\n", pReport->ShiftState, pReport->aKeys[0], pReport->aKeys[1], cbCopy)); 642 676 return usbHidCompleteOk(pThis, pUrb, cbCopy); 677 } 678 else 679 { 680 Log(("No available URB for USB kbd\n")); 643 681 } 644 682 return VINF_EOF; … … 695 733 } 696 734 } 735 736 pThis->fNoUrbSinceLastPress = true; 737 697 738 if (i == RT_ELEMENTS(pReport->aKeys)) 698 739 { 699 740 /* We ran out of room. Report error. */ 741 Log(("no more room in usbHidKeyboardPutEvent\n")); 700 742 // @todo!! 701 743 } … … 703 745 else 704 746 { 705 for (i = 0; i < RT_ELEMENTS(pReport->aKeys); ++i) 706 { 707 if (pReport->aKeys[i] == u8HidCode) 747 /* We have to avoid coalescing key presses and releases, so put all releases somewhere else */ 748 if (pThis->fNoUrbSinceLastPress) 749 { 750 for (i = 0; i < RT_ELEMENTS(pThis->aReleasedKeys); ++i) 708 751 { 709 pReport->aKeys[i] = 0; 710 break; /* Remove key down. */ 752 if (pThis->aReleasedKeys[i] == 0) 753 { 754 pThis->aReleasedKeys[i] = u8HidCode; 755 break; 756 } 711 757 } 712 758 } 713 if (i == RT_ELEMENTS(pReport->aKeys)) 714 { 715 // AssertMsgFailed(("Key is up but was never down!?")); 716 } 759 else 760 usbHidUpdateReportReleased(pThis, u8HidCode); 717 761 } 718 762 … … 841 885 { 842 886 PVUSBSETUP pSetup = (PVUSBSETUP)&pUrb->abData[0]; 887 LogFlow(("usbHidHandleDefaultPipe: cbData=%d\n", pUrb->cbData)); 888 843 889 AssertReturn(pUrb->cbData >= sizeof(*pSetup), VERR_VUSB_FAILED_TO_QUEUE_URB); 844 890
Note:
See TracChangeset
for help on using the changeset viewer.