summaryrefslogtreecommitdiff
path: root/src/eventcomm.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-11-02 10:42:44 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-11-05 08:51:54 +1000
commit33413529dc35f0afc585d4297f86199393d19684 (patch)
tree765e20e28954c643d7c6d4cbdc675332cf3a643b /src/eventcomm.c
parentd3c1b80692013abb2f2dea6ec7acf1d8a89a18d2 (diff)
eventcomm: don't use the Xisb buffers for reading.
The kernel promises to give us 32 bytes for each event, so we don't have to juggle the Xisb buffers around for the eventcomm devices. This leaves the Xisb buffers hanging around but useless (they are initialized regardless). Task for a later cleanup. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src/eventcomm.c')
-rw-r--r--src/eventcomm.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 8287ca2..d00d810 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -270,19 +270,23 @@ EventQueryHardware(LocalDevicePtr local)
}
static Bool
-SynapticsReadEvent(struct CommData *comm, struct input_event *ev)
+SynapticsReadEvent(LocalDevicePtr local, struct input_event *ev)
{
- int i, c;
- unsigned char *pBuf, u;
-
- for (i = 0; i < sizeof(struct input_event); i++) {
- if ((c = XisbRead(comm->buffer)) < 0)
- return FALSE;
- u = (unsigned char)c;
- pBuf = (unsigned char *)ev;
- pBuf[i] = u;
+ int rc = TRUE;
+ ssize_t len;
+
+ len = read(local->fd, ev, sizeof(*ev));
+ if (len <= 0)
+ {
+ /* We use X_NONE here because it doesn't alloc */
+ if (errno != EAGAIN)
+ xf86MsgVerb(X_NONE, 0, "%s: Read error %s\n", local->name, strerror(errno));
+ rc = FALSE;
+ } else if (len % sizeof(*ev)) {
+ xf86MsgVerb(X_NONE, 0, "%s: Read error, invalid number of bytes.", local->name);
+ rc = FALSE;
}
- return TRUE;
+ return rc;
}
static Bool
@@ -296,7 +300,7 @@ EventReadHwState(LocalDevicePtr local,
SynapticsPrivate *priv = (SynapticsPrivate *)local->private;
SynapticsParameters *para = &priv->synpara;
- while (SynapticsReadEvent(comm, &ev)) {
+ while (SynapticsReadEvent(local, &ev)) {
switch (ev.type) {
case EV_SYN:
switch (ev.code) {