Date: Tue, 28 Jun 2005 22:29:34 -0500 (CDT) From: Eric Kjeldergaard <kjelderg@gmail.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/82762: [patch] adding a virtual horizontal scroll feature to moused Message-ID: <200506290329.j5T3TYrN016592@cerberus.cs.und.nodak.edu> Resent-Message-ID: <200506290330.j5T3UVxo019269@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 82762 >Category: bin >Synopsis: [patch] adding a virtual horizontal scroll feature 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 Jun 29 03:30:28 GMT 2005 >Closed-Date: >Last-Modified: >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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506290329.j5T3TYrN016592>