| 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. |
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): |