Add support for mapping 'W' axis to buttons.
This commit is contained in:
parent
dae27eca2b
commit
7b632d8eb7
@ -1,4 +1,4 @@
|
||||
.\" $OpenBSD: ws.man,v 1.1.1.1 2006/11/26 22:27:26 matthieu Exp $
|
||||
.\" $OpenBSD: ws.man,v 1.2 2007/05/26 17:24:45 matthieu Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2005 Matthieu Herrb
|
||||
.\"
|
||||
@ -34,6 +34,7 @@ WS \- wscons pointer input driver for *BSD
|
||||
.BI " Option \*qRotate\*q \*q" string \*q
|
||||
.BI " Option \*qSwapXY\*q \*q" boolean \*q
|
||||
.BI " Option \*qZAxisMapping\*q \*q" "N1 N2" \*q
|
||||
.BI " Option \*qWAxisMapping\*q \*q" "N1 N2" \*q
|
||||
.B EndSection
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
@ -93,5 +94,13 @@ is mapped to the negative Z axis motion and button
|
||||
.I N2
|
||||
is mapped to the positive Z axis motion.
|
||||
Default: no mapping.
|
||||
.B Option \fI"WAxisMapping"\fP \fI"N1 N2"\fP
|
||||
Set the mapping for the W axis (horizontal wheel) motion to buttons. Button
|
||||
number
|
||||
.I N1
|
||||
is mapped to the negative W axis motion and button
|
||||
.I N2
|
||||
is mapped to the positive W axis motion.
|
||||
Default: no mapping.
|
||||
.SH "SEE ALSO"
|
||||
Xorg(1), xorg.conf(__filemansuffix__), zts(4), sysctl(8), ztsscale(8).
|
||||
|
@ -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.1.1.1 2006/11/26 22:27:26 matthieu Exp $ */
|
||||
/* $OpenBSD: ws.c,v 1.2 2007/05/26 17:24:45 matthieu Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@ -56,6 +56,7 @@ typedef struct WSDevice {
|
||||
int num, den, threshold; /* relative accel params */
|
||||
pointer buffer;
|
||||
int negativeZ, positiveZ; /* mappings for Z axis */
|
||||
int negativeW, positiveW; /* mappings for W axis */
|
||||
} WSDeviceRec, *WSDevicePtr;
|
||||
|
||||
#ifdef XFree86LOADER
|
||||
@ -245,6 +246,33 @@ wsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||
priv->buttons = priv->positiveZ;
|
||||
buttons_from = X_CONFIG;
|
||||
}
|
||||
priv->negativeW = priv->positiveW = WS_NOZMAP;
|
||||
s = xf86SetStrOption(pInfo->options, "WAxisMapping", NULL);
|
||||
if (s) {
|
||||
int b1, b2;
|
||||
|
||||
if (sscanf(s, "%d %d", &b1, &b2) == 2 &&
|
||||
b1 > 0 && b1 <= NBUTTONS &&
|
||||
b2 > 0 && b2 <= NBUTTONS) {
|
||||
priv->negativeW = b1;
|
||||
priv->positiveW = b2;
|
||||
xf86Msg(X_CONFIG,
|
||||
"%s: WAxisMapping: buttons %d and %d\n",
|
||||
pInfo->name, b1, b2);
|
||||
} else {
|
||||
xf86Msg(X_WARNING, "%s: invalid WAxisMapping value: "
|
||||
"\"%s\"\n", pInfo->name, s);
|
||||
}
|
||||
}
|
||||
if (priv->negativeW > priv->buttons) {
|
||||
priv->buttons = priv->negativeW;
|
||||
buttons_from = X_CONFIG;
|
||||
}
|
||||
if (priv->positiveW > priv->buttons) {
|
||||
priv->buttons = priv->positiveW;
|
||||
buttons_from = X_CONFIG;
|
||||
}
|
||||
|
||||
priv->screen_no = xf86SetIntOption(pInfo->options, "ScreenNo", 0);
|
||||
xf86Msg(X_CONFIG, "%s associated screen: %d\n",
|
||||
dev->identifier, priv->screen_no);
|
||||
@ -430,8 +458,8 @@ wsReadInput(InputInfoPtr pInfo)
|
||||
n /= sizeof(struct wscons_event);
|
||||
while( n-- ) {
|
||||
int buttons = priv->lastButtons;
|
||||
int dx = 0, dy = 0, dz = 0;
|
||||
int zbutton = 0;
|
||||
int dx = 0, dy = 0, dz, dw = 0;
|
||||
int zbutton = 0, wbutton = 0;
|
||||
|
||||
ax = 0; ay = 0;
|
||||
switch (event->type) {
|
||||
@ -480,6 +508,12 @@ wsReadInput(InputInfoPtr pInfo)
|
||||
++event;
|
||||
continue;
|
||||
break;
|
||||
#endif
|
||||
#ifdef WSCONS_EVENT_MOUSE_DELTA_W
|
||||
case WSCONS_EVENT_MOUSE_DELTA_W:
|
||||
DBG(4, ErrorF("Relative W %d\n", event->value));
|
||||
dw = event->value;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n",
|
||||
@ -521,6 +555,21 @@ wsReadInput(InputInfoPtr pInfo)
|
||||
buttons |= zbutton;
|
||||
dz = 0;
|
||||
}
|
||||
if (dw && priv->negativeW != WS_NOZMAP
|
||||
&& priv->positiveW != WS_NOZMAP) {
|
||||
buttons &= ~(priv->negativeW | priv->positiveW);
|
||||
if (dw < 0) {
|
||||
DBG(4, ErrorF("W -> button %d\n",
|
||||
priv->negativeW));
|
||||
wbutton = 1 << (priv->negativeW - 1);
|
||||
} else {
|
||||
DBG(4, ErrorF("W -> button %d\n",
|
||||
priv->positiveW));
|
||||
wbutton = 1 << (priv->positiveW - 1);
|
||||
}
|
||||
buttons |= wbutton;
|
||||
dw = 0;
|
||||
}
|
||||
if (priv->lastButtons != buttons) {
|
||||
/* button event */
|
||||
wsSendButtons(pInfo, buttons);
|
||||
|
Loading…
Reference in New Issue
Block a user