Fix SwapXY and rotation support.

More work to do wrt properties and calibration.
This commit is contained in:
matthieu 2009-12-10 22:32:02 +00:00
parent 206c3e3bc9
commit 012236a1be

View File

@ -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.27 2009/12/06 10:32:31 matthieu Exp $ */
/* $OpenBSD: ws.c,v 1.28 2009/12/10 22:32:02 matthieu Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -418,6 +418,15 @@ wsDeviceInit(DeviceIntPtr pWS)
ymax = -1;
}
if (priv->swap_axes) {
int tmp;
tmp = xmin;
xmin = ymin;
ymin = tmp;
tmp = xmax;
xmax = ymax;
ymax = tmp;
}
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
if ((priv->type == WSMOUSE_TYPE_TPANEL)) {
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
@ -455,6 +464,7 @@ wsDeviceInit(DeviceIntPtr pWS)
#endif
ymin, ymax, 1, 0, 1);
xf86InitValuatorDefaults(pWS, 1);
xf86MotionHistoryAllocate(pInfo);
AssignTypeAndName(pWS, pInfo->atom, pInfo->name);
pWS->public.on = FALSE;
@ -594,11 +604,11 @@ wsReadInput(InputInfoPtr pInfo)
break;
case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
DBG(4, ErrorF("Absolute X %d\n", event->value));
if (event->value != 4095) {
ax = event->value;
if (priv->inv_x)
ax = priv->max_x - ax + priv->min_x;
}
if (event->value == 4095)
break;
ax = event->value;
if (priv->inv_x)
ax = priv->max_x - ax + priv->min_x;
break;
case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
DBG(4, ErrorF("Absolute Y %d\n", event->value));
@ -678,6 +688,13 @@ wsReadInput(InputInfoPtr pInfo)
buttons &= ~zbutton;
wsSendButtons(pInfo, buttons);
}
if (priv->swap_axes) {
int tmp;
tmp = ax;
ax = ay;
ay = tmp;
}
if (ax) {
/* absolute position event */
DBG(3, ErrorF("postMotionEvent X %d\n", ax));
@ -842,10 +859,17 @@ wsSetProperty(DeviceIntPtr device, Atom atom, XIPropertyValuePtr val,
need_update++;
}
/* Update axes descriptors */
ax->min_value = priv->min_x;
ax->max_value = priv->max_x;
ay->min_value = priv->min_y;
ay->max_value = priv->max_y;
if (!priv->swap_axes) {
ax->min_value = priv->min_x;
ax->max_value = priv->max_x;
ay->min_value = priv->min_y;
ay->max_value = priv->max_y;
} else {
ax->min_value = priv->min_y;
ax->max_value = priv->max_y;
ay->min_value = priv->min_x;
ay->max_value = priv->max_x;
}
}
} else if (atom == prop_swap) {
if (val->format != 8 || val->type != XA_INTEGER ||