Ticket #4847: wacom.diff

File wacom.diff, 2.6 KB (added by Pete, 15 years ago)

Patch to make Intuos work properly

  • haiku/src/add-ons/input_server/devices/

    old new  
    292292            break;
    293293        }
    294294        case DEVICE_INTUOS:
     295            // Modifications to correct (original) Intuos functioning in the following section.
     296            // The critical point is that data[6] is used to signal use of the eraser,
     297            // as well as being the high bits of pressure.  The indication is only valid
     298            // when the pen is *not* in contact with the tablet, so it must be retained
     299            // from the pre-touch state while the pen is in contact.
     300            // (Always) while not in contact:
     301            //  If the pen end is lowermost data[6] = 1;
     302            //  If the eraser end is down data[6] = 0, and pressure is strictly 0
     303            // data[9] (top 5 bits: 0x70..0xd0) indicates height above the tablet;
     304            // this is used to prevent pressure jitter giving false eraser state.
    295305        case DEVICE_INTUOS3:
    296306        case DEVICE_CINTIQ:
    297307            if ((data[0] == 0x02) && !(((data[1] >> 5) & 0x03) == 0x02)) {
     
    319329                    pressure = 0.0;
    320330                    eraser = 0;
    321331                } else {
    322 //                  eraser = (data[1] & 0x20); // eraser is een tool-id
     332//                  eraser = (data[1] & 0x20); // eraser is in tool-id -- actually not!
    323333//                  firstButton = (pressureData > 0) && data[9] <= 0x68;// > 180);
    324334//                  firstButton = (pressureData > 180);
    325                     firstButton = (data[6] > 0);
     335//                  firstButton = (data[6] > 2);
     336                    // This should be OK for all tablets(?):
     337                    // For Intuos it MUST be >1, but '>1' still gets false actuations (shaking)
     338                    firstButton = (data[6] > 2);
    326339                    secondButton = (data[1] & 0x02);
    327340                    thirdButton = (data[1] & 0x04);
    328                     hasContact = (data[1] & 0x40);
    329                     // convert tilt (-128 ... 127)
    330 //                  int8 tiltDataX = ((data[7] & 0x3f) << 2) | ((data[8] & 0x80) >> 6);
     341                    hasContact = (data[1] & 0x40);  // is this meaningful? (always true on Intuos)
     342                    if (fDeviceMode == DEVICE_INTUOS) { // test perhaps superfluous?
     343                        eraser = fEraser;   // keep established value unless not touching pad
     344                        // Eraser state only valid when away from surface
     345                        if (data[6] <= 1 && data[9] > 0x80) {   // not touching tablet
     346                            if (!pressureData) eraser = 1;  // strictly 0 means eraser
     347                            else if (pressureData > 6) eraser = 0;  // avoid slop
     348                        }
     349                    }
     350                    // Get raw tilt values (0..54..127):
    331351                    int8 tiltDataX = ((data[7] & 0x3f) << 1) | ((data[8] & 0x80) >> 7);
    332352                    int8 tiltDataY = data[8] & 0x7f;
    333 //                  int8 tiltDataY = 0;
    334353                    // convert to floats
    335354                    tiltX = (float)(tiltDataX - 64) / 64.0;
    336355                    tiltY = (float)(tiltDataY - 64) / 64.0;