summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@openbsd.org>2009-11-23 18:29:13 +0000
committerMatthieu Herrb <matthieu@openbsd.org>2009-11-23 18:29:13 +0000
commitb0badf20a452a16bfb2cb4bbda325e7143785f4d (patch)
tree83b7a2105ad6491e62a69a92292145b60d1888f2
parent633d4ab9c0fb6cddf62ba9e83ec4c4e1328b0da5 (diff)
Implement a new "raw" mode that will put a panel in raw mode.
Calibration data is read from the kernel, so things still work in this mode.
-rw-r--r--src/ws.c88
1 files changed, 73 insertions, 15 deletions
diff --git a/src/ws.c b/src/ws.c
index 1fbbef1..c515f9b 100644
--- a/src/ws.c
+++ b/src/ws.c
@@ -54,6 +54,7 @@ typedef struct WSDevice {
int x, y; /* current abs coordinates */
int min_x, max_x, min_y, max_y; /* coord space */
int swap_axes;
+ int raw;
int inv_x, inv_y;
int screen_width, screen_height;
int screen_no;
@@ -144,6 +145,7 @@ TearDownProc(pointer p)
static InputInfoPtr
wsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
{
+ struct wsmouse_calibcoords coords;
InputInfoPtr pInfo = NULL;
WSDevicePtr priv;
MessageType buttons_from = X_CONFIG;
@@ -240,20 +242,6 @@ wsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
priv->screen_no = 0;
}
- priv->max_x = xf86SetIntOption(pInfo->options, "MaxX",
- screenInfo.screens[priv->screen_no]->width - 1);
- xf86Msg(X_INFO, "%s maximum x position: %d\n",
- dev->identifier, priv->max_x);
- priv->min_x = xf86SetIntOption(pInfo->options, "MinX", 0);
- xf86Msg(X_INFO, "%s minimum x position: %d\n",
- dev->identifier, priv->min_x);
- priv->max_y = xf86SetIntOption(pInfo->options, "MaxY",
- screenInfo.screens[priv->screen_no]->height - 1);
- xf86Msg(X_INFO, "%s maximum y position: %d\n",
- dev->identifier, priv->max_y);
- priv->min_y = xf86SetIntOption(pInfo->options, "MinY", 0);
- xf86Msg(X_INFO, "%s minimum y position: %d\n",
- dev->identifier, priv->min_y);
priv->swap_axes = xf86SetBoolOption(pInfo->options, "SwapXY", 0);
if (priv->swap_axes) {
@@ -283,6 +271,12 @@ wsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
" or \"UD\"\n");
}
}
+ priv->raw = xf86SetBoolOption(pInfo->options, "Raw", 0);
+ if (priv->raw) {
+ xf86Msg(X_CONFIG,
+ "%s device will work in raw mode\n",
+ dev->identifier);
+ }
if (wsOpen(pInfo) != Success) {
goto fail;
}
@@ -294,7 +288,40 @@ wsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pInfo->type_name = XI_TOUCHSCREEN;
else
pInfo->type_name = XI_MOUSE;
- wsClose(pInfo);
+
+ if (priv->raw) {
+ if (ioctl(pInfo->fd, WSMOUSEIO_GCALIBCOORDS, &coords) != 0) {
+ xf86Msg(X_ERROR, "GCALIBCOORS failed %s\n",
+ strerror(errno));
+ wsClose(pInfo);
+ goto fail;
+ }
+
+ /* get default coordinate space from kernel */
+ priv->min_x = coords.minx;
+ priv->max_x = coords.maxx;
+ priv->min_y = coords.miny;
+ priv->max_y = coords.maxy;
+ } else {
+ /* in calibrated mode, coordinate space, is screen coords */
+ priv->min_x = 0;
+ priv->max_x = screenInfo.screens[priv->screen_no]->width - 1;
+ priv->min_y = 0;
+ priv->max_y = screenInfo.screens[priv->screen_no]->height - 1;
+ }
+ /* Allow options to override this */
+ priv->min_x = xf86SetIntOption(pInfo->options, "MinX", priv->min_x);
+ xf86Msg(X_INFO, "%s minimum x position: %d\n",
+ dev->identifier, priv->min_x);
+ priv->max_x = xf86SetIntOption(pInfo->options, "MaxX", priv->max_x);
+ xf86Msg(X_INFO, "%s maximum x position: %d\n",
+ dev->identifier, priv->max_x);
+ priv->min_y = xf86SetIntOption(pInfo->options, "MinY", priv->min_y);
+ xf86Msg(X_INFO, "%s minimum y position: %d\n",
+ dev->identifier, priv->min_y);
+ priv->max_y = xf86SetIntOption(pInfo->options, "MaxY", priv->max_y);
+ xf86Msg(X_INFO, "%s maximum y position: %d\n",
+ dev->identifier, priv->max_y);
pInfo->name = dev->identifier;
pInfo->device_control = wsProc;
@@ -308,6 +335,8 @@ wsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pInfo->old_y = -1;
xf86Msg(buttons_from, "%s: Buttons: %d\n", pInfo->name, priv->buttons);
+ wsClose(pInfo);
+
/* mark the device configured */
pInfo->flags |= XI86_CONFIGURED;
return pInfo;
@@ -445,6 +474,8 @@ wsDeviceOn(DeviceIntPtr pWS)
{
InputInfoPtr pInfo = (InputInfoPtr)pWS->public.devicePrivate;
WSDevicePtr priv = (WSDevicePtr)XI_PRIVATE(pWS);
+ struct wsmouse_calibcoords coords;
+ int raw;
DBG(1, ErrorF("WS DEVICE ON\n"));
if ((pInfo->fd < 0) && (wsOpen(pInfo) != Success)) {
@@ -452,6 +483,19 @@ wsDeviceOn(DeviceIntPtr pWS)
strerror(errno));
return !Success;
}
+ raw = priv->raw;
+ if (ioctl(pInfo->fd, WSMOUSEIO_GCALIBCOORDS, &coords) != 0) {
+ xf86Msg(X_ERROR, "GCALIBCOORS failed %s\n",
+ strerror(errno));
+ return !Success;
+ }
+ priv->raw = coords.samplelen;
+ coords.samplelen = raw;
+ if (ioctl(pInfo->fd, WSMOUSEIO_SCALIBCOORDS, &coords) != 0) {
+ xf86Msg(X_ERROR, "GCALIBCOORS failed %s\n",
+ strerror(errno));
+ return !Success;
+ }
priv->buffer = XisbNew(pInfo->fd,
sizeof(struct wscons_event) * NUMEVENTS);
if (priv->buffer == NULL) {
@@ -469,8 +513,22 @@ wsDeviceOff(DeviceIntPtr pWS)
{
InputInfoPtr pInfo = (InputInfoPtr)pWS->public.devicePrivate;
WSDevicePtr priv = (WSDevicePtr)XI_PRIVATE(pWS);
+ struct wsmouse_calibcoords coords;
+ int raw;
DBG(1, ErrorF("WS DEVICE OFF\n"));
+ raw = priv->raw;
+ if (ioctl(pInfo->fd, WSMOUSEIO_GCALIBCOORDS, &coords) != 0) {
+ xf86Msg(X_ERROR, "GCALIBCOORS failed %s\n",
+ strerror(errno));
+ }
+ priv->raw = coords.samplelen;
+ coords.samplelen = raw;
+ if (ioctl(pInfo->fd, WSMOUSEIO_SCALIBCOORDS, &coords) != 0) {
+ xf86Msg(X_ERROR, "GCALIBCOORS failed %s\n",
+ strerror(errno));
+ }
+
if (pInfo->fd >= 0) {
xf86RemoveEnabledDevice(pInfo);
wsClose(pInfo);