Changeset 49385 in vbox
- Timestamp:
- Nov 4, 2013 2:32:18 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/UsbKbd.cpp
r48947 r49385 925 925 } 926 926 927 /* See the PS2K device. */ 928 #define KRSP_BAT_FAIL 0xFC /* Also a 'release keys' signal. */ 929 927 930 /** 928 931 * Keyboard event handler. … … 942 945 RTCritSectEnter(&pThis->CritSect); 943 946 944 pThis->XlatState = ScancodeToHidUsage(pThis->XlatState, u8KeyCode, &u32Usage);945 946 if (pThis->XlatState == SS_IDLE)947 {948 /* The usage code is valid. */949 fKeyDown = !(u32Usage & 0x80000000);950 u8HidCode = u32Usage & 0xFF;951 AssertReturn(u8HidCode <= VBOX_USB_MAX_USAGE_CODE, VERR_INTERNAL_ERROR);952 953 LogFlowFunc(("key %s: 0x%x->0x%x\n", 954 fKeyDown ? "down" : "up", u8KeyCode, u8HidCode));955 956 if ( fKeyDown)947 if (RT_UNLIKELY(u8KeyCode == KRSP_BAT_FAIL)) 948 { 949 /* Clear all currently depressed and unreported keys. */ 950 RT_ZERO(pThis->abDepressedKeys); 951 RT_ZERO(pThis->abUnreportedKeys); 952 usbHidSendReport(pThis); 953 } 954 else 955 { 956 957 pThis->XlatState = ScancodeToHidUsage(pThis->XlatState, u8KeyCode, &u32Usage); 958 959 if (pThis->XlatState == SS_IDLE) 957 960 { 958 /* Due to host key repeat, we can get key events for keys which are 959 * already depressed. */ 960 if (!pThis->abDepressedKeys[u8HidCode]) 961 /* The usage code is valid. */ 962 fKeyDown = !(u32Usage & 0x80000000); 963 u8HidCode = u32Usage & 0xFF; 964 AssertReturn(u8HidCode <= VBOX_USB_MAX_USAGE_CODE, VERR_INTERNAL_ERROR); 965 966 LogFlowFunc(("key %s: 0x%x->0x%x\n", 967 fKeyDown ? "down" : "up", u8KeyCode, u8HidCode)); 968 969 if (fKeyDown) 961 970 { 962 pThis->abUnreportedKeys[u8HidCode] = 1; 963 964 /* If a non-modifier key is being marked as unreported, also set 965 * all currently depressed modifer keys as unreported. This avoids 966 * problems where a simulated key sequence is sent too fast and 967 * by the time the key is reported, some previously reported 968 * modifiers are already released. This helps ensure that the guest 969 * sees the entire modifier(s)+key sequence in a single report. 970 */ 971 if (!usbHidUsageCodeIsModifier(u8HidCode)) 971 /* Due to host key repeat, we can get key events for keys which are 972 * already depressed. */ 973 if (!pThis->abDepressedKeys[u8HidCode]) 972 974 { 973 int iModKey; 974 975 for (iModKey = USBHID_MODIFIER_FIRST; iModKey <= USBHID_MODIFIER_LAST; ++iModKey) 976 if (pThis->abDepressedKeys[iModKey]) 977 pThis->abUnreportedKeys[iModKey] = 1; 975 pThis->abUnreportedKeys[u8HidCode] = 1; 976 977 /* If a non-modifier key is being marked as unreported, also set 978 * all currently depressed modifer keys as unreported. This avoids 979 * problems where a simulated key sequence is sent too fast and 980 * by the time the key is reported, some previously reported 981 * modifiers are already released. This helps ensure that the guest 982 * sees the entire modifier(s)+key sequence in a single report. 983 */ 984 if (!usbHidUsageCodeIsModifier(u8HidCode)) 985 { 986 int iModKey; 987 988 for (iModKey = USBHID_MODIFIER_FIRST; iModKey <= USBHID_MODIFIER_LAST; ++iModKey) 989 if (pThis->abDepressedKeys[iModKey]) 990 pThis->abUnreportedKeys[iModKey] = 1; 991 } 978 992 } 993 else 994 fHaveEvent = false; 995 pThis->abDepressedKeys[u8HidCode] = 1; 979 996 } 980 997 else 981 fHaveEvent = false; 982 pThis->abDepressedKeys[u8HidCode] = 1; 998 { 999 /* For stupid Korean keyboards, we have to fake a key up/down sequence 1000 * because they only send break codes for Hangul/Hanja keys. 1001 */ 1002 if (u8HidCode == 0x90 || u8HidCode == 0x91) 1003 pThis->abUnreportedKeys[u8HidCode] = 1; 1004 pThis->abDepressedKeys[u8HidCode] = 0; 1005 } 1006 1007 1008 /* Send a report if the host is already waiting for it. */ 1009 if (fHaveEvent) 1010 usbHidSendReport(pThis); 983 1011 } 984 else985 {986 /* For stupid Korean keyboards, we have to fake a key up/down sequence987 * because they only send break codes for Hangul/Hanja keys.988 */989 if (u8HidCode == 0x90 || u8HidCode == 0x91)990 pThis->abUnreportedKeys[u8HidCode] = 1;991 pThis->abDepressedKeys[u8HidCode] = 0;992 }993 994 995 /* Send a report if the host is already waiting for it. */996 if (fHaveEvent)997 usbHidSendReport(pThis);998 1012 } 999 1013
Note:
See TracChangeset
for help on using the changeset viewer.