Changeset 47321 in vbox for trunk/src/VBox/Devices/Input/PS2K.cpp
- Timestamp:
- Jul 22, 2013 5:44:50 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/PS2K.cpp
r47313 r47321 889 889 key_def const *pKeyDef; 890 890 uint8_t abCodes[16]; 891 uint8_t u8MakeCode; 891 892 892 893 LogFlowFunc(("key %s: 0x%02x (set %d)\n", fKeyDown ? "down" : "up", u8HidCode, pThis->u8ScanSet)); … … 920 921 pThis->fNumLockOn ^= true; 921 922 922 if (pThis->u8ScanSet == 2) 923 { 924 /* Handle Scan Set 2 - used almost all the time. */ 923 if (pThis->u8ScanSet == 1 || pThis->u8ScanSet == 2) 924 { 925 /* The basic scan set 1 and 2 logic is the same, only the scan codes differ. 926 * Since scan set 2 is used almost all the time, that case is handled first. 927 */ 925 928 abCodes[0] = 0; 926 929 if (fKeyDown) … … 931 934 /* Pause/Break sends different data if either Ctrl is held. */ 932 935 if (pThis->u8Modifiers & (MOD_LCTRL | MOD_RCTRL)) 933 strcpy((char *)abCodes, "\xE0\x7E\xE0\xF0\x7E"); 936 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 937 "\xE0\x7E\xE0\xF0\x7E" : "\xE0\x46\xE0\xC6"); 934 938 else 935 strcpy((char *)abCodes, "\xE1\x14\x77\xE1\xF0\x14\xF0\x77"); 939 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 940 "\xE1\x14\x77\xE1\xF0\x14\xF0\x77" : "\xE1\x1D\x45\xE1\x9D\xC5"); 936 941 } 937 942 else if (pKeyDef->keyFlags & KF_PS) 938 943 { 939 /* Print Screen depends on all Ctrl, Shift, *and* Alt! */944 /* Print Screen depends on all of Ctrl, Shift, *and* Alt! */ 940 945 if (pThis->u8Modifiers & (MOD_LALT | MOD_RALT)) 941 strcpy((char *)abCodes, "\x84"); 946 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 947 "\x84" : "\x54"); 942 948 else if (pThis->u8Modifiers & (MOD_LSHIFT | MOD_RSHIFT)) 943 strcpy((char *)abCodes, "\xE0\x7C"); 949 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 950 "\xE0\x7C" : "\xE0\x37"); 944 951 else 945 strcpy((char *)abCodes, "\xE0\x12\xE0\x7C"); 952 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 953 "\xE0\x12\xE0\x7C" : "\xE0\x2A\xE0\x37"); 946 954 } 947 else if (pKeyDef->keyFlags & KF_GK)955 else if (pKeyDef->keyFlags & (KF_GK | KF_NS)) 948 956 { 949 if (pThis->fNumLockOn) 957 /* The numeric pad keys fake Shift presses or releases 958 * depending on Num Lock and Shift key state. The '/' 959 * key behaves in a similar manner but does not depend on 960 * the Num Lock state. 961 */ 962 if (!pThis->fNumLockOn || (pKeyDef->keyFlags & KF_NS)) 950 963 { 951 if ((pThis->u8Modifiers & (MOD_LSHIFT | MOD_RSHIFT)) == 0) 952 strcpy((char *)abCodes, "\xE0\x12"); 964 if (pThis->u8Modifiers & MOD_LSHIFT) 965 strcat((char *)abCodes, pThis->u8ScanSet == 2 ? 966 "\xE0\xF0\x12" : "\xE0\xAA"); 967 if (pThis->u8Modifiers & MOD_RSHIFT) 968 strcat((char *)abCodes, pThis->u8ScanSet == 2 ? 969 "\xE0\xF0\x59" : "\xE0\xB6"); 953 970 } 954 971 else 955 972 { 956 if (pThis->u8Modifiers & MOD_LSHIFT) 957 strcat((char *)abCodes, "\xE0\xF0\x12"); 958 if (pThis->u8Modifiers & MOD_RSHIFT) 959 strcat((char *)abCodes, "\xE0\xF0\x59"); 973 Assert(pThis->fNumLockOn); /* Not for KF_NS! */ 974 if ((pThis->u8Modifiers & (MOD_LSHIFT | MOD_RSHIFT)) == 0) 975 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 976 "\xE0\x12" : "\xE0\x2A"); 977 /* Else Shift cancels NumLock, so no prefix! */ 960 978 } 961 979 } … … 967 985 968 986 /* Standard processing for regular keys only. */ 987 u8MakeCode = pThis->u8ScanSet == 2 ? pKeyDef->makeS2 : pKeyDef->makeS1; 969 988 if (!(pKeyDef->keyFlags & (KF_PB | KF_PS))) 970 989 { 971 990 if (pKeyDef->keyFlags & (KF_E0 | KF_GK | KF_NS)) 972 991 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, 0xE0); 973 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, pKeyDef->makeS2);992 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, u8MakeCode); 974 993 } 975 994 } … … 983 1002 /* Undo faked Print Screen state as needed. */ 984 1003 if (pThis->u8Modifiers & (MOD_LALT | MOD_RALT)) 985 strcpy((char *)abCodes, "\xF0\x84"); 1004 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 1005 "\xF0\x84" : "\xD4"); 986 1006 else if (pThis->u8Modifiers & (MOD_LSHIFT | MOD_RSHIFT)) 987 strcpy((char *)abCodes, "\xE0\xF0\x7C"); 1007 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 1008 "\xE0\xF0\x7C" : "\xE0\xB7"); 988 1009 else 989 strcpy((char *)abCodes, "\xE0\xF0\x7C\xE0\xF0\x12"); 1010 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 1011 "\xE0\xF0\x7C\xE0\xF0\x12" : "\xE0\xB7\xE0\xAA"); 990 1012 } 991 1013 else … … 994 1016 if (pKeyDef->keyFlags & (KF_E0 | KF_GK | KF_NS)) 995 1017 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, 0xE0); 996 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, 0xF0); 997 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, pKeyDef->makeS2); 1018 if (pThis->u8ScanSet == 2) { 1019 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, 0xF0); 1020 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, pKeyDef->makeS2); 1021 } else { 1022 Assert(pThis->u8ScanSet == 1); 1023 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, pKeyDef->makeS1 | 0x80); 1024 } 998 1025 999 1026 /* Restore shift state for gray keys. */ 1000 if (pKeyDef->keyFlags & KF_GK)1027 if (pKeyDef->keyFlags & (KF_GK | KF_NS)) 1001 1028 { 1002 if ( pThis->fNumLockOn)1029 if (!pThis->fNumLockOn || (pKeyDef->keyFlags & KF_NS)) 1003 1030 { 1004 if ((pThis->u8Modifiers & (MOD_LSHIFT | MOD_RSHIFT)) == 0) 1005 strcpy((char *)abCodes, "\xE0\xF0\x12"); 1031 if (pThis->u8Modifiers & MOD_LSHIFT) 1032 strcat((char *)abCodes, pThis->u8ScanSet == 2 ? 1033 "\xE0\x12" : "\xE0\x2A"); 1034 if (pThis->u8Modifiers & MOD_RSHIFT) 1035 strcat((char *)abCodes, pThis->u8ScanSet == 2 ? 1036 "\xE0\x59" : "\xE0\x36"); 1006 1037 } 1007 1038 else 1008 1039 { 1009 if (pThis->u8Modifiers & MOD_RSHIFT)1010 strcat((char *)abCodes, "\xE0\x59");1011 if (pThis->u8Modifiers & MOD_LSHIFT)1012 strcat((char *)abCodes, "\xE0\x12");1040 Assert(pThis->fNumLockOn); /* Not for KF_NS! */ 1041 if ((pThis->u8Modifiers & (MOD_LSHIFT | MOD_RSHIFT)) == 0) 1042 strcpy((char *)abCodes, pThis->u8ScanSet == 2 ? 1043 "\xE0\xF0\x12" : "\xE0\xAA"); 1013 1044 } 1014 1045 } … … 1022 1053 } 1023 1054 } 1024 else if (pThis->u8ScanSet == 1)1025 {1026 /* Handle Scan Set 1 - similar in complexity to Set 2. */1027 if (fKeyDown)1028 {1029 if (pKeyDef->keyFlags & (KF_E0 | KF_GK | KF_NS | KF_PS))1030 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, 0xE0);1031 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, pKeyDef->makeS1);1032 }1033 else if (!(pKeyDef->keyFlags & (KF_NB | KF_PB))) {1034 if (pKeyDef->keyFlags & (KF_E0 | KF_GK | KF_NS | KF_PS))1035 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, 0xE0);1036 ps2kInsertQueue((GeneriQ *)&pThis->keyQ, pKeyDef->makeS1 | 0x80);1037 }1038 }1039 1055 else 1040 1056 { 1041 1057 /* Handle Scan Set 3 - very straightforward. */ 1058 Assert(pThis->u8ScanSet == 3); 1042 1059 if (fKeyDown) 1043 1060 {
Note:
See TracChangeset
for help on using the changeset viewer.