VirtualBox

Changeset 79729 in vbox


Ignore:
Timestamp:
Jul 12, 2019 12:22:16 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Using usage page/id instead of scan codes

Location:
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79669 r79729  
    9696};
    9797
    98 struct KeyCaptions
    99 {
    100     QString m_strBase;
    101     QString m_strShift;
    102     QString m_strAltGr;
    103     QString m_strShiftAltGr;
    104 };
    105 
    10698enum KeyboardColorType
    10799{
     
    112104    KeyboardColorType_Pressed,
    113105    KeyboardColorType_Max
     106};
     107
     108struct KeyCaptions
     109{
     110    QString m_strBase;
     111    QString m_strShift;
     112    QString m_strAltGr;
     113    QString m_strShiftAltGr;
     114};
     115
     116struct UsageCode
     117{
     118    LONG usageId;
     119    LONG usagePage;
     120    bool fRelease;
    114121};
    115122
     
    327334    void addScanCodePrefix(LONG scanCode);
    328335    const QVector<LONG> &scanCodePrefix() const;
     336
     337    void setUsageId(LONG usageId);
     338    void setUsagePage(LONG usagePage);
     339    QPair<LONG, LONG> usagePageIdPair() const;
    329340
    330341    void setSpaceWidthAfter(int iSpace);
     
    391402    int        m_iPosition;
    392403    UISoftKeyboardWidget  *m_pParentWidget;
     404
     405    LONG m_iUsageId;
     406    LONG m_iUsagePage;
     407
    393408    bool m_fIsNumPadKey;
    394409    bool m_fIsOSMenuKey;
     
    509524    void sigStatusBarMessage(const QString &strMessage);
    510525    void sigPutKeyboardSequence(QVector<LONG> sequence);
     526
     527    void sigPutUsageCodesPress(QVector<QPair<LONG, LONG> > sequence);
     528    void sigPutUsageCodesRelease(QVector<QPair<LONG, LONG> > sequence);
     529
     530
    511531    void sigCurrentLayoutChange();
    512532    void sigKeyToEdit(UISoftKeyboardKey* pKey);
     
    14631483}
    14641484
     1485void UISoftKeyboardKey::setUsageId(LONG usageId)
     1486{
     1487    m_iUsageId = usageId;
     1488}
     1489
     1490void UISoftKeyboardKey::setUsagePage(LONG usagePage)
     1491{
     1492    m_iUsagePage = usagePage;
     1493}
     1494
     1495QPair<LONG, LONG> UISoftKeyboardKey::usagePageIdPair() const
     1496{
     1497    return QPair<LONG, LONG>(m_iUsageId, m_iUsagePage);
     1498}
     1499
    14651500int UISoftKeyboardKey::spaceWidthAfter() const
    14661501{
     
    24262461        return;
    24272462
     2463#if 0
     2464
    24282465    QVector<LONG> sequence;
    24292466    if (!pKey->scanCodePrefix().isEmpty())
     
    24422479    }
    24432480    emit sigPutKeyboardSequence(sequence);
     2481
     2482#else
     2483
     2484    QVector<QPair<LONG, LONG> > sequence;
     2485    sequence << QPair<LONG, LONG>(pKey->usagePageIdPair());
     2486    /* Add the pressed modifiers in the reverse order: */
     2487    for (int i = m_pressedModifiers.size() - 1; i >= 0; --i)
     2488    {
     2489        UISoftKeyboardKey *pModifier = m_pressedModifiers[i];
     2490        sequence << pModifier->usagePageIdPair();
     2491        /* Release the pressed modifiers (if there are not locked): */
     2492        pModifier->release();
     2493    }
     2494    emit sigPutUsageCodesRelease(sequence);
     2495
     2496#endif
    24442497}
    24452498
     
    24532506        return;
    24542507
     2508#if 0
    24552509    QVector<LONG> sequence;
    24562510     /* Add the pressed modifiers first: */
     
    24672521    sequence << pKey->scanCode();
    24682522    emit sigPutKeyboardSequence(sequence);
     2523
     2524#else
     2525
     2526    QVector<QPair<LONG, LONG> > sequence;
     2527
     2528     /* Add the pressed modifiers first: */
     2529    for (int i = 0; i < m_pressedModifiers.size(); ++i)
     2530    {
     2531        UISoftKeyboardKey *pModifier = m_pressedModifiers[i];
     2532        sequence << pModifier->usagePageIdPair();
     2533    }
     2534
     2535    sequence << pKey->usagePageIdPair();
     2536    emit sigPutUsageCodesPress(sequence);
     2537
     2538#endif
    24692539}
    24702540
     
    29232993                    key.addScanCodePrefix(iCode);
    29242994            }
     2995        }
     2996        else if (m_xmlReader.name() == "usageid")
     2997        {
     2998            QString strCode = m_xmlReader.readElementText();
     2999            bool fOk = false;
     3000            key.setUsageId(strCode.toInt(&fOk, 16));
     3001        }
     3002        else if (m_xmlReader.name() == "usagepage")
     3003        {
     3004            QString strCode = m_xmlReader.readElementText();
     3005            bool fOk = false;
     3006            key.setUsagePage(strCode.toInt(&fOk, 16));
    29253007        }
    29263008        else if (m_xmlReader.name() == "cutout")
     
    33913473}
    33923474
     3475void UISoftKeyboard::sltPutUsageCodesPress(QVector<QPair<LONG, LONG> > sequence)
     3476{
     3477    for (int i = 0; i < sequence.size(); ++i)
     3478        keyboard().PutUsageCode(sequence[i].first, sequence[i].second, false);
     3479}
     3480
     3481void UISoftKeyboard::sltPutUsageCodesRelease(QVector<QPair<LONG, LONG> > sequence)
     3482{
     3483    for (int i = 0; i < sequence.size(); ++i)
     3484        keyboard().PutUsageCode(sequence[i].first, sequence[i].second, true);
     3485}
     3486
    33933487void UISoftKeyboard::sltStatusBarContextMenuRequest(const QPoint &point)
    33943488{
     
    35923686    connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltKeyboardLedsChange);
    35933687    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltPutKeyboardSequence);
     3688    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutUsageCodesPress, this, &UISoftKeyboard::sltPutUsageCodesPress);
     3689    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutUsageCodesRelease, this, &UISoftKeyboard::sltPutUsageCodesRelease);
     3690
    35943691    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigCurrentLayoutChange, this, &UISoftKeyboard::sltCurentLayoutChanged);
    35953692    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigKeyToEdit, this, &UISoftKeyboard::sltKeyToEditChanged);
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79641 r79729  
    6767    void sltKeyboardLedsChange();
    6868    void sltPutKeyboardSequence(QVector<LONG> sequence);
     69    void sltPutUsageCodesPress(QVector<QPair<LONG, LONG> > sequence);
     70    void sltPutUsageCodesRelease(QVector<QPair<LONG, LONG> > sequence);
     71
    6972    void sltStatusBarContextMenuRequest(const QPoint &point);
    7073    /** Handles the signal we get from the layout selector widget.
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