VirtualBox

Changeset 40310 in vbox


Ignore:
Timestamp:
Mar 1, 2012 11:56:06 AM (13 years ago)
Author:
vboxsync
Message:

Devices/VMMDev and Additions: use a single definition for the value range of the Additions pointer position reporting.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VMMDev.h

    r40213 r40310  
    317317       | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR \
    318318       | VMMDEV_MOUSE_HOST_HAS_ABS_DEV)
     319/** @} */
     320
     321/** @name Absolute mouse reporting range
     322 * @{ */
     323/** @todo Should these be here?  They are needed by both host and guest. */
     324/** The minumum value our pointing device can return. */
     325#define VMMDEV_MOUSE_RANGE_MIN 0
     326/** The maximum value our pointing device can return. */
     327#define VMMDEV_MOUSE_RANGE_MAX 0xFFFF
     328/** The full range our pointing device can return. */
     329#define VMMDEV_MOUSE_RANGE (VMMDEV_MOUSE_RANGE_MAX - VMMDEV_MOUSE_RANGE_MIN)
    319330/** @} */
    320331
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c

    r39353 r40310  
    390390
    391391
    392 enum
    393 {
    394     /** The minumum value our device can return */
    395     RANGE_MIN = 0,
    396     /** The maximum value our device can return */
    397     RANGE_MAX = 0xFFFF
    398 };
    399 
    400 
    401392#ifdef VBOXGUEST_WITH_INPUT_DRIVER
    402393/** Calls the kernel IOCtl to report mouse status to the host on behalf of
     
    476467    ASMBitSet(g_pInputDevice->evbit, EV_SYN);
    477468# endif
    478     input_set_abs_params(g_pInputDevice, ABS_X, RANGE_MIN, RANGE_MAX, 0, 0);
    479     input_set_abs_params(g_pInputDevice, ABS_Y, RANGE_MIN, RANGE_MAX, 0, 0);
     469    input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN,
     470                         VMMDEV_MOUSE_RANGE_MAX, 0, 0);
     471    input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN,
     472                         VMMDEV_MOUSE_RANGE_MAX, 0, 0);
    480473    ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE);
    481474    /** @todo this string should be in a header file somewhere. */
  • trunk/src/VBox/Additions/x11/vboxmouse/vboxmouse.c

    r39811 r40310  
    6363#include "product-generated.h"
    6464
    65 enum
    66 {
    67     /** The minumum value our device can return */
    68     RANGE_MIN = 0,
    69     /** The maximum value our device can return */
    70     RANGE_MAX = 0xFFFF
    71 };
    72 
    7365static void
    7466VBoxReadInput(InputInfoPtr pInfo)
     
    144136                               axis_labels[0],
    145137# endif
    146                                RANGE_MIN /* min X */, RANGE_MAX /* max X */,
     138                               VMMDEV_MOUSE_RANGE_MIN /* min X */, VMMDEV_MOUSE_RANGE_MAX /* max X */,
    147139                               10000, 0, 10000
    148140# if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
     
    155147                               axis_labels[1],
    156148# endif
    157                                RANGE_MIN /* min Y */, RANGE_MAX /* max Y */,
     149                               VMMDEV_MOUSE_RANGE_MIN /* min Y */, VMMDEV_MOUSE_RANGE_MAX /* max Y */,
    158150                               10000, 0, 10000
    159151# if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
  • trunk/src/VBox/Main/src-client/MouseImpl.cpp

    r40282 r40310  
    4141/** @} */
    4242
    43 /** @name Absolute mouse reporting range
    44  * @{ */
    45 enum
    46 {
    47     /** Lower end */
    48     MOUSE_RANGE_LOWER = 0,
    49     /** Higher end */
    50     MOUSE_RANGE_UPPER = 0xFFFF,
    51     /** Full range */
    52     MOUSE_RANGE = MOUSE_RANGE_UPPER - MOUSE_RANGE_LOWER
    53 };
    54 /** @} */
    5543
    5644/**
     
    327315                                        int32_t dz, int32_t dw, uint32_t fButtons)
    328316{
    329     if (mouseXAbs < MOUSE_RANGE_LOWER || mouseXAbs > MOUSE_RANGE_UPPER)
     317    if (   mouseXAbs < VMMDEV_MOUSE_RANGE_MIN
     318        || mouseXAbs > VMMDEV_MOUSE_RANGE_MAX)
    330319        return S_OK;
    331     if (mouseYAbs < MOUSE_RANGE_LOWER || mouseYAbs > MOUSE_RANGE_UPPER)
     320    if (   mouseYAbs < VMMDEV_MOUSE_RANGE_MIN
     321        || mouseYAbs > VMMDEV_MOUSE_RANGE_MAX)
    332322        return S_OK;
    333323    if (   mouseXAbs != mcLastAbsX || mouseYAbs != mcLastAbsY
     
    477467/**
    478468 * Convert an (X, Y) value pair in screen co-ordinates (starting from 1) to a
    479  * value from MOUSE_RANGE_LOWER to MOUSE_RANGE_UPPER.  Sets the optional
    480  * validity value to false if the pair is not on an active screen and to true
    481  * otherwise.
     469 * value from VMMDEV_MOUSE_RANGE_MIN to VMMDEV_MOUSE_RANGE_MAX.  Sets the
     470 * optional validity value to false if the pair is not on an active screen and
     471 * to true otherwise.
    482472 * @note      since guests with recent versions of X.Org use a different method
    483473 *            to everyone else to map the valuator value to a screen pixel (they
     
    501491     * to compensate for differences in guest methods for mapping back to
    502492     * pixels */
    503     enum { ADJUST_RANGE = - 3 * MOUSE_RANGE / 4 };
     493    enum { ADJUST_RANGE = - 3 * VMMDEV_MOUSE_RANGE / 4 };
    504494
    505495    if (pfValid)
     
    509499        ULONG displayWidth, displayHeight;
    510500        /* Takes the display lock */
    511         HRESULT rc = pDisplay->GetScreenResolution(0, &displayWidth, &displayHeight,
    512                                                    NULL);
     501        HRESULT rc = pDisplay->GetScreenResolution(0, &displayWidth,
     502                                                   &displayHeight, NULL);
    513503        if (FAILED(rc))
    514504            return rc;
    515505
    516         *pcX = displayWidth ? (x * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayWidth: 0;
    517         *pcY = displayHeight ? (y * MOUSE_RANGE + ADJUST_RANGE) / (LONG) displayHeight: 0;
     506        *pcX = displayWidth ?    (x * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     507                               / (LONG) displayWidth: 0;
     508        *pcY = displayHeight ?   (y * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     509                               / (LONG) displayHeight: 0;
    518510    }
    519511    else
     
    522514        /* Takes the display lock */
    523515        pDisplay->getFramebufferDimensions(&x1, &y1, &x2, &y2);
    524         *pcX = x1 < x2 ? ((x - x1) * MOUSE_RANGE + ADJUST_RANGE) / (x2 - x1) : 0;
    525         *pcY = y1 < y2 ? ((y - y1) * MOUSE_RANGE + ADJUST_RANGE) / (y2 - y1) : 0;
    526         if (   *pcX < MOUSE_RANGE_LOWER || *pcX > MOUSE_RANGE_UPPER
    527             || *pcY < MOUSE_RANGE_LOWER || *pcY > MOUSE_RANGE_UPPER)
     516        *pcX = x1 < x2 ?   ((x - x1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     517                         / (x2 - x1) : 0;
     518        *pcY = y1 < y2 ?   ((y - y1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
     519                         / (y2 - y1) : 0;
     520        if (   *pcX < VMMDEV_MOUSE_RANGE_MIN || *pcX > VMMDEV_MOUSE_RANGE_MAX
     521            || *pcY < VMMDEV_MOUSE_RANGE_MIN || *pcY > VMMDEV_MOUSE_RANGE_MAX)
    528522            if (pfValid)
    529523                *pfValid = false;
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