add wheel emulation for ws(4)
Hi, This port wheel emulation from evdev(4) (suggestion oga@) Comments ? OK ? -- Alexandr Shadchin Index: include/ws-properties.h === RCS file: /cvs/xenocara/driver/xf86-input-ws/include/ws-properties.h,v retrieving revision 1.2 diff -u -p -r1.2 ws-properties.h --- include/ws-properties.h 27 Nov 2009 10:30:08 - 1.2 +++ include/ws-properties.h 19 Nov 2011 15:24:53 - @@ -23,6 +23,18 @@ /* CARD32 */ #define WS_PROP_MIDBUTTON_TIMEOUT WS Pointer Middle Button Timeout +/* Mouse wheel emulation */ +/* BOOL */ +#define WS_PROP_WHEEL WS Pointer Wheel Emulation +/* CARD8, 4 values [x up, x down, y up, y down], 0 to disable a value */ +#define WS_PROP_WHEEL_AXES WS Pointer Wheel Emulation Axes +/* CARD16 */ +#define WS_PROP_WHEEL_INERTIA WS Pointer Wheel Emulation Inertia +/* CARD32 */ +#define WS_PROP_WHEEL_TIMEOUT WS Pointer Wheel Emulation Timeout +/* CARD8, value range 0-32, 0 to always scroll */ +#define WS_PROP_WHEEL_BUTTON WS Pointer Wheel Emulation Button + /* Run-time calibration */ /* CARD32, 4 values [minx, maxx, miny, maxy], or no values for unset */ #define WS_PROP_CALIBRATION WS Pointer Axis Calibration Index: man/ws.man === RCS file: /cvs/xenocara/driver/xf86-input-ws/man/ws.man,v retrieving revision 1.11 diff -u -p -r1.11 ws.man --- man/ws.man 19 Nov 2011 12:28:10 - 1.11 +++ man/ws.man 19 Nov 2011 15:24:53 - @@ -69,6 +69,51 @@ Sets the timeout (in milliseconds) that if two buttons where pressed simultaneously when 3 button emulation is enabled. Default: 50. .TP 4 +.BI Option \*qEmulateWheel\*q \*q boolean \*q +Enable/disable wheel emulation. +Wheel emulation means emulating button press/release events when the mouse +is moved while a specific real button is pressed. +Wheel button events (typically buttons 4 and 5) are usually used for scrolling. +Wheel emulation is useful for getting wheel-like behaviour with trackballs. +It can also be useful for mice with 4 or more buttons but no wheel. +See the description of the +.BR EmulateWheelButton , +.BR EmulateWheelInertia , +.BR EmulateWheelTimeout , +.BR XAxisMapping , +and +.B YAxisMapping +options. +Default: off. +.TP 4 +.BI Option \*qEmulateWheelButton\*q \*q integer \*q +Specifies which button must be held down to enable wheel emulation mode. +While this button is down, X and/or Y pointer movement will generate button +press/release events as specified for the +.B XAxisMapping +and +.B YAxisMapping +settings. +If the button is 0 and +.BR EmulateWheel +is on, any motion of the device is converted into wheel events. +Default:\ 4. +.TP 4 +.BI Option \*qEmulateWheelInertia\*q \*q integer \*q +Specifies how far (in pixels) the pointer must move to generate button +press/release events in wheel emulation mode. +Default:\ 10. +.TP 4 +.BI Option \*qEmulateWheelTimeout\*q \*q integer \*q +Specifies the time in milliseconds the +.BR EmulateWheelButton +must be pressed before wheel emulation is started. +If the +.BR EmulateWheelButton +is released before this timeout, the original button press/release event +is sent. +Default:\ 200. +.TP 4 .BI Option \*qDebugLevel\*q \*q integer \*q This option sets the verbosity level of the driver. It defaults to 0, which means no extra debug output. @@ -107,6 +152,26 @@ clockwise, counter-clockwise, or upside- .BI Option \*qSwapXY\*q \*q boolean \*q swaps the X and Y axis of the input device if set. Default: false. .TP 4 +.BI Option \*qXAxisMapping\*q \*q N1 N2 \*q +Specifies which buttons are mapped to motion in the X direction in wheel +emulation mode. +Button number +.I N1 +is mapped to the negative X axis motion and button number +.I N2 +is mapped to the positive X axis motion. +Default: no mapping. +.TP 4 +.BI Option \*qYAxisMapping\*q \*q N1 N2 \*q +Specifies which buttons are mapped to motion in the Y direction in wheel +emulation mode. +Button number +.I N1 +is mapped to the negative Y axis motion and button number +.I N2 +is mapped to the positive Y axis motion. +Default:\ 4\ 5. +.TP 4 .BI Option \*qZAxisMapping\*q \*q N1 N2 \*q Set the mapping for the Z axis (wheel) motion to buttons. Button number @@ -134,6 +199,21 @@ driver. .TP 7 .BI WS Pointer Middle Button Timeout 1 32-bit positive value (unit: milliseconds) +.TP 7 +.BI WS Pointer Wheel Emulation +1 boolean value (8 bit, 0 or 1). +.TP 7 +.BI WS Pointer Wheel Emulation Axes +4 8-bit values, order X up, X down, Y up, Y down. 0 disables a value. +.TP 7 +.BI WS Pointer Wheel Emulation Button +1 8-bit value, allowed range 0-32, 0 to always scroll. +.TP 7 +.BI WS Pointer Wheel Emulation Inertia +1 16-bit positive value. +.TP 7 +.BI WS Pointer Wheel Emulation Timeout +1 32-bit positive value (unit: milliseconds). .TP 7 .BI WS Pointer Axis Calibration 4 32 bits values, in the order min-x, max-x, min-y, max-y. Index: src/Makefile.am
escape man(1) arguments from glob(3)
Hi, i'm moving this thread here from misc@ because i'm proposing a patch to fix the issue. Jason McIntyre wrote on Sat, Nov 19, 2011 at 08:45:33AM +: On Fri, Nov 18, 2011 at 11:04:12PM -0700, Barry Grumbine wrote: man [ used to give me the test(1) manpage, doesn't anymore. Is that something that needs fixin'? something weird, right enough. the man page is still installed (/usr/share/man/man1/[.1), but man(1) does not pick it up. ingo, could this be anything to do with the code that determines whether pages exist pre-formatted or not, and try to display the more recent of the two? Gah, right, i had this in my TODO file since c2k11, but completely forgot about it: - man(1) does not find man1/[.1 because */[.[1-9n] fails to match however, it did find cat1/[.0 because */[.0 matches that think about a fix... What happens is that the name command line argument to man(1) is used for glob(3) and fnmatch(3) in man.c, internally. So currently, $ man -a \* # one backslash escapes from the shell [ ... quite a lot of pages ... oops ... ] $ man \\* # one eaten by the shell, the other by glob(3) man: no entry for * in the manual. $ man [ # no need to escape from the shell man: no entry for [ in the manual. $ man \\[ TEST(1) [...] Either we have to document that the name argument to man(1) allows shell globbing, while the keyword argument to man -k does not. Do we really want that? I guess not, in particular since the exact meaning of special characters may depend on the suffixes defined in man.conf(5), as you can see above, which is a serious offence against the principle of least surprise. Or we need the patch below. It looks a bit messy, but i think it is safe. Thoughts, OKs? Ingo Index: man.c === RCS file: /cvs/src/usr.bin/man/man.c,v retrieving revision 1.43 diff -u -p -r1.43 man.c --- man.c 7 Jul 2011 04:24:35 - 1.43 +++ man.c 20 Nov 2011 01:02:49 - @@ -435,11 +435,26 @@ manual(char *page, TAG *tag, glob_t *pg) ENTRY *ep, *e_sufp, *e_tag; TAG *missp, *sufp; int anyfound, cnt, found, globres; - char *p, buf[MAXPATHLEN]; + char *p, *escpage, buf[MAXPATHLEN]; anyfound = 0; buf[0] = '*'; + /* Escape the page name for glob(3); consider man [. */ + if ((escpage = malloc(2 * strlen(page) + 1)) == NULL) { + warn(NULL); + cleanup(0); + exit(1); + } + p = page; + cnt = 0; + while (*p != '\0') { + if (strchr(*?[\\]{}, *p)) + escpage[cnt++] = '\\'; + escpage[cnt++] = *p++; + } + escpage[cnt] = '\0'; + /* Expand the search path. */ if (f_all != f_where) { e_tag = tag == NULL ? NULL : TAILQ_FIRST(tag-list); @@ -473,7 +488,7 @@ manual(char *page, TAG *tag, glob_t *pg) /* For each element in the list... */ e_tag = tag == NULL ? NULL : TAILQ_FIRST(tag-list); for (; e_tag != NULL; e_tag = TAILQ_NEXT(e_tag, q)) { - (void)snprintf(buf, sizeof(buf), %s/%s.*, e_tag-s, page); + snprintf(buf, sizeof(buf), %s/%s.*, e_tag-s, escpage); switch (glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT, NULL, pg)) { case (0): @@ -507,7 +522,7 @@ manual(char *page, TAG *tag, glob_t *pg) * We just test for .0 first, it's fast and probably * going to hit. */ - (void)snprintf(buf, sizeof(buf), */%s.0, page); + snprintf(buf, sizeof(buf), */%s.0, escpage); if (!fnmatch(buf, pg-gl_pathv[cnt], 0)) goto next; @@ -515,8 +530,8 @@ manual(char *page, TAG *tag, glob_t *pg) NULL : TAILQ_FIRST(sufp-list); for (found = 0; e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) { - (void)snprintf(buf, -sizeof(buf), */%s%s, page, e_sufp-s); + snprintf(buf, sizeof(buf), + */%s%s, escpage, e_sufp-s); if (!fnmatch(buf, pg-gl_pathv[cnt], 0)) { found = 1; break; @@ -535,8 +550,8 @@ manual(char *page, TAG *tag, glob_t *pg) if (*p == '\0') continue; *p = '\0'; - (void)snprintf(buf, -sizeof(buf), */%s%s, page, e_sufp-s); + snprintf(buf, sizeof(buf), + */%s%s, escpage, e_sufp-s);
Re: escape man(1) arguments from glob(3)
On Sun, Nov 20, 2011 at 02:27:39AM +0100, Ingo Schwarze wrote: Or we need the patch below. It looks a bit messy, but i think it is safe. Thoughts, OKs? Invert the logic. Check with strcspn first, if there is a character that needs quoting. This is not the default case after all. If you do, allocate escpage, quote to it and reassign page. Otherwise, just set escpage to NULL. Joerg