diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2010-07-16 09:21:19 -0400 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-10-22 13:37:57 +1000 |
commit | 65c0fc81eb920085e650b8c9e874c9dd26c7ec98 (patch) | |
tree | ac513fa8127b4dc8d4e8003d3cd4f1be21fe060e /dix/eventconvert.c | |
parent | 9696c782c8cb86b06d12949899582533a2e04cfe (diff) |
Add support for per-axis valuator modes (Relative/Absolute)
The XI2 protocol supports per-axis modes, but the server so far does
not. This change adds support in the server.
A complication is the fact that XI1 does not support per-axis modes.
The solution provided here is to set a per-device mode that defines the
mode of at least the first two valuators (X and Y). Note that initializing
the first two axes to a different mode than the device mode will fail.
For XI1 events, any axes following the first two that have the same mode
will be sent to clients, up to the first axis that has a different mode.
Thus, if a device has relative, then absolute, then relative mode axes,
only the first block of relative axes will be sent over XI1.
Since the XI2 protocol supports per-axis modes, all axes are sent to the
client.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'dix/eventconvert.c')
-rw-r--r-- | dix/eventconvert.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 0f747c1a0..46eb4ffd8 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -261,6 +261,12 @@ eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count) } num_events = (countValuators(ev, &first) + 5)/6; /* valuator ev */ + if (num_events <= 0) + { + *count = 0; + return BadMatch; + } + num_events++; /* the actual event event */ *xi = calloc(num_events, sizeof(xEvent)); @@ -318,6 +324,12 @@ countValuators(DeviceEvent *ev, int *first) for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++) { + /* Assume mode of 0th valuator matches XI1 device mode. Stop when the + * event mode changes since XI1 can't handle mixed mode devices. + */ + if (ev->valuators.mode[i] != ev->valuators.mode[0]) + break; + if (BitIsOn(ev->valuators.mask, i)) { if (first_valuator == -1) @@ -440,7 +452,7 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe info->value.frac = 0; info->resolution = dce->valuators[axisnumber].resolution; info->number = axisnumber; - info->mode = dce->valuators[axisnumber].mode; /* Server doesn't have per-axis mode yet */ + info->mode = dce->valuators[axisnumber].mode; info->sourceid = dce->sourceid; return info->length * 4; |