From kjelderg@cerberus.cs.und.nodak.edu  Wed Jun 29 03:26:56 2005
Return-Path: <kjelderg@cerberus.cs.und.nodak.edu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D81DB16A41C
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 29 Jun 2005 03:26:56 +0000 (GMT)
	(envelope-from kjelderg@cerberus.cs.und.nodak.edu)
Received: from cerberus.cs.und.nodak.edu (cerberus.cs.und.nodak.edu [134.129.223.74])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9070243D55
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 29 Jun 2005 03:26:56 +0000 (GMT)
	(envelope-from kjelderg@cerberus.cs.und.nodak.edu)
Received: from cerberus.cs.und.nodak.edu (localhost [127.0.0.1])
	by cerberus.cs.und.nodak.edu (8.13.1/8.13.1) with ESMTP id j5T3TYHs016593
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 28 Jun 2005 22:29:34 -0500 (CDT)
	(envelope-from kjelderg@cerberus.cs.und.nodak.edu)
Received: (from kjelderg@localhost)
	by cerberus.cs.und.nodak.edu (8.13.1/8.13.1/Submit) id j5T3TYrN016592;
	Tue, 28 Jun 2005 22:29:34 -0500 (CDT)
	(envelope-from kjelderg)
Message-Id: <200506290329.j5T3TYrN016592@cerberus.cs.und.nodak.edu>
Date: Tue, 28 Jun 2005 22:29:34 -0500 (CDT)
From: Eric Kjeldergaard <kjelderg@gmail.com>
Reply-To: Eric Kjeldergaard <kjelderg@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] adding a virtual horizontal scroll feature to moused
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         82762
>Category:       bin
>Synopsis:       [patch] adding a virtual horizontal scroll feature to moused
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    philip
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 29 03:30:28 GMT 2005
>Closed-Date:    Tue Jul 19 19:31:55 GMT 2005
>Last-Modified:  Tue Jul 19 19:31:55 GMT 2005
>Originator:     Eric Kjeldergaard <kjelderg@gmail.com>
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 6.0-CURRENT FreeBSD 6.0-CURRENT #3: Sat Jun 25 15:01:29 UTC 2005 t
oor@:/usr/obj/usr/src/sys/UNINFECTABLE i386

	
>Description:
	The attached patch adds a -H option to moused.  moused has a -V option.  The -V option allows a user to generate "vertical scroll events" by holding the middle button of the mouse and generating Y-Axis movement.  Similarly, the -H option allows users to generate "horizontal scroll events" by holding the middle button and generating X-Axis movement.  The -V and -H options may be used together or separately.  Both options respect the threshold which can be set with the -U option.
>How-To-Repeat:
	
>Fix:

	

--- moused.diff begins here ---
*** moused.c	Wed Apr 13 16:25:45 2005
--- moused.c.horizontal	Wed Jun 29 00:26:07 2005
***************
*** 97,106 ****
--- 97,107 ----
  #define Emulate3Button	0x0002
  #define ClearDTR	0x0004
  #define ClearRTS	0x0008
  #define NoPnP		0x0010
  #define VirtualScroll	0x0020
+ #define HVirtualScroll	0x0040
  
  #define ID_NONE		0
  #define ID_PORT		1
  #define ID_IF		2
  #define ID_TYPE		4
***************
*** 165,174 ****
--- 166,176 ----
  #define SCROLL_PREPARE		1
  #define SCROLL_SCROLLING	2
  
  static int	scroll_state;
  static int	scroll_movement;
+ static int	hscroll_movement;
  
  /* local variables */
  
  /* interface (the table must be ordered by MOUSE_IF_XXX in mouse.h) */
  static symtab_t rifs[] = {
***************
*** 521,531 ****
      int retry;
  
      for (i = 0; i < MOUSE_MAXBUTTON; ++i)
  	mstate[i] = &bstate[i];
  
!     while ((c = getopt(argc, argv, "3C:DE:F:I:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
  	switch(c) {
  
  	case '3':
  	    rodent.flags |= Emulate3Button;
  	    break;
--- 523,533 ----
      int retry;
  
      for (i = 0; i < MOUSE_MAXBUTTON; ++i)
  	mstate[i] = &bstate[i];
  
!     while ((c = getopt(argc, argv, "3C:DE:F:HI:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
  	switch(c) {
  
  	case '3':
  	    rodent.flags |= Emulate3Button;
  	    break;
***************
*** 686,695 ****
--- 688,701 ----
  		warnx("invalid argument `%s'", optarg);
  		usage();
  	    }
  	    break;
  
+ 	case 'H':
+ 	    rodent.flags |= HVirtualScroll;
+ 	    break;
+ 		 
  	case 'I':
  	    pidfile = optarg;
  	    break;
  
  	case 'P':
***************
*** 991,1001 ****
  		    return;
  	    }
  	    if ((flags = r_protocol(b, &action0)) == 0)
  		continue;
  
! 	    if (rodent.flags & VirtualScroll) {
  		/* Allow middle button drags to scroll up and down */
  		if (action0.button == MOUSE_BUTTON2DOWN) {
  		    if (scroll_state == SCROLL_NOTSCROLLING) {
  			scroll_state = SCROLL_PREPARE;
  			debug("PREPARING TO SCROLL");
--- 997,1007 ----
  		    return;
  	    }
  	    if ((flags = r_protocol(b, &action0)) == 0)
  		continue;
  
! 	    if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) {
  		/* Allow middle button drags to scroll up and down */
  		if (action0.button == MOUSE_BUTTON2DOWN) {
  		    if (scroll_state == SCROLL_NOTSCROLLING) {
  			scroll_state = SCROLL_PREPARE;
  			debug("PREPARING TO SCROLL");
***************
*** 1051,1061 ****
  	if (flags) {			/* handler detected action */
  	    r_map(&action, &action2);
  	    debug("activity : buttons 0x%08x  dx %d  dy %d  dz %d",
  		action2.button, action2.dx, action2.dy, action2.dz);
  
! 	    if (rodent.flags & VirtualScroll) {
  		/* 
  		 * If *only* the middle button is pressed AND we are moving
  		 * the stick/trackpoint/nipple, scroll!
  		 */
  		if (scroll_state == SCROLL_PREPARE) {
--- 1057,1067 ----
  	if (flags) {			/* handler detected action */
  	    r_map(&action, &action2);
  	    debug("activity : buttons 0x%08x  dx %d  dy %d  dz %d",
  		action2.button, action2.dx, action2.dy, action2.dz);
  
! 	    if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) {
  		/* 
  		 * If *only* the middle button is pressed AND we are moving
  		 * the stick/trackpoint/nipple, scroll!
  		 */
  		if (scroll_state == SCROLL_PREPARE) {
***************
*** 1063,1084 ****
  		    if (action2.dy || action2.dx)
  			scroll_state = SCROLL_SCROLLING;
  		}
  		if (scroll_state == SCROLL_SCROLLING) {
  		    scroll_movement += action2.dy;
! 		    debug("SCROLL: %d", scroll_movement);
  
! 		    if (scroll_movement < -rodent.scrollthreshold) { 
! 			/* Scroll down */
! 			action2.dz = -1;
! 			scroll_movement = 0;
! 		    }
! 		    else if (scroll_movement > rodent.scrollthreshold) { 
! 			/* Scroll up */
! 			action2.dz = 1;
! 			scroll_movement = 0;
! 		    }
  
  		    /* Don't move while scrolling */
  		    action2.dx = action2.dy = 0;
  		}
  	    }
--- 1069,1106 ----
  		    if (action2.dy || action2.dx)
  			scroll_state = SCROLL_SCROLLING;
  		}
  		if (scroll_state == SCROLL_SCROLLING) {
  		    scroll_movement += action2.dy;
! 			 hscroll_movement += action2.dx;
  
! 			 if (rodent.flags & VirtualScroll) {
! 				debug("Rodent Flags: %d", rodent.flags);
! 		    	debug("SCROLL: %d", scroll_movement);
! 			    if (scroll_movement < -rodent.scrollthreshold) { 
! 				/* Scroll down */
! 				action2.dz = -1;
! 				scroll_movement = 0;
! 			    }
! 			    else if (scroll_movement > rodent.scrollthreshold) { 
! 				/* Scroll up */
! 				action2.dz = 1;
! 				scroll_movement = 0;
! 			    }
! 			 }
! 			 if (rodent.flags & HVirtualScroll) {
! 				debug("Rodent Flags: %d", rodent.flags);
! 		    	debug("HORIZONTAL SCROLL: %d", hscroll_movement);
! 				 if (hscroll_movement < -rodent.scrollthreshold) {
! 					 action2.dz = -2;
! 					 hscroll_movement = 0;
! 				 }
! 				 else if (hscroll_movement > rodent.scrollthreshold) {
! 					 action2.dz = 2;
! 					 hscroll_movement = 0;
! 				 }
! 			 }
  
  		    /* Don't move while scrolling */
  		    action2.dx = action2.dy = 0;
  		}
  	    }
***************
*** 1156,1166 ****
  static void
  usage(void)
  {
      fprintf(stderr, "%s\n%s\n%s\n%s\n",
  	"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
! 	"              [-V [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]",
  	"              [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]] -p <port>",
  	"       moused [-d] -i <port|if|type|model|all> -p <port>");
      exit(1);
  }
  
--- 1178,1188 ----
  static void
  usage(void)
  {
      fprintf(stderr, "%s\n%s\n%s\n%s\n",
  	"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
! 	"              [-VH [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]",
  	"              [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]] -p <port>",
  	"       moused [-d] -i <port|if|type|model|all> -p <port>");
      exit(1);
  }
  
--- moused.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->philip 
Responsible-Changed-By: philip 
Responsible-Changed-When: Thu Jun 30 10:55:58 GMT 2005 
Responsible-Changed-Why:  
Grab this - I like it. :-) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=82762 

From: Eric Kjeldergaard <kjelderg@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/82762: [patch] adding a virtual horizontal scroll feature to moused
Date: Thu, 30 Jun 2005 21:41:27 +0900

 --Boundary-00=_3h+wCs8tCFKRcwM
 Content-Type: text/plain;
   charset="iso-2022-jp"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 The promised update to the man page (I hope it's alright) and a fix that was 
 bothering me for the moused.c file.  If only -H or only -V were enabled, it 
 would have been adding one extra addition and assignment operation.  We have 
 better things to do with our processor cycles.
 
 --Boundary-00=_3h+wCs8tCFKRcwM
 Content-Type: text/x-diff;
   charset="iso-2022-jp";
   name="moused.8.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="moused.8.diff"
 
 *** moused.8	Thu Jun 30 20:55:28 2005
 --- moused.8.horizontal	Thu Jun 30 20:43:58 2005
 ***************
 *** 41,51 ****
   .Op Fl DPRacdfs
   .Op Fl I Ar file
   .Op Fl F Ar rate
   .Op Fl r Ar resolution
   .Op Fl S Ar baudrate
 ! .Op Fl V Op Fl U Ar distance
   .Op Fl a Ar X Ns Op , Ns Ar Y
   .Op Fl C Ar threshold
   .Op Fl m Ar N=M
   .Op Fl w Ar N
   .Op Fl z Ar target
 --- 41,51 ----
   .Op Fl DPRacdfs
   .Op Fl I Ar file
   .Op Fl F Ar rate
   .Op Fl r Ar resolution
   .Op Fl S Ar baudrate
 ! .Op Fl VH Op Fl U Ar distance
   .Op Fl a Ar X Ns Op , Ns Ar Y
   .Op Fl C Ar threshold
   .Op Fl m Ar N=M
   .Op Fl w Ar N
   .Op Fl z Ar target
 ***************
 *** 126,135 ****
 --- 126,147 ----
   msec at most before deciding whether two buttons are being pressed
   simultaneously.
   The default timeout is 100 msec.
   .It Fl F Ar rate
   Set the report rate (reports/sec) of the device if supported.
 + .It Fl H
 + Enable
 + .Dq Horizontal Virtual Scrolling .
 + With this option set, holding the middle mouse
 + button down will cause motion to be interpreted as 
 + horizontal scrolling. 
 + Use the
 + .Fl U
 + option to set the distance the mouse must move before the scrolling mode is
 + activated.  This option may be used with or without the
 + .Fl V
 + option.
   .It Fl I Ar file
   Write the process id of the
   .Nm
   utility in the specified file.
   Without this option, the process id will be stored in
 
 --Boundary-00=_3h+wCs8tCFKRcwM
 Content-Type: text/x-diff;
   charset="iso-2022-jp";
   name="moused.c.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename="moused.c.diff"
 
 *** moused.c	Thu Jun 30 21:38:50 2005
 --- moused.c.horizontal	Thu Jun 30 21:38:03 2005
 ***************
 *** 97,106 ****
 --- 97,107 ----
   #define Emulate3Button	0x0002
   #define ClearDTR	0x0004
   #define ClearRTS	0x0008
   #define NoPnP		0x0010
   #define VirtualScroll	0x0020
 + #define HVirtualScroll	0x0040
   
   #define ID_NONE		0
   #define ID_PORT		1
   #define ID_IF		2
   #define ID_TYPE		4
 ***************
 *** 165,174 ****
 --- 166,176 ----
   #define SCROLL_PREPARE		1
   #define SCROLL_SCROLLING	2
   
   static int	scroll_state;
   static int	scroll_movement;
 + static int	hscroll_movement;
   
   /* local variables */
   
   /* interface (the table must be ordered by MOUSE_IF_XXX in mouse.h) */
   static symtab_t rifs[] = {
 ***************
 *** 521,531 ****
       int retry;
   
       for (i = 0; i < MOUSE_MAXBUTTON; ++i)
   	mstate[i] = &bstate[i];
   
 !     while ((c = getopt(argc, argv, "3C:DE:F:I:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
   	switch(c) {
   
   	case '3':
   	    rodent.flags |= Emulate3Button;
   	    break;
 --- 523,533 ----
       int retry;
   
       for (i = 0; i < MOUSE_MAXBUTTON; ++i)
   	mstate[i] = &bstate[i];
   
 !     while ((c = getopt(argc, argv, "3C:DE:F:HI:PRS:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
   	switch(c) {
   
   	case '3':
   	    rodent.flags |= Emulate3Button;
   	    break;
 ***************
 *** 686,695 ****
 --- 688,701 ----
   		warnx("invalid argument `%s'", optarg);
   		usage();
   	    }
   	    break;
   
 + 	case 'H':
 + 	    rodent.flags |= HVirtualScroll;
 + 	    break;
 + 		 
   	case 'I':
   	    pidfile = optarg;
   	    break;
   
   	case 'P':
 ***************
 *** 991,1001 ****
   		    return;
   	    }
   	    if ((flags = r_protocol(b, &action0)) == 0)
   		continue;
   
 ! 	    if (rodent.flags & VirtualScroll) {
   		/* Allow middle button drags to scroll up and down */
   		if (action0.button == MOUSE_BUTTON2DOWN) {
   		    if (scroll_state == SCROLL_NOTSCROLLING) {
   			scroll_state = SCROLL_PREPARE;
   			debug("PREPARING TO SCROLL");
 --- 997,1007 ----
   		    return;
   	    }
   	    if ((flags = r_protocol(b, &action0)) == 0)
   		continue;
   
 ! 	    if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) {
   		/* Allow middle button drags to scroll up and down */
   		if (action0.button == MOUSE_BUTTON2DOWN) {
   		    if (scroll_state == SCROLL_NOTSCROLLING) {
   			scroll_state = SCROLL_PREPARE;
   			debug("PREPARING TO SCROLL");
 ***************
 *** 1051,1084 ****
   	if (flags) {			/* handler detected action */
   	    r_map(&action, &action2);
   	    debug("activity : buttons 0x%08x  dx %d  dy %d  dz %d",
   		action2.button, action2.dx, action2.dy, action2.dz);
   
 ! 	    if (rodent.flags & VirtualScroll) {
   		/* 
   		 * If *only* the middle button is pressed AND we are moving
   		 * the stick/trackpoint/nipple, scroll!
   		 */
   		if (scroll_state == SCROLL_PREPARE) {
   		    /* Ok, Set we're really scrolling now.... */
   		    if (action2.dy || action2.dx)
   			scroll_state = SCROLL_SCROLLING;
   		}
   		if (scroll_state == SCROLL_SCROLLING) {
 ! 		    scroll_movement += action2.dy;
 ! 		    debug("SCROLL: %d", scroll_movement);
 ! 
 ! 		    if (scroll_movement < -rodent.scrollthreshold) { 
 ! 			/* Scroll down */
 ! 			action2.dz = -1;
 ! 			scroll_movement = 0;
 ! 		    }
 ! 		    else if (scroll_movement > rodent.scrollthreshold) { 
 ! 			/* Scroll up */
 ! 			action2.dz = 1;
 ! 			scroll_movement = 0;
 ! 		    }
   
   		    /* Don't move while scrolling */
   		    action2.dx = action2.dy = 0;
   		}
   	    }
 --- 1057,1105 ----
   	if (flags) {			/* handler detected action */
   	    r_map(&action, &action2);
   	    debug("activity : buttons 0x%08x  dx %d  dy %d  dz %d",
   		action2.button, action2.dx, action2.dy, action2.dz);
   
 ! 	    if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) {
   		/* 
   		 * If *only* the middle button is pressed AND we are moving
   		 * the stick/trackpoint/nipple, scroll!
   		 */
   		if (scroll_state == SCROLL_PREPARE) {
   		    /* Ok, Set we're really scrolling now.... */
   		    if (action2.dy || action2.dx)
   			scroll_state = SCROLL_SCROLLING;
   		}
   		if (scroll_state == SCROLL_SCROLLING) {
 ! 			 if (rodent.flags & VirtualScroll) {
 ! 		    	scroll_movement += action2.dy;
 ! 		    	debug("SCROLL: %d", scroll_movement);
 ! 
 ! 			    if (scroll_movement < -rodent.scrollthreshold) { 
 ! 				/* Scroll down */
 ! 				action2.dz = -1;
 ! 				scroll_movement = 0;
 ! 			    }
 ! 			    else if (scroll_movement > rodent.scrollthreshold) { 
 ! 				/* Scroll up */
 ! 				action2.dz = 1;
 ! 				scroll_movement = 0;
 ! 			    }
 ! 			 }
 ! 			 if (rodent.flags & HVirtualScroll) {
 ! 			 	hscroll_movement += action2.dx;
 ! 		    	debug("HORIZONTAL SCROLL: %d", hscroll_movement);
 ! 
 ! 				 if (hscroll_movement < -rodent.scrollthreshold) {
 ! 					 action2.dz = -2;
 ! 					 hscroll_movement = 0;
 ! 				 }
 ! 				 else if (hscroll_movement > rodent.scrollthreshold) {
 ! 					 action2.dz = 2;
 ! 					 hscroll_movement = 0;
 ! 				 }
 ! 			 }
   
   		    /* Don't move while scrolling */
   		    action2.dx = action2.dy = 0;
   		}
   	    }
 ***************
 *** 1156,1166 ****
   static void
   usage(void)
   {
       fprintf(stderr, "%s\n%s\n%s\n%s\n",
   	"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
 ! 	"              [-V [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]",
   	"              [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]] -p <port>",
   	"       moused [-d] -i <port|if|type|model|all> -p <port>");
       exit(1);
   }
   
 --- 1177,1187 ----
   static void
   usage(void)
   {
       fprintf(stderr, "%s\n%s\n%s\n%s\n",
   	"usage: moused [-DRcdfs] [-I file] [-F rate] [-r resolution] [-S baudrate]",
 ! 	"              [-VH [-U threshold]] [-a X [,Y]] [-C threshold] [-m N=M] [-w N]",
   	"              [-z N] [-t <mousetype>] [-l level] [-3 [-E timeout]] -p <port>",
   	"       moused [-d] -i <port|if|type|model|all> -p <port>");
       exit(1);
   }
   
 
 --Boundary-00=_3h+wCs8tCFKRcwM--
State-Changed-From-To: open->closed 
State-Changed-By: philip 
State-Changed-When: Tue Jul 19 19:31:38 GMT 2005 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=82762 
>Unformatted:
