diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-05-23 12:55:50 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-05-23 12:55:50 +0930 |
commit | 75551a2ef949c2cfb53fdc4b97f3964a5e2f45f5 (patch) | |
tree | 036fc3545712072285b42b5caf173e9bfd93484b /Xi | |
parent | fe59b1a62b2c7f467d20132db4913317bbf308eb (diff) |
Revert "dix: Correct values in the device axisVal are calculated in GPE"
We can't rely on GPE to update device->valuators->axisVal. If a SIGIO occurs
during event processing this may have incoherent results.
This reverts commit f6645ddbf754c80e9a8b1672519534a887622270.
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 103 |
1 files changed, 101 insertions, 2 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index da6cf8dee..42b77c137 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -818,8 +818,107 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count) bit = 1 << (key & 7); } - /* Device axis are calculated in GetPointerEvents and need - * no more processing */ + /* Update device axis */ + for (i = 1; i < count; i++) { + if ((++xV)->type == DeviceValuator) { + int *axisvals; + int first = xV->first_valuator; + BOOL change = FALSE; + + if (xV->num_valuators && + (!v || (xV->num_valuators && + (first + xV->num_valuators > v->numAxes)))) + FatalError("Bad valuators reported for device %s\n", + device->name); + if (v && v->axisVal) { + /* The device always stores values in absolute. Only the + * delivery mode changes. + * If device is mode Absolute, and event is Relative + * dev += event + * event = dev + * If device is mode Absolute, and event is Absolute + * dev = event + * If device is mode Relative, and event is Absolute + * swap = (event - device) + * dev = event + * event = delta + * If device is mode Relative, and event is Relative + * dev += event + * + * XXX: axis clipping for relative events? + */ + axisvals = v->axisVal; + if (xV->sequenceNumber & Absolute) { + int delta; + if (v->mode == Relative) /* device reports relative */ + { + change = TRUE; + xV->sequenceNumber &= ~Absolute; + } + + switch (xV->num_valuators) { + case 6: + if (change) delta = xV->valuator5 - *(axisvals + first + 5); + *(axisvals + first + 5) = xV->valuator5; + if (change) xV->valuator5 = delta; + case 5: + if (change) delta = xV->valuator4 - *(axisvals + first + 4); + *(axisvals + first + 4) = xV->valuator4; + if (change) xV->valuator4 = delta; + case 4: + if (change) delta = xV->valuator3 - *(axisvals + first + 3); + *(axisvals + first + 3) = xV->valuator3; + if (change) xV->valuator3 = delta; + case 3: + if (change) delta = xV->valuator2 - *(axisvals + first + 2); + *(axisvals + first + 2) = xV->valuator2; + if (change) xV->valuator2 = delta; + case 2: + if (change) delta = xV->valuator1 - *(axisvals + first + 1); + *(axisvals + first + 1) = xV->valuator1; + if (change) xV->valuator1 = delta; + case 1: + if (change) delta = xV->valuator0 - *(axisvals + first); + *(axisvals + first) = xV->valuator0; + if (change) xV->valuator0 = delta; + case 0: + default: + break; + } + } else { /* event is relative */ + if (v->mode == Absolute) /* device reports absolute */ + { + change = TRUE; + xV->sequenceNumber |= Absolute; + } + + switch (xV->num_valuators) { + case 6: + *(axisvals + first + 5) += xV->valuator5; + if (change) xV->valuator5 = *(axisvals + first + 5); + case 5: + *(axisvals + first + 4) += xV->valuator4; + if (change) xV->valuator4 = *(axisvals + first + 4); + case 4: + *(axisvals + first + 3) += xV->valuator3; + if (change) xV->valuator3 = *(axisvals + first + 3); + case 3: + *(axisvals + first + 2) += xV->valuator2; + if (change) xV->valuator2 = *(axisvals + first + 2); + case 2: + *(axisvals + first + 1) += xV->valuator1; + if (change) xV->valuator1 = *(axisvals + first + 1); + case 1: + *(axisvals + first) += xV->valuator0; + if (change) xV->valuator0 = *(axisvals + first); + case 0: + default: + break; + } + } + } + } + } if (xE->u.u.type == DeviceKeyPress) { if (!k) |