Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Mar 2002 12:07:39 -0800 (PST)
From:      "Mikhail A. Vladimirov" <vladimirow@mail.ru>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/36143: Dynamic (non linear) mouse acceleration added to moused
Message-ID:  <200203202007.g2KK7dK76857@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         36143
>Category:       misc
>Synopsis:       Dynamic (non linear) mouse acceleration added to moused
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 20 12:10:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Mikhail A. Vladimirov
>Release:        4.4-STABLE
>Organization:
Moscow State University
>Environment:
FreeBSD stalker.hackers 4.5-STABLE FreeBSD 4.5-STABLE #0: Fri Feb  1 18:52:34 MSK 2002     stalker@stalker.hackers:/usr/obj/usr/src/sys/STALKER  i386

>Description:
Patch for moused, that adds 
-A twice[,quadro]
flag.  Mouse movement speed accelerated twice, if mouse moves more then _twice_ steps a time.  And when mouse moves more, then quadro steps a time, it accelerated four times.  I changed moused.8 manual page too, but there may be some typos.  I use resolution 1280x960 and I think, that this patch realy did things better.  I found
-F 200 -A 4,8
setting very suitable for my Logitech M-S48a mouse.
>How-To-Repeat:
Apply this patch, recompile and restart moused. :)
>Fix:
diff -c -r orig/moused.8 moused/moused.8
*** orig/moused.8	Wed Mar 20 22:46:59 2002
--- moused/moused.8	Wed Mar 20 22:40:22 2002
***************
*** 44,49 ****
--- 44,50 ----
  .Op Fl r Ar resolution
  .Op Fl S Ar baudrate
  .Op Fl a Ar X Ns Op , Ns Ar Y
+ .Op Fl A Ar twice Ns Op , Ns Ar quadro
  .Op Fl C Ar threshold
  .Op Fl m Ar N=M
  .Op Fl w Ar N
***************
*** 161,166 ****
--- 162,179 ----
  Values less than 1.0 slow down movement, values greater than 1.0 speed it
  up.
  Specifying only one value sets the acceleration for both axes.
+ .It Fl A Ar twice Ns Op , Ns Ar quadro
+ Accelerate the mouse input dynamically.
+ If mouse moves more then 
+ .Ar twice
+ steps at a time, extra movement accelerated twice.
+ If mouse moves more then
+ .Ar quadro
+ steps at a time, extra movement accelerated four times.
+ If the 
+ .Fl a
+ option is present, the dynamic acceleration applies before 
+ linear acceleration.
  .It Fl c
  Some mice report middle button down events
  as if the left and right buttons are being pressed.
diff -c -r orig/moused.c moused/moused.c
*** orig/moused.c	Wed Mar 20 22:46:59 2002
--- moused/moused.c	Wed Mar 20 22:21:31 2002
***************
*** 389,394 ****
--- 389,396 ----
      mousemode_t mode;		/* protocol information */
      float accelx;		/* Acceleration in the X axis */
      float accely;		/* Acceleration in the Y axis */
+     int twice;                  /* Twice acceleration limit in pixels */
+     int quadro;                 /* Quadro acceleration limit in pixels */
  } rodent = { 
      flags : 0, 
      portname : NULL,
***************
*** 407,412 ****
--- 409,416 ----
      button2timeout : DFLT_BUTTON2TIMEOUT,
      accelx : 1.0,
      accely : 1.0,
+     twice : 10000,
+     quadro : 10000
  };
  
  /* button status */
***************
*** 474,479 ****
--- 478,484 ----
  static void	hup(int sig);
  static void	cleanup(int sig);
  static void	usage(void);
+ static int      dynaccel (int delta);
  
  static int	r_identify(void);
  static char	*r_if(int type);
***************
*** 513,519 ****
      for (i = 0; i < MOUSE_MAXBUTTON; ++i)
  	mstate[i] = &bstate[i];
  
!     while((c = getopt(argc,argv,"3C:DE:F:I:PRS:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
  	switch(c) {
  
  	case '3':
--- 518,524 ----
      for (i = 0; i < MOUSE_MAXBUTTON; ++i)
  	mstate[i] = &bstate[i];
  
!     while((c = getopt(argc,argv,"3C:DE:F:I:PRS:a:A:cdfhi:l:m:p:r:st:w:z:")) != -1)
  	switch(c) {
  
  	case '3':
***************
*** 532,538 ****
  	case 'a':
  	    i = sscanf(optarg, "%f,%f", &rodent.accelx, &rodent.accely);
  	    if (i == 0) {
! 		warnx("invalid acceleration argument '%s'", optarg);
  		usage();
  	    }
  	    
--- 537,543 ----
  	case 'a':
  	    i = sscanf(optarg, "%f,%f", &rodent.accelx, &rodent.accely);
  	    if (i == 0) {
! 		warnx("invalid acceleration argument `%s'", optarg);
  		usage();
  	    }
  	    
***************
*** 541,546 ****
--- 546,560 ----
  	    
  	    break;
  	    
+ 	case 'A':
+ 	    i = sscanf(optarg, "%d,%d", &rodent.twice, &rodent.quadro);
+ 	    if (i == 0) {
+ 		warnx("invalid dynamic acceleration argument `%s'", optarg);
+ 		usage();
+ 	    }
+ 
+ 	    break;
+ 
  	case 'c':
  	    rodent.flags |= ChordMiddle;
  	    break;
***************
*** 943,950 ****
  	        if (action2.flags & MOUSE_POSCHANGED) {
      		    mouse.operation = MOUSE_MOTION_EVENT;
  	            mouse.u.data.buttons = action2.button;
! 	            mouse.u.data.x = action2.dx * rodent.accelx;
! 	            mouse.u.data.y = action2.dy * rodent.accely;
  	            mouse.u.data.z = action2.dz;
  		    if (debug < 2)
  	                ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
--- 957,964 ----
  	        if (action2.flags & MOUSE_POSCHANGED) {
      		    mouse.operation = MOUSE_MOTION_EVENT;
  	            mouse.u.data.buttons = action2.button;
! 	            mouse.u.data.x = dynaccel(action2.dx) * rodent.accelx;
! 	            mouse.u.data.y = dynaccel(action2.dy) * rodent.accely;
  	            mouse.u.data.z = action2.dz;
  		    if (debug < 2)
  	                ioctl(rodent.cfd, CONS_MOUSECTL, &mouse);
***************
*** 1010,1021 ****
  {
      fprintf(stderr, "%s\n%s\n%s\n%s\n",
  	"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
! 	"              [-a X [,Y]] [-C threshold] [-m N=M] [-w N] [-z N]",
! 	"              [-t <mousetype>] [-3 [-E timeout]] -p <port>",
  	"       moused [-d] -i <port|if|type|model|all> -p <port>");
      exit(1);
  }
  
  /**
   ** Mouse interface code, courtesy of XFree86 3.1.2.
   **
--- 1024,1056 ----
  {
      fprintf(stderr, "%s\n%s\n%s\n%s\n",
  	"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
! 	"              [-a X [,Y]] [-A twice [,quadro]] [-C threshold] [-m N=M]",
!         "              [-w N] [-z N] [-t <mousetype>] [-3 [-E timeout]] -p <port>",
  	"       moused [-d] -i <port|if|type|model|all> -p <port>");
      exit(1);
  }
  
+ static int
+ dynaccel(int delta)
+ {
+     int sign=1;
+ 
+     if (delta<0)
+     {
+ 	sign=-1;
+ 	delta=-delta;
+     }
+ 
+     if (delta<=rodent.twice) return delta*sign;
+ 
+     if (delta<=rodent.quadro) 
+ 	return (rodent.twice+(delta-rodent.twice)*2)*sign;
+ 
+     return (rodent.twice+
+ 	    (rodent.quadro-rodent.twice)*2+
+ 	    (delta-rodent.quadro)*4)*sign;
+ }
+ 
  /**
   ** Mouse interface code, courtesy of XFree86 3.1.2.
   **
***************
*** 2940,2944 ****
  	rodent.mremcfd = -1;
      }
  }
- 
  
--- 2975,2978 ----


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203202007.g2KK7dK76857>