From owner-freebsd-bugs@FreeBSD.ORG Fri Jan 25 06:50:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DB26F659 for ; Fri, 25 Jan 2013 06:50:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id BF562117 for ; Fri, 25 Jan 2013 06:50:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r0P6o0Sh016286 for ; Fri, 25 Jan 2013 06:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r0P6o0Lm016284; Fri, 25 Jan 2013 06:50:00 GMT (envelope-from gnats) Resent-Date: Fri, 25 Jan 2013 06:50:00 GMT Resent-Message-Id: <201301250650.r0P6o0Lm016284@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Wayne Galen Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 04FE6640 for ; Fri, 25 Jan 2013 06:48:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id EA45710B for ; Fri, 25 Jan 2013 06:48:24 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r0P6mOp4089246 for ; Fri, 25 Jan 2013 06:48:24 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r0P6mOJ5089245; Fri, 25 Jan 2013 06:48:24 GMT (envelope-from nobody) Message-Id: <201301250648.r0P6mOJ5089245@red.freebsd.org> Date: Fri, 25 Jan 2013 06:48:24 GMT From: Wayne Galen To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/175556: [PATCH] moused(8) virtual scrolling on alternate buttons X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2013 06:50:00 -0000 >Number: 175556 >Category: bin >Synopsis: [PATCH] moused(8) virtual scrolling on alternate buttons >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: Fri Jan 25 06:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Wayne Galen >Release: 9.1-RELEASE >Organization: N/A >Environment: >Description: Attached is a patch that adds a new flag to moused(8), -b. This option allows the user to choose a button other than MOUSE_BUTTON3 to trigger virtual scrolling. The manpage has also been updated to reflect the change. >How-To-Repeat: >Fix: Patch attached with submission follows: diff -rupN moused.orig/moused.8 moused/moused.8 --- moused.orig/moused.8 2013-01-24 22:16:17.994604268 -0800 +++ moused/moused.8 2013-01-24 22:30:13.674634226 -0800 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 15, 2008 +.Dd Jan 24, 2011 .Dt MOUSED 8 .Os .Sh NAME @@ -43,7 +43,7 @@ .Op Fl F Ar rate .Op Fl r Ar resolution .Op Fl S Ar baudrate -.Op Fl VH Op Fl U Ar distance Fl L Ar distance +.Op Fl VH Op Fl U Ar distance Fl L Ar distance Fl b Ar vscrollbtn .Op Fl A Ar exp Ns Op , Ns Ar offset .Op Fl a Ar X Ns Op , Ns Ar Y .Op Fl C Ar threshold @@ -230,6 +230,15 @@ mode is activated. The default .Ar distance is 3 pixels. +.It Fl b Ar vscrollbutton +When +.Dq Virtual Scrolling +is enabled, the +.Fl b +option can be used to set the button used to trigger scrolling. +The default +.Ar vscrollbutton +is 3. .It Fl A Ar exp Ns Op , Ns Ar offset Apply exponential (dynamic) acceleration to mouse movements: the faster you move the mouse, the more it will be accelerated. @@ -824,6 +833,10 @@ This manual page was written by .An Mike Pritchard Aq mpp@FreeBSD.org . The command and manual page have since been updated by .An Kazutaka Yokota Aq yokota@FreeBSD.org . +The +.Fl b +flag was added by +.An Wayne Galen Aq wayne.galen@gmail.com . .Sh CAVEATS Many pad devices behave as if the first (left) button were pressed if the user diff -rupN moused.orig/moused.c moused/moused.c --- moused.orig/moused.c 2013-01-24 22:15:58.934600200 -0800 +++ moused/moused.c 2013-01-24 22:28:16.114623671 -0800 @@ -29,6 +29,8 @@ ** OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** + ** Modified on 1/24/13 by Wayne Galen: + ** added -b flag so virtual scroll can be on any button **/ /** @@ -396,6 +398,7 @@ static unsigned short rodentcflags[] = static struct rodentparam { int flags; + int vscrollbtn; const char *portname; /* /dev/XXX */ int rtype; /* MOUSE_PROTO_XXX */ int level; /* operation level: 0 or greater */ @@ -423,6 +426,7 @@ static struct rodentparam { int scrollspeed; /* Movement distance to rate of scrolling */ } rodent = { .flags = 0, + .vscrollbtn = MOUSE_BUTTON3DOWN, .portname = NULL, .rtype = MOUSE_PROTO_UNKNOWN, .level = -1, @@ -576,7 +580,7 @@ main(int argc, char *argv[]) for (i = 0; i < MOUSE_MAXBUTTON; ++i) mstate[i] = &bstate[i]; - while ((c = getopt(argc, argv, "3A:C:DE:F:HI:L:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1) + while ((c = getopt(argc, argv, "3A:C:DE:F:HI:L:PRS:T:VUb:a:cdfhi:l:m:p:r:st:w:z:")) != -1) switch(c) { case '3': @@ -835,7 +839,16 @@ main(int argc, char *argv[]) usage(); } break; - + case 'b': + rodent.vscrollbtn = atoi(optarg); + if (rodent.vscrollbtn > MOUSE_MAXBUTTON || rodent.vscrollbtn < 1) { + warnx("invalid button number `%s'", optarg); + usage(); + } + else { + rodent.vscrollbtn = 1 << (rodent.vscrollbtn - 1); //turn the button number into a bitmask ala mouse.h + } + break; case 'h': case '?': default: @@ -1116,23 +1129,23 @@ moused(void) continue; if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) { - /* Allow middle button drags to scroll up and down */ - if (action0.button == MOUSE_BUTTON2DOWN) { + /* Allow vscroll button drags to scroll up and down */ + if (action0.button == rodent.vscrollbtn) { if (scroll_state == SCROLL_NOTSCROLLING) { scroll_state = SCROLL_PREPARE; scroll_movement = hscroll_movement = 0; debug("PREPARING TO SCROLL"); } - debug("[BUTTON2] flags:%08x buttons:%08x obuttons:%08x", + debug("[VSCROLLBTN] flags:%08x buttons:%08x obuttons:%08x", action.flags, action.button, action.obutton); } else { - debug("[NOTBUTTON2] flags:%08x buttons:%08x obuttons:%08x", + debug("[NOTVSCROLLBTN] flags:%08x buttons:%08x obuttons:%08x", action.flags, action.button, action.obutton); /* This isn't a middle button down... move along... */ if (scroll_state == SCROLL_SCROLLING) { /* - * We were scrolling, someone let go of button 2. + * We were scrolling, someone let go of the button. * Now turn autoscroll off. */ scroll_state = SCROLL_NOTSCROLLING; @@ -1146,11 +1159,11 @@ moused(void) A(newaction.button & MOUSE_BUTTON1DOWN, action0.button & MOUSE_BUTTON3DOWN)); - /* Send middle down */ - newaction.button = MOUSE_BUTTON2DOWN; + /* Send button down */ + newaction.button = rodent.vscrollbtn; r_click(&newaction); - /* Send middle up */ + /* Send button up */ r_timestamp(&newaction); newaction.obutton = newaction.button; newaction.button = action0.button; @@ -1178,11 +1191,11 @@ moused(void) if ((rodent.flags & VirtualScroll) || (rodent.flags & HVirtualScroll)) { /* - * If *only* the middle button is pressed AND we are moving + * If *only* the vscroll button is pressed AND we are moving * the stick/trackpoint/nipple, scroll! */ if (scroll_state == SCROLL_PREPARE) { - /* Middle button down, waiting for movement threshold */ + /* VScroll button down, waiting for movement threshold */ if (action2.dy || action2.dx) { if (rodent.flags & VirtualScroll) { scroll_movement += action2.dy; @@ -1371,9 +1384,9 @@ usage(void) { fprintf(stderr, "%s\n%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 ] [-l level] [-3 [-E timeout]]", - " [-T distance[,time[,after]]] -p ", + " [-VH [-U threshold][-b vscrollbtn] [-a X[,Y]] [-C threshold]", + " [-m N=M] [-w N] [-z N] [-t ] [-l level]", + " [-3 [-E timeout]] [-T distance[,time[,after]]] -p ", " moused [-d] -i -p "); exit(1); } >Release-Note: >Audit-Trail: >Unformatted: