~ubuntu-branches/ubuntu/maverick/wacom-tools/maverick

« back to all changes in this revision

Viewing changes to linuxwacom/src/xdrv/wcmCommon.c

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-09-16 16:31:32 UTC
  • mfrom: (1.12.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090916163132-ow32sul82lb7wqb8
Tags: 1:0.8.4.1-0ubuntu1
* New upstream version. (LP: #405800)
* xsfbs: Remove deprecated --print-installation-architecture. (LP: #403316)
* waltop-ntrig.diff: Drop support for WALTOP, it doesn't work and crashes
  the server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
 
142
142
        if (!(local->flags & (XI86_ALWAYS_CORE | XI86_CORE_POINTER))) return;
143
143
 
144
 
        if (priv->twinview != TV_NONE && priv->screen_no == -1 && (priv->flags & ABSOLUTE_FLAG))
 
144
        if (priv->twinview > TV_XINERAMA && priv->screen_no == -1 && (priv->flags & ABSOLUTE_FLAG))
145
145
        {
146
146
                if (priv->twinview == TV_LEFT_RIGHT)
147
147
                {
226
226
        xf86WcmVirtaulTabletPadding(local);
227
227
        x = ((double)(v0 + priv->leftPadding) * priv->factorX) - priv->screenTopX[screenToSet] + 0.5;
228
228
        y = ((double)(v1 + priv->topPadding) * priv->factorY) - priv->screenTopY[screenToSet] + 0.5;
229
 
                
 
229
 
230
230
        if (x >= screenInfo.screens[screenToSet]->width)
231
231
                x = screenInfo.screens[screenToSet]->width - 1;
232
232
        if (y >= screenInfo.screens[screenToSet]->height)
254
254
                "buttons=%d for %s\n", buttons, local->name));
255
255
 
256
256
        /* Tablet PC buttons. */
257
 
        if ( common->wcmTPCButton && !IsCursor(priv) && !IsPad(priv) )
 
257
        if ( common->wcmTPCButton && !IsCursor(priv) && !IsPad(priv) && !IsTouch(priv) )
258
258
        {
259
259
                if ( buttons & 1 )
260
260
                {
521
521
                button, mask, priv->button[button], 
522
522
                local->name, (priv->button[button] & AC_CORE) ? "yes" : "no"));
523
523
 
524
 
        switch (button & AC_TYPE)
 
524
        switch (priv->button[button] & AC_TYPE)
525
525
        {
526
526
        case AC_BUTTON:
527
527
                xf86PostButtonEvent(local->dev, is_absolute, priv->button[button] & AC_CODE,
545
545
        case AC_DISPLAYTOGGLE:
546
546
                if (mask && priv->numScreen > 1)
547
547
                {
548
 
                        if (IsPad(priv)) /* toggle display for all tools except pad */
 
548
                        if (IsPad(priv)) /* toggle display (individual screens plus the whole desktop) for all tools except pad */
549
549
                        {
550
550
                                WacomDevicePtr tmppriv;
551
551
                                for (tmppriv = common->wcmDevices; tmppriv; tmppriv = tmppriv->next)
559
559
                                        }
560
560
                                }
561
561
                        }
562
 
                        else /* toggle display only for the selected tool */
 
562
                        else /* toggle display (individual screens plus the whole desktop) only for the selected tool */
563
563
                        {
564
564
                                int screen = priv->screen_no;
565
565
                                if (++screen >= priv->numScreen)
569
569
                }
570
570
                break;
571
571
 
 
572
        case AC_SCREENTOGGLE:
 
573
                if (mask && priv->numScreen > 1)
 
574
                {
 
575
                        if (IsPad(priv)) /* toggle screens for all tools except pad */
 
576
                        {
 
577
                                WacomDevicePtr tmppriv;
 
578
                                for (tmppriv = common->wcmDevices; tmppriv; tmppriv = tmppriv->next)
 
579
                                {
 
580
                                        if (!IsPad(tmppriv))
 
581
                                        {
 
582
                                                int screen = tmppriv->screen_no;
 
583
                                                if (++screen >= tmppriv->numScreen)
 
584
                                                        screen = 0;
 
585
                                                xf86WcmChangeScreen(tmppriv->local, screen);
 
586
                                        }
 
587
                                }
 
588
                        }
 
589
                        else /* toggle screens only for the selected tool */
 
590
                        {
 
591
                                int screen = priv->screen_no;
 
592
                                if (++screen >= priv->numScreen)
 
593
                                        screen = 0;
 
594
                                xf86WcmChangeScreen(local, screen);
 
595
                        }
 
596
                }
 
597
                break;
 
598
 
572
599
        case AC_DBLCLICK:
573
600
                if (mask)
574
601
                {
575
602
                        /* Left button down */
576
603
                        xf86PostButtonEvent(local->dev, is_absolute,
577
604
                                1,1,0,naxes, rx,ry,rz,v3,v4,v5);
578
 
 
579
605
                        /* Left button up */
580
606
                        xf86PostButtonEvent(local->dev, is_absolute,
581
607
                                1,0,0,naxes,rx,ry,rz,v3,v4,v5);
603
629
                int x, int y, int z, int v3, int v4, int v5)
604
630
{
605
631
        WacomDevicePtr priv = (WacomDevicePtr) local->private;
 
632
        WacomCommonPtr common = priv->common;
606
633
        int fakeButton = 0, i, value = 0, naxes = priv->naxes;
607
634
        unsigned  *keyP = 0;
608
635
        int is_absolute = priv->flags & ABSOLUTE_FLAG;
631
658
        if ( ds->abswheel != priv->oldWheel )
632
659
        {
633
660
                value = priv->oldWheel - ds->abswheel;
 
661
                if ((strstr(common->wcmModel->name, "Bamboo") ||
 
662
                strstr(common->wcmModel->name, "Intuos4"))
 
663
                        && IsPad(priv))
 
664
                {
 
665
                        /* deal with MAX_FINGER_WHEEL to 0 and 0 to MAX_FINGER_WHEEL switching */
 
666
                        if (abs(priv->oldWheel - ds->abswheel) > (MAX_FINGER_WHEEL/2))
 
667
                        {
 
668
                                if (priv->oldWheel > ds->abswheel)
 
669
                                        value -= MAX_FINGER_WHEEL;
 
670
                                else
 
671
                                        value += MAX_FINGER_WHEEL;
 
672
                        }
 
673
                }
634
674
                if ( value > 0 )
635
675
                {
636
676
                        fakeButton = priv->wheelup;
746
786
        WacomDevicePtr priv = (WacomDevicePtr) local->private;
747
787
        int buttons = ds->buttons;
748
788
 
 
789
        /* send button events when state changed or first time in prox and button unpresses */
749
790
        if (priv->oldButtons != buttons || (!priv->oldProximity && !buttons))
750
791
                xf86WcmSendButtons(local,buttons,x,y,z,v3,v4,v5);
751
792
 
938
979
                        if(is_absolute) {
939
980
                                x -= priv->topX;
940
981
                                y -= priv->topY;
941
 
                                if (priv->currentScreen == 1 && priv->twinview != TV_NONE)
 
982
                                if (priv->currentScreen == 1 && priv->twinview > TV_XINERAMA)
942
983
                                {
943
984
                                        x -= priv->tvoffsetX;
944
985
                                        y -= priv->tvoffsetY;
947
988
                        x = (int)((double)x * priv->factorX + (x>=0?0.4:-0.4));
948
989
                        y = (int)((double)y * priv->factorY + (y>=0?0.4:-0.4));
949
990
 
 
991
                        if ((priv->flags & ABSOLUTE_FLAG) && (priv->twinview <= TV_XINERAMA))
 
992
                        {
 
993
                                x -= priv->screenTopX[priv->currentScreen];
 
994
                                y -= priv->screenTopY[priv->currentScreen];
 
995
                        }
 
996
 
 
997
                        if (priv->screen_no != -1)
 
998
                        {
 
999
                                if (x > priv->screenBottomX[priv->currentScreen] - priv->screenTopX[priv->currentScreen])
 
1000
                                        x = priv->screenBottomX[priv->currentScreen];
 
1001
                                if (x < 0) x = 0;
 
1002
                                if (y > priv->screenBottomY[priv->currentScreen] - priv->screenTopY[priv->currentScreen])
 
1003
                                        y = priv->screenBottomY[priv->currentScreen];
 
1004
                                if (y < 0) y = 0;
 
1005
        
 
1006
                        }
950
1007
                        priv->currentSX = x;
951
1008
                        priv->currentSY = y;
952
1009
#endif
985
1042
        }
986
1043
        else
987
1044
        {
 
1045
 
988
1046
                if (v3 || v4 || v5 || buttons || ds->relwheel)
989
1047
                {
990
1048
                        x = 0;
1205
1263
#ifdef WCM_ENABLE_LINUXINPUT
1206
1264
        /* Discard the first 2 USB packages due to events delay */
1207
1265
        if ( (pChannel->nSamples < 2) && (common->wcmDevCls == &gWacomUSBDevice) && 
1208
 
                ds.device_type != PAD_ID )
 
1266
                (ds.device_type != PAD_ID) )
1209
1267
        {
1210
1268
                DBG(11, common->debugLevel, 
1211
1269
                        ErrorF("discarded %dth USB data.\n", 
1243
1301
                }
1244
1302
                fs->x[0] = ds.x;
1245
1303
                fs->y[0] = ds.y;
1246
 
                if (HANDLE_TILT(common) && (ds.device_type == STYLUS_ID || ds.device_type == ERASER_ID))
 
1304
                if (HANDLE_TILT(common) && ((ds.device_type == STYLUS_ID) || (ds.device_type == ERASER_ID)))
1247
1305
                {
1248
1306
                        for (i=common->wcmRawSample - 1; i>0; i--)
1249
1307
                        {
1253
1311
                        fs->tiltx[0] = ds.tiltx;
1254
1312
                        fs->tilty[0] = ds.tilty;
1255
1313
                }
1256
 
                if (RAW_FILTERING(common) && common->wcmModel->FilterRaw && ds.device_type != PAD_ID)
 
1314
 
 
1315
                if (RAW_FILTERING(common) && common->wcmModel->FilterRaw && (ds.device_type != PAD_ID))
1257
1316
                {
1258
1317
                        if (common->wcmModel->FilterRaw(common,pChannel,&ds))
1259
1318
                        {
1263
1322
                                return; /* discard */
1264
1323
                        }
1265
1324
                }
1266
 
 
1267
1325
                /* Discard unwanted data */
1268
1326
                suppress = xf86WcmSuppress(common, pLast, &ds);
1269
1327
                if (!suppress)
1284
1342
                pChannel->valid.states,
1285
1343
                sizeof(WacomDeviceState) * (common->wcmRawSample - 1));
1286
1344
        pChannel->valid.state = ds; /*save last raw sample */
 
1345
 
1287
1346
        if (pChannel->nSamples < common->wcmRawSample) ++pChannel->nSamples;
1288
 
 
1289
1347
        commonDispatchDevice(common,channel,pChannel, suppress);
1290
1348
        resetSampleCounter(pChannel);
1291
1349
}
1368
1426
                                        break;
1369
1427
                                }
1370
1428
        }
1371
 
 
1372
1429
        DBG(10, common->debugLevel, ErrorF("commonDispatchDevice device type = %d\n", ds->device_type));
1373
1430
        /* Find the device the current events are meant for */
1374
1431
        /* 1: Find the tool (the one with correct serial or in second
1528
1585
                                int tol = common->wcmMaxZ / 250;
1529
1586
                                if (strstr(common->wcmModel->name, "Intuos4"))
1530
1587
                                        tol = common->wcmMaxZ / 125;
1531
 
                                if (filtered.pressure < common->wcmThreshold + tol)
 
1588
                                if (filtered.pressure < common->wcmThreshold - tol)
1532
1589
                                        filtered.buttons &= ~button;
1533
1590
                        }
1534
1591
                        /* transform pressure */
1543
1600
                                        (5 - common->wcmCapacity))
1544
1601
                                filtered.buttons |= button;
1545
1602
                }
1546
 
                else if (!(priv->flags & ABSOLUTE_FLAG) && !priv->hardProx)
 
1603
                else if (IsCursor(priv) && !priv->hardProx)
1547
1604
                {
1548
1605
                        /* initial current max distance */
1549
1606
                        if (strstr(common->wcmModel->name, "Intuos"))
1604
1661
 
1605
1662
                #endif /* throttle */
1606
1663
 
1607
 
                if (!(priv->flags & ABSOLUTE_FLAG))
 
1664
                if (!(priv->flags & ABSOLUTE_FLAG) && !IsPad(priv))
1608
1665
                {
1609
1666
                        /* To improve the accuracy of relative x/y,
1610
1667
                         * don't send motion event when there is no movement.
1613
1670
                        double delty = filtered.y - priv->oldY;
1614
1671
                        deltx *= priv->factorY*priv->speed;
1615
1672
                        delty *= priv->factorY*priv->speed;
1616
 
 
 
1673
        
1617
1674
                        if (ABS(deltx)<1 && ABS(delty)<1) 
1618
1675
                        {
1619
1676
                                /* don't move the cursor */
1624
1681
                                        filtered.y = priv->oldY;
1625
1682
                                }
1626
1683
                                else /* no other events to send */
 
1684
                                {
 
1685
                                        DBG(10, common->debugLevel, ErrorF(
 
1686
                                                "Ignore non-movement relative data \n"));
1627
1687
                                        return;
 
1688
                                }
1628
1689
                        }
1629
1690
                        else
1630
1691
                        {
1637
1698
                        }
1638
1699
                }
1639
1700
 
1640
 
                /* force out-prox when distance is outside wcmCursorProxoutDist. */
1641
 
                if (!(priv->flags & ABSOLUTE_FLAG))
 
1701
                /* force out-prox when distance is outside wcmCursorProxoutDist for pucks */
 
1702
                if (IsCursor(priv))
1642
1703
                {
1643
 
                        if (strstr(common->wcmModel->name, "Intuos"))
 
1704
                        /* force out-prox when distance is outside wcmCursorProxoutDist. */
 
1705
                        if (common->wcmProtocolLevel == 5)
1644
1706
                        {
1645
1707
                                if (common->wcmMaxCursorDist > filtered.distance)
1646
1708
                                        common->wcmMaxCursorDist = filtered.distance;
1810
1872
{
1811
1873
        WacomDevicePtr priv = (WacomDevicePtr)local->private;
1812
1874
 
1813
 
        if (priv->twinview == TV_NONE)
 
1875
        if (priv->twinview <= TV_XINERAMA)
1814
1876
                return;
1815
1877
 
1816
1878
        priv->numScreen = 2;
1920
1982
                "number of screen=%d \n", local->name, screenInfo.numScreens));
1921
1983
        priv->tvoffsetX = 0;
1922
1984
        priv->tvoffsetY = 0;
1923
 
        if (priv->twinview != TV_NONE)
 
1985
        if (priv->twinview > TV_XINERAMA)
1924
1986
        {
1925
1987
                xf86WcmInitialTVScreens(local);
1926
1988
                return;