On Thu May 20 2010 11:04:01 Marc Balmer wrote:
> Am 20.05.10 18:58, schrieb Sverre Froyen:
> > On Thu May 20 2010 10:49:06 Marc Balmer wrote:
> >> So I suggest that you leave out the changes for absolute positioning
> >> devices, I have some, and I can not imagine how this would be of any
> >> good in this case.  For relative devices, I think the approach can make
> >> sense.
> >> 
> >> Can you provide a complete diff?  Make sure the default settings are the
> >> same as we have now, i.e. don't break existing setups.
> > 
> > It is a complete diff except for the ioctls. I was hoping for some input
> > on that aspect.
> 
> Well, I more or less suggested you provide a *new* complete diff, with
> the absolute parts removed.

OK. New diff attached. 

> As for the ioctls, I suggest you make a proposal.  Looks to me like you
> only have to pass an X, Y, and Z factor to the driver.

Possible ioctls in new diff. I suggest we delete the old and never(?) 
implemented WSMOUSEIO_SSCALE.

> Also you might want to check if the scaling functionality is present in
> X.Org already?

It appears that xorg provides acceleration support only (xinput set-ptr-
feedback). As you suggested, changing xorg.conf allows configuring the two 
mouse inputs separately, so adding scaling support to xorg would solve my 
problem.

Finally, it looks like moused(8) provides linear scaling support. I have not 
yet tested it, however.

Thanks,
Sverre
? sys/dev/wscons/wsmouse.c.save
Index: sys/dev/wscons/wsconsio.h
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsconsio.h,v
retrieving revision 1.92
diff -u -p -r1.92 wsconsio.h
--- sys/dev/wscons/wsconsio.h	31 Dec 2009 05:08:05 -0000	1.92
+++ sys/dev/wscons/wsconsio.h	20 May 2010 23:28:28 -0000
@@ -217,9 +217,6 @@ struct wskbd_scroll_data {
 #define	WSMOUSE_RES_DEFAULT	75
 #define	WSMOUSE_RES_MAX		100
 
-/* Set scale factor (num / den).  Not applicable to all mouse types. */
-#define	WSMOUSEIO_SSCALE	_IOW('W', 34, u_int[2])
-
 /* Set sample rate.  Not applicable to all mouse types. */
 #define	WSMOUSEIO_SRATE		_IOW('W', 35, u_int)
 #define	WSMOUSE_RATE_MIN	0
@@ -265,6 +262,11 @@ struct wsmouse_repeat {
 #define WSMOUSEIO_SETVERSION	_IOW('W', 41, int)
 #define WSMOUSE_EVENT_VERSION	WSEVENT_VERSION
 
+/* Set scale factor in percent. */
+#define	WSMOUSEIO_SETSCALEXY	_IOW('W', 42, int)
+#define	WSMOUSEIO_SETSCALEZ	_IOW('W', 43, int)
+#define	WSMOUSEIO_SETSCALEW	_IOW('W', 44, int)
+
 /*
  * Display ioctls (64 - 95)
  */
Index: sys/dev/wscons/wsmouse.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wsmouse.c,v
retrieving revision 1.62
diff -u -p -r1.62 wsmouse.c
--- sys/dev/wscons/wsmouse.c	15 Jan 2009 04:22:11 -0000	1.62
+++ sys/dev/wscons/wsmouse.c	20 May 2010 23:28:29 -0000
@@ -144,6 +144,8 @@ extern int wsmuxdebug;
 #define INVALID_Y	INT_MAX
 #define INVALID_Z	INT_MAX
 
+#define WSCONS_MOUSE_RES	100
+
 struct wsmouse_softc {
 	struct wsevsrc	sc_base;
 
@@ -161,6 +163,11 @@ struct wsmouse_softc {
 	int		sc_z;		/* absolute-z */
 	int		sc_w;		/* absolute-w */
 
+	int		sc_mx;
+	int		sc_my;
+	int		sc_mz;
+	int		sc_mw;
+
 	int		sc_refcnt;
 	u_char		sc_dying;	/* device is being detached */
 
@@ -251,6 +258,12 @@ wsmouse_attach(device_t parent, device_t
 	callout_init(&sc->sc_repeat_callout, 0);
 	callout_setfunc(&sc->sc_repeat_callout, wsmouse_repeat, sc);
 
+	/* One-to-one scale multipliers. */
+	sc->sc_mx = WSCONS_MOUSE_RES;
+	sc->sc_my = WSCONS_MOUSE_RES;
+	sc->sc_mz = WSCONS_MOUSE_RES;
+	sc->sc_mw = WSCONS_MOUSE_RES;
+
 #if NWSMUX > 0
 	sc->sc_base.me_ops = &wsmouse_srcops;
 	mux = device_cfdata(self)->wsmousedevcf_mux;
@@ -370,13 +383,13 @@ wsmouse_input(device_t wsmousedev, u_int
 
 	sc->sc_mb = btns;
 	if (!(flags & WSMOUSE_INPUT_ABSOLUTE_X))
-		sc->sc_dx += x;
+		sc->sc_dx += x * sc->sc_mx;
 	if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Y))
-		sc->sc_dy += y;
+		sc->sc_dy += y * sc->sc_my;
 	if (!(flags & WSMOUSE_INPUT_ABSOLUTE_Z))
-		sc->sc_dz += z;
+		sc->sc_dz += z * sc->sc_mz;
 	if (!(flags & WSMOUSE_INPUT_ABSOLUTE_W))
-		sc->sc_dw += w;
+		sc->sc_dw += w * sc->sc_mw;
 
 	/*
 	 * We have at least one event (mouse button, delta-X, or
@@ -395,9 +408,9 @@ wsmouse_input(device_t wsmousedev, u_int
 			nevents++;
 		}
 	} else {
-		if (sc->sc_dx) {
+		if (sc->sc_dx / WSCONS_MOUSE_RES) {
 			events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_X;
-			events[nevents].value = sc->sc_dx;
+			events[nevents].value = sc->sc_dx / WSCONS_MOUSE_RES;
 			nevents++;
 		}
 	}
@@ -408,9 +421,9 @@ wsmouse_input(device_t wsmousedev, u_int
 			nevents++;
 		}
 	} else {
-		if (sc->sc_dy) {
+		if (sc->sc_dy / WSCONS_MOUSE_RES) {
 			events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_Y;
-			events[nevents].value = sc->sc_dy;
+			events[nevents].value = sc->sc_dy / WSCONS_MOUSE_RES;
 			nevents++;
 		}
 	}
@@ -421,9 +434,9 @@ wsmouse_input(device_t wsmousedev, u_int
 			nevents++;
 		}
 	} else {
-		if (sc->sc_dz) {
+		if (sc->sc_dz / WSCONS_MOUSE_RES) {
 			events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_Z;
-			events[nevents].value = sc->sc_dz;
+			events[nevents].value = sc->sc_dz / WSCONS_MOUSE_RES;
 			nevents++;
 		}
 	}
@@ -434,9 +447,9 @@ wsmouse_input(device_t wsmousedev, u_int
 			nevents++;
 		}
 	} else {
-		if (sc->sc_dw) {
+		if (sc->sc_dw / WSCONS_MOUSE_RES) {
 			events[nevents].type = WSCONS_EVENT_MOUSE_DELTA_W;
-			events[nevents].value = sc->sc_dw;
+			events[nevents].value = sc->sc_dw / WSCONS_MOUSE_RES;
 			nevents++;
 		}
 	}
@@ -494,10 +507,10 @@ wsmouse_input(device_t wsmousedev, u_int
 		/* All events were correctly injected into the queue.
 		 * Synchronize the mouse's status with what the user
 		 * has received. */
-		sc->sc_x = x; sc->sc_dx = 0;
-		sc->sc_y = y; sc->sc_dy = 0;
-		sc->sc_z = z; sc->sc_dz = 0;
-		sc->sc_w = w; sc->sc_dw = 0;
+		sc->sc_x = x; sc->sc_dx %= WSCONS_MOUSE_RES;
+		sc->sc_y = y; sc->sc_dy %= WSCONS_MOUSE_RES;
+		sc->sc_z = z; sc->sc_dz %= WSCONS_MOUSE_RES;
+		sc->sc_w = w; sc->sc_dw %= WSCONS_MOUSE_RES;
 		sc->sc_ub = ub;
 #if NWSMUX > 0
 		DPRINTFN(5,("wsmouse_input: %s wakeup evar=%p\n",
@@ -687,6 +700,7 @@ wsmouse_do_ioctl(struct wsmouse_softc *s
 {
 	int error;
 	struct wsmouse_repeat *wr;
+	int s;
 
 	if (sc->sc_dying)
 		return (EIO);
@@ -749,6 +763,31 @@ wsmouse_do_ioctl(struct wsmouse_softc *s
 
 		return 0;
 
+	case WSMOUSEIO_SETSCALEXY:
+		if (*(int *)data == 0)
+			return EINVAL;
+		s = spltty();
+		sc->sc_my = sc->sc_mx =
+		    (*(int *)data) * WSCONS_MOUSE_RES / 100;
+		splx(s);
+		return 0;
+
+	case WSMOUSEIO_SETSCALEZ:
+		if (*(int *)data == 0)
+			return EINVAL;
+		s = spltty();
+		sc->sc_mz = (*(int *)data) * WSCONS_MOUSE_RES / 100;
+		splx(s);
+		return 0;
+
+	case WSMOUSEIO_SETSCALEW:
+		if (*(int *)data == 0)
+			return EINVAL;
+		s = spltty();
+		sc->sc_mw = (*(int *)data) * WSCONS_MOUSE_RES / 100;
+		splx(s);
+		return 0;
+
 	case WSMOUSEIO_SETVERSION:
 		return wsevent_setversion(sc->sc_base.me_evp, *(int *)data);
 	}

Reply via email to