VirtualBox

Changeset 49384 in vbox for trunk


Ignore:
Timestamp:
Nov 4, 2013 2:32:01 PM (11 years ago)
Author:
vboxsync
Message:

PS2K: Recognize 0xFC as a special 'release all keys' event.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/PS2K.cpp

    r49254 r49384  
    7575#define KRSP_ID2            0x83
    7676#define KRSP_BAT_OK         0xAA
    77 #define KRSP_BAT_FAIL       0xFC
     77#define KRSP_BAT_FAIL       0xFC    /* Also a 'release keys' signal. */
    7878#define KRSP_ECHO           0xEE
    7979#define KRSP_ACK            0xFA
     
    11411141}
    11421142
     1143/* Release any and all currently depressed keys. Used whenever the guest keyboard
     1144 * is likely to be out of sync with the host, such as when loading a saved state
     1145 * or resuming a suspended host.
     1146 */
     1147static void ps2kReleaseKeys(PPS2K pThis)
     1148{
     1149    LogFlowFunc(("Releasing keys...\n"));
     1150    LogRel(("Releasing keys...\n"));
     1151
     1152    for (unsigned uKey = 0; uKey < sizeof(pThis->abDepressedKeys); ++uKey)
     1153        if (pThis->abDepressedKeys[uKey])
     1154        {
     1155            LogRel(("Releasing key %02X\n", uKey));
     1156            psk2ProcessKeyEvent(pThis, uKey, false /* key up */);
     1157            pThis->abDepressedKeys[uKey] = 0;
     1158        }
     1159    LogFlowFunc(("Done releasing keys\n"));
     1160}
     1161
    11431162
    11441163/**
     
    12401259    PPS2K       pThis = RT_FROM_MEMBER(pInterface, PS2K, Keyboard.IPort);
    12411260    uint32_t    u32Usage = 0;
     1261    int         rc;
    12421262
    12431263    LogFlowFunc(("key code %02X\n", u8KeyCode));
    1244     pThis->XlatState = ScancodeToHidUsage(pThis->XlatState, u8KeyCode, &u32Usage);
    1245 
    1246     if (pThis->XlatState == SS_IDLE)
    1247     {
    1248         /* Stupid Korean key hack: convert a lone break key into a press/release sequence. */
    1249         if (u32Usage == 0x80000090 || u32Usage == 0x80000091)
    1250             ps2kPutEventWorker(pThis, u32Usage & ~0x80000000);
    1251 
    1252         ps2kPutEventWorker(pThis, u32Usage);
     1264
     1265    /* The 'BAT fail' scancode is reused as a signal to release keys. No actual
     1266     * key is allowed to use this scancode.
     1267     */
     1268    if (RT_UNLIKELY(u8KeyCode == KRSP_BAT_FAIL))
     1269    {
     1270        rc = PDMCritSectEnter(pThis->pCritSectR3, VERR_SEM_BUSY);
     1271        AssertReleaseRC(rc);
     1272
     1273        ps2kReleaseKeys(pThis);
     1274
     1275        PDMCritSectLeave(pThis->pCritSectR3);
     1276    }
     1277    else
     1278    {
     1279        pThis->XlatState = ScancodeToHidUsage(pThis->XlatState, u8KeyCode, &u32Usage);
     1280
     1281        if (pThis->XlatState == SS_IDLE)
     1282        {
     1283            /* Stupid Korean key hack: convert a lone break key into a press/release sequence. */
     1284            if (u32Usage == 0x80000090 || u32Usage == 0x80000091)
     1285                ps2kPutEventWorker(pThis, u32Usage & ~0x80000000);
     1286
     1287            ps2kPutEventWorker(pThis, u32Usage);
     1288        }
    12531289    }
    12541290
     
    13411377    SSMR3PutU32(pSSM, cPressed);
    13421378
    1343     for (unsigned i = 0; i < sizeof(pThis->abDepressedKeys); ++i)
    1344         if (pThis->abDepressedKeys[i])
    1345             SSMR3PutU8(pSSM, pThis->abDepressedKeys[i]);
     1379    for (unsigned uKey = 0; uKey < sizeof(pThis->abDepressedKeys); ++uKey)
     1380        if (pThis->abDepressedKeys[uKey])
     1381            SSMR3PutU8(pSSM, uKey);
    13461382
    13471383    /* Save the typematic settings for Scan Set 3. */
     
    13891425    AssertRCReturn(rc, rc);
    13901426
    1391     while (cPressed--)
    1392     {
    1393         rc = SSMR3GetU8(pSSM, &u8);
    1394         AssertRCReturn(rc, rc);
    1395         psk2ProcessKeyEvent(pThis, u8, false /* key up */);
     1427    /* If any keys were down, load and then release them. */
     1428    if (cPressed)
     1429    {
     1430        for (unsigned i = 0; i < cPressed; ++i)
     1431        {
     1432            rc = SSMR3GetU8(pSSM, &u8);
     1433            AssertRCReturn(rc, rc);
     1434            pThis->abDepressedKeys[u8] = 1;
     1435        }
     1436        ps2kReleaseKeys(pThis);
    13961437    }
    13971438
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette