diff options
author | Alexandr Shadchin <shadchin@cvs.openbsd.org> | 2013-10-30 18:05:35 +0000 |
---|---|---|
committer | Alexandr Shadchin <shadchin@cvs.openbsd.org> | 2013-10-30 18:05:35 +0000 |
commit | aa1540565e912aa8efee015254abb26aef4a3929 (patch) | |
tree | 6bcc3865f2476974f47282e941a539375d8ba953 | |
parent | f96734e0c418164f37081c0de1a84e12c069819c (diff) |
Fix jagged diagonal lines (xenocara part)
Make sure that you have a recent kernel.
ok matthieu@. tested edd@, Henri Kemppainen and Alf Schlichting.
-rw-r--r-- | driver/xf86-input-ws/src/ws.c | 254 | ||||
-rw-r--r-- | driver/xf86-input-ws/src/ws.h | 8 |
2 files changed, 123 insertions, 139 deletions
diff --git a/driver/xf86-input-ws/src/ws.c b/driver/xf86-input-ws/src/ws.c index c264c591f..2694c6e48 100644 --- a/driver/xf86-input-ws/src/ws.c +++ b/driver/xf86-input-ws/src/ws.c @@ -13,7 +13,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: ws.c,v 1.58 2013/07/20 13:24:50 matthieu Exp $ */ +/* $OpenBSD: ws.c,v 1.59 2013/10/30 18:05:34 shadchin Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -428,13 +428,6 @@ wsDeviceOn(DeviceIntPtr pWS) } } } - priv->buffer = XisbNew(pInfo->fd, - sizeof(struct wscons_event) * NUMEVENTS); - if (priv->buffer == NULL) { - xf86IDrvMsg(pInfo, X_ERROR, "cannot alloc xisb buffer\n"); - wsClose(pInfo); - return !Success; - } xf86AddEnabledDevice(pInfo); wsmbEmuOn(pInfo); pWS->public.on = TRUE; @@ -462,170 +455,157 @@ wsDeviceOff(DeviceIntPtr pWS) xf86RemoveEnabledDevice(pInfo); wsClose(pInfo); } - if (priv->buffer) { - XisbFree(priv->buffer); - priv->buffer = NULL; - } pWS->public.on = FALSE; } -static void -wsReadInput(InputInfoPtr pInfo) +static Bool +wsReadEvent(InputInfoPtr pInfo, struct wscons_event *event) { - WSDevicePtr priv = (WSDevicePtr)pInfo->private; - static struct wscons_event eventList[NUMEVENTS]; - int n, c, dx, dy; - struct wscons_event *event = eventList; - unsigned char *pBuf; + Bool rc = TRUE; + ssize_t len; - XisbBlockDuration(priv->buffer, -1); - pBuf = (unsigned char *)eventList; - n = 0; - while (n < sizeof(eventList) && (c = XisbRead(priv->buffer)) >= 0) { - pBuf[n++] = (unsigned char)c; + len = read(pInfo->fd, event, sizeof(struct wscons_event)); + if (len <= 0) { + if (errno != EAGAIN) + xf86IDrvMsg(pInfo, X_ERROR, "read error %s\n", + strerror(errno)); + rc = FALSE; + } else if (len != sizeof(struct wscons_event)) { + xf86IDrvMsg(pInfo, X_ERROR, + "read error, invalid number of bytes\n"); + rc = FALSE; } - if (n == 0) - return; + return rc; +} - dx = dy = 0; - n /= sizeof(struct wscons_event); - while (n--) { - int buttons = priv->lastButtons; - int newdx = 0, newdy = 0, dz = 0, dw = 0, ax = 0, ay = 0; - int zbutton = 0, wbutton = 0; +static Bool +wsReadHwState(InputInfoPtr pInfo, wsHwState *hw) +{ + WSDevicePtr priv = (WSDevicePtr)pInfo->private; + struct wscons_event event; + + bzero(hw, sizeof(wsHwState)); + + hw->buttons = priv->lastButtons; + hw->ax = priv->old_ax; + hw->ay = priv->old_ay; - switch (event->type) { + while (wsReadEvent(pInfo, &event)) { + switch (event.type) { case WSCONS_EVENT_MOUSE_UP: - buttons &= ~(1 << event->value); - DBG(4, ErrorF("Button %d up %x\n", event->value, - buttons)); + hw->buttons &= ~(1 << event.value); + DBG(4, ErrorF("Button %d up %x\n", event.value, + hw->buttons)); break; case WSCONS_EVENT_MOUSE_DOWN: - buttons |= (1 << event->value); - DBG(4, ErrorF("Button %d down %x\n", event->value, - buttons)); + hw->buttons |= (1 << event.value); + DBG(4, ErrorF("Button %d down %x\n", event.value, + hw->buttons)); break; case WSCONS_EVENT_MOUSE_DELTA_X: - if (!dx) - dx = event->value; - else - newdx = event->value; - DBG(4, ErrorF("Relative X %d\n", event->value)); + hw->dx = event.value; + DBG(4, ErrorF("Relative X %d\n", event.value)); break; case WSCONS_EVENT_MOUSE_DELTA_Y: - if (!dy) - dy = -event->value; - else - newdy = -event->value; - DBG(4, ErrorF("Relative Y %d\n", event->value)); + hw->dy = -event.value; + DBG(4, ErrorF("Relative Y %d\n", event.value)); + break; + case WSCONS_EVENT_MOUSE_DELTA_Z: + hw->dz = event.value; + DBG(4, ErrorF("Relative Z %d\n", event.value)); + break; + case WSCONS_EVENT_MOUSE_DELTA_W: + hw->dw = event.value; + DBG(4, ErrorF("Relative W %d\n", event.value)); break; case WSCONS_EVENT_MOUSE_ABSOLUTE_X: - DBG(4, ErrorF("Absolute X %d\n", event->value)); - if (event->value == 4095) - break; - ax = event->value; + hw->ax = event.value; if (priv->inv_x) - ax = priv->max_x - ax + priv->min_x; + hw->ax = priv->max_x - hw->ax + priv->min_x; + DBG(4, ErrorF("Absolute X %d\n", event.value)); break; case WSCONS_EVENT_MOUSE_ABSOLUTE_Y: - DBG(4, ErrorF("Absolute Y %d\n", event->value)); - ay = event->value; + hw->ay = event.value; if (priv->inv_y) - ay = priv->max_y - ay + priv->min_y; - break; - case WSCONS_EVENT_MOUSE_DELTA_Z: - DBG(4, ErrorF("Relative Z %d\n", event->value)); - dz = event->value; + hw->ay = priv->max_y - hw->ay + priv->min_y; + DBG(4, ErrorF("Absolute Y %d\n", event.value)); break; case WSCONS_EVENT_MOUSE_ABSOLUTE_Z: + case WSCONS_EVENT_MOUSE_ABSOLUTE_W: /* ignore those */ - ++event; continue; - break; - case WSCONS_EVENT_MOUSE_DELTA_W: - DBG(4, ErrorF("Relative W %d\n", event->value)); - dw = event->value; - break; + case WSCONS_EVENT_SYNC: + DBG(4, ErrorF("Sync\n")); + return TRUE; default: xf86IDrvMsg(pInfo, X_WARNING, - "bad wsmouse event type=%d\n", event->type); - ++event; + "bad wsmouse event type=%d\n", event.type); continue; } - ++event; - - if ((newdx || newdy) || ((dx || dy) && - event->type != WSCONS_EVENT_MOUSE_DELTA_X && - event->type != WSCONS_EVENT_MOUSE_DELTA_Y)) { - int tmpx = dx, tmpy = dy; - dx = newdx; - dy = newdy; - - if (wsWheelEmuFilterMotion(pInfo, tmpx, tmpy)) - continue; - - /* relative motion event */ - DBG(3, ErrorF("postMotionEvent dX %d dY %d\n", - tmpx, tmpy)); - xf86PostMotionEvent(pInfo->dev, 0, 0, 2, tmpx, tmpy); - } - if (dz && priv->Z.negative != WS_NOMAP - && priv->Z.positive != WS_NOMAP) { - zbutton = (dz < 0) ? priv->Z.negative : - priv->Z.positive; - DBG(4, ErrorF("Z -> button %d\n", zbutton)); - wsButtonClicks(pInfo, zbutton, abs(dz)); - } - if (dw && priv->W.negative != WS_NOMAP - && priv->W.positive != WS_NOMAP) { - wbutton = (dw < 0) ? priv->W.negative : - priv->W.positive; - DBG(4, ErrorF("W -> button %d\n", wbutton)); - wsButtonClicks(pInfo, wbutton, abs(dw)); - } - if (priv->lastButtons != buttons) { - /* button event */ - wsSendButtons(pInfo, buttons); - } - if (priv->swap_axes) { - int tmp; +#ifdef __NetBSD__ + /* + * XXX NetBSD reads only one event. + * WSCONS_EVENT_SYNC is not supported yet. + */ + return TRUE; +#endif + } - tmp = ax; - ax = ay; - ay = tmp; - } - if (ax) { - int xdelta = ax - priv->old_ax; - priv->old_ax = ax; - if (wsWheelEmuFilterMotion(pInfo, xdelta, 0)) - continue; - - /* absolute position event */ - DBG(3, ErrorF("postMotionEvent X %d\n", ax)); - xf86PostMotionEvent(pInfo->dev, 1, 0, 1, ax); - } - if (ay) { - int ydelta = ay - priv->old_ay; - priv->old_ay = ay; - if (wsWheelEmuFilterMotion(pInfo, 0, ydelta)) - continue; - - /* absolute position event */ - DBG(3, ErrorF("postMotionEvent y %d\n", ay)); - xf86PostMotionEvent(pInfo->dev, 1, 1, 1, ay); - } + return FALSE; +} + +static void +wsReadInput(InputInfoPtr pInfo) +{ + WSDevicePtr priv = (WSDevicePtr)pInfo->private; + wsHwState hw; + + if (!wsReadHwState(pInfo, &hw)) + return; + + if ((hw.dx || hw.dy) && !wsWheelEmuFilterMotion(pInfo, hw.dx, hw.dy)) { + /* relative motion event */ + DBG(3, ErrorF("postMotionEvent dX %d dY %d\n", hw.dx, hw.dy)); + xf86PostMotionEvent(pInfo->dev, 0, 0, 2, hw.dx, hw.dy); + } + if (hw.dz && priv->Z.negative != WS_NOMAP + && priv->Z.positive != WS_NOMAP) { + int zbutton; + zbutton = (hw.dz < 0) ? priv->Z.negative : priv->Z.positive; + DBG(4, ErrorF("Z -> button %d (%d)\n", zbutton, abs(hw.dz))); + wsButtonClicks(pInfo, zbutton, abs(hw.dz)); + } + if (hw.dw && priv->W.negative != WS_NOMAP + && priv->W.positive != WS_NOMAP) { + int wbutton; + wbutton = (hw.dw < 0) ? priv->W.negative : priv->W.positive; + DBG(4, ErrorF("W -> button %d (%d)\n", wbutton, abs(hw.dw))); + wsButtonClicks(pInfo, wbutton, abs(hw.dw)); + } + if (priv->lastButtons != hw.buttons) { + /* button event */ + wsSendButtons(pInfo, hw.buttons); } - if (dx || dy) { - if (wsWheelEmuFilterMotion(pInfo, dx, dy)) + if (priv->swap_axes) { + int tmp; + + tmp = hw.ax; + hw.ax = hw.ay; + hw.ay = tmp; + } + if ((hw.ax != priv->old_ax) || (hw.ay != priv->old_ay)) { + int xdelta = hw.ax - priv->old_ax; + int ydelta = hw.ay - priv->old_ay; + priv->old_ax = hw.ax; + priv->old_ay = hw.ay; + if (wsWheelEmuFilterMotion(pInfo, xdelta, ydelta)) return; - /* relative motion event */ - DBG(3, ErrorF("postMotionEvent dX %d dY %d\n", - dx, dy)); - xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy); + /* absolute position event */ + DBG(3, ErrorF("postMotionEvent X %d Y %d\n", hw.ax, hw.ay)); + xf86PostMotionEvent(pInfo->dev, 1, 0, 2, hw.ax, hw.ay); } - return; } static void diff --git a/driver/xf86-input-ws/src/ws.h b/driver/xf86-input-ws/src/ws.h index 0e0abc07e..09277fdf7 100644 --- a/driver/xf86-input-ws/src/ws.h +++ b/driver/xf86-input-ws/src/ws.h @@ -29,7 +29,6 @@ extern int ws_debug_level; #define NAXES 2 /* X and Y axes only */ #define NBUTTONS 32 /* max theoretical buttons */ #define DFLTBUTTONS 3 /* default number of buttons */ -#define NUMEVENTS 16 /* max # of ws events to read at once */ #define WS_NOMAP 0 @@ -40,6 +39,12 @@ typedef struct { int traveled_distance; } WheelAxis, *WheelAxisPtr; +typedef struct { + unsigned int buttons; + int dx, dy, dz, dw; + int ax, ay; +} wsHwState; + typedef struct WSDevice { char *devName; /* device name */ int type; /* ws device type */ @@ -50,7 +55,6 @@ typedef struct WSDevice { int raw; int inv_x, inv_y; int screen_no; - pointer buffer; WheelAxis Z; WheelAxis W; struct wsmouse_calibcoords coords; /* mirror of the kernel values */ |