VirtualBox

Changeset 96909 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 27, 2022 11:24:45 PM (2 years ago)
Author:
vboxsync
Message:

Main/MouseImpl: Simplified i_getDeviceCaps and code immediately associated with it.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MouseImpl.h

    r96407 r96909  
    127127    HRESULT i_putEventMultiTouch(LONG aCount, const LONG64 *paContacts, BOOL isTouchScreen, ULONG aScanTime);
    128128
    129     void i_getDeviceCaps(bool *pfAbs, bool *pfRel, bool *pfTS, bool *pfTP);
     129    uint32_t i_getDeviceCaps(void);
    130130    void i_sendMouseCapsNotifications(void);
    131131    bool i_guestNeedsHostCursor(void);
    132132    bool i_vmmdevCanAbs(void);
    133133    bool i_deviceCanAbs(void);
     134    bool i_supportsAbs(uint32_t fCaps) const;
    134135    bool i_supportsAbs(void);
    135136    bool i_supportsRel(void);
  • trunk/src/VBox/Main/src-client/MouseImpl.cpp

    r96908 r96909  
    10061006{
    10071007    if (aCount >= 256)
    1008     {
    1009          return E_INVALIDARG;
    1010     }
     1008        return E_INVALIDARG;
    10111009
    10121010    HRESULT hrc = S_OK;
     
    10951093                    }
    10961094                }
    1097             } else {
     1095            }
     1096            else
     1097            {
    10981098                LONG i;
    10991099                for (i = 0; i < aCount; i++)
     
    11461146
    11471147
    1148 /** Check what sort of reporting can be done using the devices currently
    1149  * enabled.  Does not consider the VMM device.
    1150  *
    1151  * @param   pfAbs   supports absolute mouse coordinates.
    1152  * @param   pfRel   supports relative mouse coordinates.
    1153  * @param   pfTS    supports touchscreen.
    1154  * @param   pfTP    supports touchpad.
    1155  */
    1156 void Mouse::i_getDeviceCaps(bool *pfAbs, bool *pfRel, bool *pfTS, bool *pfTP)
    1157 {
    1158     bool fAbsDev = false;
    1159     bool fRelDev = false;
    1160     bool fTSDev  = false;
    1161     bool fTPDev  = false;
    1162 
     1148/**
     1149 * Gets the combined capabilities of all currently enabled devices.
     1150 *
     1151 * @returns Combination of MOUSE_DEVCAP_XXX
     1152 */
     1153uint32_t Mouse::i_getDeviceCaps(void)
     1154{
     1155    uint32_t fCaps = 0;
    11631156    AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
    1164 
    11651157    for (unsigned i = 0; i < MOUSE_MAX_DEVICES; ++i)
    11661158        if (mpDrv[i])
    1167         {
    1168            if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_ABSOLUTE)
    1169                fAbsDev = true;
    1170            if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_RELATIVE)
    1171                fRelDev = true;
    1172            if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_MT_ABSOLUTE)
    1173                fTSDev  = true;
    1174            if (mpDrv[i]->u32DevCaps & MOUSE_DEVCAP_MT_RELATIVE)
    1175                fTPDev  = true;
    1176         }
    1177     if (pfAbs)
    1178         *pfAbs = fAbsDev;
    1179     if (pfRel)
    1180         *pfRel = fRelDev;
    1181     if (pfTS)
    1182         *pfTS = fTSDev;
    1183     if (pfTP)
    1184         *pfTP = fTPDev;
     1159            fCaps |= mpDrv[i]->u32DevCaps;
     1160    return fCaps;
    11851161}
    11861162
     
    11891165bool Mouse::i_vmmdevCanAbs(void)
    11901166{
    1191     bool fRelDev;
    1192 
    1193     i_getDeviceCaps(NULL, &fRelDev, NULL, NULL);
    1194     return    (mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
    1195            && fRelDev;
    1196 }
    1197 
    1198 
    1199 /** Does the VMM device currently support absolute reporting? */
     1167    /* This requires the VMMDev cap and a relative device, which supposedly
     1168       consumes these. As seen in @bugref{10285} this isn't quite as clear cut. */
     1169    return (mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
     1170        && (i_getDeviceCaps() & MOUSE_DEVCAP_RELATIVE);
     1171}
     1172
     1173
     1174/** Does any device currently support absolute reporting w/o help from VMMDev? */
    12001175bool Mouse::i_deviceCanAbs(void)
    12011176{
    1202     bool fAbsDev;
    1203 
    1204     i_getDeviceCaps(&fAbsDev, NULL, NULL, NULL);
    1205     return fAbsDev;
     1177    return RT_BOOL(i_getDeviceCaps() & MOUSE_DEVCAP_ABSOLUTE);
    12061178}
    12071179
     
    12101182bool Mouse::i_supportsRel(void)
    12111183{
    1212     bool fRelDev;
    1213 
    1214     i_getDeviceCaps(NULL, &fRelDev, NULL, NULL);
    1215     return fRelDev;
     1184    return RT_BOOL(i_getDeviceCaps() & MOUSE_DEVCAP_RELATIVE);
     1185}
     1186
     1187
     1188/** Can we currently send absolute events to the guest (including via VMMDev)? */
     1189bool Mouse::i_supportsAbs(uint32_t fCaps) const
     1190{
     1191    return (fCaps & MOUSE_DEVCAP_ABSOLUTE)
     1192        || /* inlined i_vmmdevCanAbs() to avoid unnecessary i_getDeviceCaps call: */
     1193           (   (mfVMMDevGuestCaps & VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE)
     1194            && (fCaps & MOUSE_DEVCAP_RELATIVE));
    12161195}
    12171196
     
    12201199bool Mouse::i_supportsAbs(void)
    12211200{
    1222     bool fAbsDev;
    1223 
    1224     i_getDeviceCaps(&fAbsDev, NULL, NULL, NULL);
    1225     return fAbsDev || i_vmmdevCanAbs();
     1201    return Mouse::i_supportsAbs(i_getDeviceCaps());
    12261202}
    12271203
     
    12301206bool Mouse::i_supportsTS(void)
    12311207{
    1232     bool fTSDev;
    1233 
    1234     i_getDeviceCaps(NULL, NULL, &fTSDev, NULL);
    1235     return fTSDev;
     1208    return RT_BOOL(i_getDeviceCaps() & MOUSE_DEVCAP_MT_ABSOLUTE);
    12361209}
    12371210
     
    12401213bool Mouse::i_supportsTP(void)
    12411214{
    1242     bool fTPDev;
    1243 
    1244     i_getDeviceCaps(NULL, NULL, NULL, &fTPDev);
    1245     return fTPDev;
     1215    return RT_BOOL(i_getDeviceCaps() & MOUSE_DEVCAP_MT_RELATIVE);
    12461216}
    12471217
     
    12531223{
    12541224    bool fRelDev, fTSDev, fTPDev, fCanAbs, fNeedsHostCursor;
    1255 
    12561225    {
    12571226        AutoReadLock aLock(this COMMA_LOCKVAL_SRC_POS);
    12581227
    1259         i_getDeviceCaps(NULL, &fRelDev, &fTSDev, &fTPDev);
    1260         fCanAbs = i_supportsAbs();
     1228        uint32_t const fCaps = i_getDeviceCaps();
     1229        fRelDev = RT_BOOL(fCaps & MOUSE_DEVCAP_RELATIVE);
     1230        fTSDev  = RT_BOOL(fCaps & MOUSE_DEVCAP_MT_ABSOLUTE);
     1231        fTPDev  = RT_BOOL(fCaps & MOUSE_DEVCAP_MT_RELATIVE);
     1232        fCanAbs = i_supportsAbs(fCaps);
    12611233        fNeedsHostCursor = i_guestNeedsHostCursor();
    12621234    }
     
    12671239/**
    12681240 * @interface_method_impl{PDMIMOUSECONNECTOR,pfnReportModes}
    1269  * A virtual device is notifying us about its current state and capabilities
    12701241 */
    12711242DECLCALLBACK(void) Mouse::i_mouseReportModes(PPDMIMOUSECONNECTOR pInterface, bool fRelative,
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