[Xpert]Proposal for mouse speed/acceleration settings improvement

2002-11-02 Thread Michael Toomim
I propose adding an option to the XF86Config mouse settings that lets a 
user modify the mouse speed (not acceleration) dynamically (with xset 
rather than XF86Config).

Right now, xset m acceleration threshold tells X to make the mouse go 
acceleration times faster when it's going beyond speed threshold, 
unless threshold is 0, in which case it makes the mouse go at a 
polynomial mouse_speed^acceleration instead of mouse_speed^1.  This 
last feature (with threshold=0) is undocumented.

The right way to do things is to have smooth acceleration curve (like 
polynomial) and to let the user control both the acceleration and a 
constant multiplier dynamically (not in XF86Config).  For example, the 
mouse should behave something like a * speed^b where a and b can be 
set through xset.  Currently, one can fake a constant multiplier by 
setting a Resolution parameter in XF86Config.  But this feature 
requires root access, a server restart, a lot of figuring out (how does 
resolution correspond to speed?), is buried in the documentation 
(it's not on XF86Config's man page), and isn't supported for all mice.

Proposal:  Add a boolean option to XF86Config called 
UseSmoothMouseAccel that changes the behavior of xset.  If this 
variable is set to true, the command xset m VALUE_A VALUE_B will be 
interpreted as set the mouse function to VALUE_B * 
mouse_speed^VALUE_A.  This way, nobody has to modify xset.  The server 
would also need some way to communicate the state of 
UseSmoothMouseAccel to clients, in order to show the right UI to the 
user settings mouse settings.

Michael



___
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert


[Xpert]Proposal for mouse speed acceleration settings

2002-11-02 Thread Michael Toomim
I propose adding an option to the XF86Config mouse settings that lets a 
user modify the mouse speed dynamically with xset, rather than with the 
Resolution option in XF86Config.

Right now, xset m acceleration threshold means:

   Move the cursor at speed `acceleration*raw_mouse_speed' whenever
   `raw_mouse_speed' is greater than `threshold' -- unless `threshold'
   is 0, in which case the cursor will move at
   `raw_mouse_speed^acceleration'.

This last feature (with threshold=0) is completely undocumented.  In 
addition, there's no way to speed up the mouse by a constant multiplier 
(independent of acceleration) without changing the Resolution option 
in XF86Config.  This requires a server restart, root access, isn't 
documented in XF86Config's man page, isn't supported for all mice, can't 
be customized per-user, and doesn't really make sense (Resolution is 
inversely proportional to MouseSpeed).

The right way to do mouse acceleration is to have a smooth acceleration 
curve (like the polynomial you get with threshold=0) and to let the user 
control both the acceleration and a constant multiplier dynamically (not 
in XF86Config).  For example, it'd be great if xset m [A] [B] made the 
cursor move according to the formula  [A] * raw_mouse_speed^[B].

Proposal:  Add a boolean option to XF86Config called 
UseSmoothMouseAccel that changes the behavior of xset.  If this 
variable is set to true, the command `xset m [A] [B]' will mean set the 
cursor movement function to `[A] * raw_mouse_speed^[B]'.

This will also require some way for client X applications (like gnome's 
mouse settings applet) to determine the value of UseSmoothMouseAccel, etc.

Comments?  There has been scattered discussion of possible ways to 
improve XFree86's mouse acceleration in the past, but there haven't been 
many practical solutions suggested.  I'd really like to get this cobweb 
cleaned up.

Michael

___
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert


Re: [Xpert]Proposal for mouse speed acceleration settings

2002-11-01 Thread Soeren Sandmann
Michael Toomim [EMAIL PROTECTED] writes:

 Proposal:  Add a boolean option to XF86Config called
 UseSmoothMouseAccel that changes the behavior of xset.  If this
 variable is set to true, the command `xset m [A] [B]' will mean set the
 cursor movement function to `[A] * raw_mouse_speed^[B]'.

Back in May this year I sent the mail below to [EMAIL PROTECTED], but
I never got any response.

Søren


From: Soeren Sandmann [EMAIL PROTECTED]
Subject: Smoother mouse acceleration
To: [EMAIL PROTECTED]

The current mouse acceleration algorithm when the user defined
threshold is non-zero is essentially this:

if (d  t)
d' = A * d
else
d' = d;

where d' is the new traveled distance, and d the distqance reported by
the mouse.  The constant t is the user defined threshold, and A 
(= num/den) is the user defined amount of acceleration.

There are some problems with this:

- if you set the threshold high, the mouse cursor feels
  sticky. If you move the mouse at just the right speed, you
  will se jerky cursor movements as the traveled distance
  oscillates around the threshold.

- if you set the threshold low and the acceleration high, you
  lose precision as the cursor moves too fast even on small
  movements.

- if you set the acceleration low, it gets difficult to reach
  to corners of the screen.

So, while this isn't terribly bad, it not really good either 

Here is a patch that modifies the mouse acceleration code to use the
formula

d' = c * d^alpha + d

where d' is the new distance and d is the distance reported by the
mouse. The constants c and alpha are based on the acceleration
settings, specifically

c = 1 / (threshold / 4) ^alpha

which ensures that when the travelled distance is less then
threshold/4, the distance is not modified by more than 1. This ensures
that the threshold set by the user still corresponds to the precision
of the device.

The constant alpha is just a linear function of the user set
acceleration.

The patch also changes the default acceleration to 8/3 3, which in my
opinion is a more useful setting than 2/1 4, which is the current
default.


Søren



--- ../../../xcoriginal/programs/Xserver/hw/xfree86/common/xf86Xinput.c	Tue May 21 01:50:43 2002
+++ ./hw/xfree86/common/xf86Xinput.c	Tue May 21 01:49:00 2002
@@ -905,15 +905,42 @@
 		/*
 		 * Accelerate
 		 */
-		if (device-ptrfeed  device-ptrfeed-ctrl.num) {
-		/* modeled from xf86Events.c */
-		if (device-ptrfeed-ctrl.threshold) {
-			if ((abs(dx) + abs(dy)) = device-ptrfeed-ctrl.threshold) {
-			valuator[0] = (dx * device-ptrfeed-ctrl.num) /
-	device-ptrfeed-ctrl.den;
-			valuator[1] = (dy * device-ptrfeed-ctrl.num) /
-	device-ptrfeed-ctrl.den;
+		if (device-ptrfeed  device-ptrfeed-ctrl.num  device-ptrfeed-ctrl.den) {
+		if (device-ptrfeed-ctrl.num = device-ptrfeed-ctrl.den) {
+			valuator[0] = (dx * device-ptrfeed-ctrl.num) / device-ptrfeed-ctrl.den;
+			valuator[1] = (dy * device-ptrfeed-ctrl.num) / device-ptrfeed-ctrl.den;
+		}
+		else if (device-ptrfeed-ctrl.threshold) {
+			static int cached_num = -1;
+			static int cached_den = -1;
+			static int cached_threshold = -1;
+
+			static double c = -1;
+			static double alpha = -1;
+
+			double k;
+			
+			if (cached_num != device-ptrfeed-ctrl.num ||
+			cached_den != device-ptrfeed-ctrl.den ||
+			cached_threshold != device-ptrfeed-ctrl.threshold) {
+
+			double A, t;
+			
+			cached_num = device-ptrfeed-ctrl.num;
+			cached_den = device-ptrfeed-ctrl.den;
+			cached_threshold = device-ptrfeed-ctrl.threshold;
+
+			A = (double)cached_num / cached_den;
+			t = (double)cached_threshold;
+
+			alpha = A/3.0 + 2.0/3.0;
+			c = 1 / pow (t/4.0, alpha);
 			}
+
+			k = c * pow (dx*dx + dy*dy, 0.5 * (alpha - 1)) + 1;
+
+			valuator[0] = k * dx;
+			valuator[1] = k * dy;
 		}
 		else if (dx || dy) {
 			mult = pow((float)(dx*dx+dy*dy),
--- ../../../xcoriginal/programs/Xserver/include/site.h	Tue May 21 01:50:43 2002
+++ ./include/site.h	Tue May 21 01:17:48 2002
@@ -113,9 +113,9 @@
 #define DEFAULT_INT_MAX_VALUE		100
 #define DEFAULT_INT_DISPLAYED		0
 
-#define DEFAULT_PTR_NUMERATOR	2
-#define DEFAULT_PTR_DENOMINATOR	1
-#define DEFAULT_PTR_THRESHOLD	4
+#define DEFAULT_PTR_NUMERATOR	8
+#define DEFAULT_PTR_DENOMINATOR	3
+#define DEFAULT_PTR_THRESHOLD	3
 
 #define DEFAULT_SCREEN_SAVER_TIME (10 * (60 * 1000))
 #define DEFAULT_SCREEN_SAVER_INTERVAL (10 * (60 * 1000))



Re: [Xpert]Proposal for mouse speed acceleration settings

2002-11-01 Thread Michael Toomim
Soeren Sandmann wrote:


Back in May this year I sent the mail below to [EMAIL PROTECTED], but
I never got any response.


That sucks!  Would it be rude to send it again?

I like the idea of changing the acceleration formula completely (as you 
have done) rather than introducing a new XF86Config option to change it 
(as I had suggested).

___
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert


Re: [Xpert]Proposal for mouse speed acceleration settings

2002-11-01 Thread Craig Carey
At 02\11\01 11:52 -0800 Friday, Michael Toomim wrote:
Soeren Sandmann wrote:

 Back in May this year I sent the mail below to [EMAIL PROTECTED], but
 I never got any response.

That sucks!  Would it be rude to send it again?

I like the idea of changing the acceleration formula completely (as you
have done) rather than introducing a new XF86Config option to change it
(as I had suggested).


The XFree86 mouse deceleration function gets dx,dy integers that are
small integers in between -1 and +1 quite often. Whatever the function
(formula) was, it could be replaced with these two without much change:

  dx' = k1 * dx * (+1 if dx  0 else -1)
  dx' = k2 * dx

 [dx is a C int, dx' is real that is added to a real sum and then
 later converted into a screen pixel position]

Mr David Dawes was replying to some e-mail on the topic of the mouse
deceleration algorithm. He told me about Opensource projects.

What could be done is this:

* xf86PostMotionEvent() is repeatedly called. EAch time it is called,
 the dx,dy and time values are saved.

* an algorithm averages the last k dx (and dy) values. The function
 that calculates k is not too simple. Certainly k is not a constant
 since that can lead to a slow mouse pointer appearing to have inertia.

I presume patches aiming to tweak functions ought be filed/etc away
while there is not some substantially better averaging algorithm in
the XFree86 source code.


xf86PostMotionEvent():
http://cvsweb.xfree86.org/cvsweb/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c


Craig Carey

___
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert



[Xpert]Proposal for mouse speed acceleration settings

2002-10-31 Thread Michael Toomim
I propose adding an option to the XF86Config mouse settings that lets a
user modify the mouse speed dynamically with xset, rather than with the
Resolution option in XF86Config.

Right now, xset m acceleration threshold means:

Move the cursor at speed `acceleration*raw_mouse_speed' whenever
`raw_mouse_speed' is greater than `threshold' -- unless `threshold'
is 0, in which case the cursor will move at
`raw_mouse_speed^acceleration'.

This last feature (with threshold=0) is completely undocumented.  In
addition, there's no way to speed up the mouse by a constant multiplier
(independent of acceleration) without changing the Resolution option
in XF86Config.  This requires a server restart, root access, isn't
documented in XF86Config's man page, isn't supported for all mice, can't
be customized per-user, and doesn't really make sense (Resolution is
inversely proportional to MouseSpeed).

The right way to do mouse acceleration is to have a smooth acceleration
curve (like the polynomial you get with threshold=0) and to let the user
control both the acceleration and a constant multiplier dynamically (not
in XF86Config).  For example, it'd be great if xset m [A] [B] made the
cursor move according to the formula [A] * raw_mouse_speed^[B].

Proposal:  Add a boolean option to XF86Config called
UseSmoothMouseAccel that changes the behavior of xset.  If this
variable is set to true, the command `xset m [A] [B]' will mean set the
cursor movement function to `[A] * raw_mouse_speed^[B]'.

This will also require some way for client X applications (like gnome's
mouse settings applet) to determine the value of UseSmoothMouseAccel, etc.

Comments?  There has been scattered discussion of possible ways to
improve XFree86's mouse acceleration in the past, but there haven't been
many practical solutions suggested.  I'd really like to get this cobweb
cleaned up.

Michael

___
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert



Re: [Xpert]Proposal for mouse speed acceleration settings

2002-10-31 Thread Craig Carey
I have a webpage on the topic of the mouse in XFree86:

http://www.ijs.co.nz/linux-orbiting-mouse.htm



At 2002\10\31 18:20 -0800 Thursday, Michael Toomim wrote:
I propose adding an option to the XF86Config mouse settings that lets a
user modify the mouse speed dynamically with xset, rather than with the
Resolution option in XF86Config.

Right now, xset m acceleration threshold means:

 Move the cursor at speed `acceleration*raw_mouse_speed' whenever
 `raw_mouse_speed' is greater than `threshold' -- unless `threshold'
 is 0, in which case the cursor will move at
 `raw_mouse_speed^acceleration'.

This last feature (with threshold=0) is completely undocumented.  In

It is also not available to KDE users (who can't get the threshold down
to 0, if I recall correctly).
Anyway, the unavailable algorithm maybe is no better (or if it is, then
comparing the two is going to produce indecision over which is better).


addition, there's no way to speed up the mouse by a constant multiplier
(independent of acceleration) without changing the Resolution option
in XF86Config.  This requires a server restart, root access, isn't
documented in XF86Config's man page, isn't supported for all mice, can't
be customized per-user, and doesn't really make sense (Resolution is
inversely proportional to MouseSpeed).

The right way to do mouse acceleration is to have a smooth acceleration
curve (like the polynomial you get with threshold=0) and to let the user


That is not correct because the data going into the functions. is mainly
(dx,dy) taking these values: (0,0),(1,0),(-1,0),(0,1),(0,-1). It might
be different if some high resolution expensive mouse gets around the
problem. Such things are not needed when Windows 2000 is used.

To get the digits +/-2 to show up, when there is a plain Microsoft PS/2
mouse, then a speed that is often not reached, is needed.


control both the acceleration and a constant multiplier dynamically (not
in XF86Config).  For example, it'd be great if xset m [A] [B] made the
cursor move according to the formula [A] * raw_mouse_speed^[B].


It is a 2-D curve.
Also it has a discontinuity in it which is a bug. The effect of the bug
would be to make the mouse orbit around that stopping point. I tried
removing the bug but it was not any better. The function ought be
replaced eventually even though it seems to me that most of the problem
is due to the missing code to do averaging of dx,dy integers.



Proposal:  Add a boolean option to XF86Config called
UseSmoothMouseAccel that changes the behavior of xset.  If this
variable is set to true, the command `xset m [A] [B]' will mean set the
cursor movement function to `[A] * raw_mouse_speed^[B]'.


While the bad problem of an absence of code to average mouse data (for
a plain XFree86 configuration), is not remedied, then other problems
can't easily be fixed, due to reviewers being unable to decide if the
change made the mouse better or worse. After that there could be a
problem of too many possible algorithms.

It could be nice to shift disputes over retaining the meaning of the
sliders in GNOME and rewriting the parameters, out to the desktop
bug tracking systems, so it does not add disputes unnecessarily to
the topic of whether copying the mouse algorithm of Windows 2000/Timeout
is best.


The problems are inside of the xf86PostMotionEvent() procedure, which can
be viewed at this URL:
http://cvsweb.xfree86.org/cvsweb/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c


This will also require some way for client X applications (like gnome's
mouse settings applet) to determine the value of UseSmoothMouseAccel, etc.



Comments?  There has been scattered discussion of possible ways to
improve XFree86's mouse acceleration in the past, but there haven't been
many practical solutions suggested.  I'd really like to get this cobweb
cleaned up.

I am guessing people would prefer hundreds of iterations recompiling.
A quickest way could be to start out compiling some Windows program.

Tapping into Windows 2000 mouse data and then inferring from an analysis
of the data should allow the Microsoft algorithm to be precisely
copied. They have a worse mouse deceleration algorithm in Windows 98 SE,
and possibly the best effort of someone could produce something as bad,
Anyway, for many, having the mouse be about identical to a Windows 2000
mouse is aim independent of one of having the behaviour be unimprovable.

---

To fix the bad design of the sliders in GNOME and KDE could justify a
preprocessing subroutine/procedure that alters the parameters that then
pass into the mouse pointer deceleration algorithm. Possibly they might
want to control the rewriting of the parameter integers but not
provide their own new mouse deceleration code.


Would someone say how to get debugging data piped out of XFree86 and
put into a window in XFree86 in any OS. Any sample code to copy?.





Craig Carey [EMAIL PROTECTED]  Auckland, New Zealand
Ada 95 mailing lists;