On Mon, Feb 22, 2010 at 02:36:39PM -0800, Ping Cheng wrote:
> I can not test the patch until next week.  But I do have two comments inline.
> 
> Thanks,
> 
> Ping
> 
> On Sun, Feb 21, 2010 at 7:33 PM, Peter Hutterer
> <[email protected]> wrote:
> > X expects buttons 4-7 to be the scrolling directions, hence if our device
> > has more than 3 buttons, we need to add 4 to the actual number of buttons
> > reported.
> >
> > This affects the internal default button map as well, physical buttons need
> > to be offset by 4 after the first three.
> >
> > Signed-off-by: Peter Hutterer <[email protected]>
> > ---
> > Thanks for the reviews on the first one, this one looks better now,
> > hopefully. AFAICT the linuxwacom commit Ping pointed me to is still buggy
> > though.
> > http://linuxwacom.cvs.sourceforge.net/viewvc/linuxwacom/linuxwacom-dev/src/xdrv/xf86Wacom.c?r1=1.66&r2=1.67
> > When I tried this approach, two of my pad buttons (button 3 and 4) would
> > scroll instead of being actual buttons.
> 
> Oh, really? Are they assigned to button 6 and 7 events by default?

I don't have any specific configurations, so this is the default install
yes. the problem is quite simple, we have priv->button[] as internal button
map from the device (buttons are 0 indexed). we then forward them according
to the configuration, so the mapping for a button is essentially:

button number = priv->button[physical button number]
xf86PostButtonEvent(button number)
(in the server) → logical button = buttonmap[button number]

if we use the default button map, a physical button 4 will map to button 4
will map to logical button 4 - i.e scroll up.
so we need to offset those buttons that they already map to something > 7
when they leave the driver.

> >  src/wcmConfig.c |    5 +++--
> >  src/xf86Wacom.c |    3 +++
> >  2 files changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/wcmConfig.c b/src/wcmConfig.c
> > index af3b95b..5d07fc9 100644
> > --- a/src/wcmConfig.c
> > +++ b/src/wcmConfig.c
> > @@ -99,9 +99,10 @@ static int wcmAllocate(LocalDevicePtr local, char* 
> > type_name, int flag)
> >        priv->nPressCtrl [2] = 100;  /* pressure curve x1 */
> >        priv->nPressCtrl [3] = 100;  /* pressure curve y1 */
> >
> > -       /* Default button and expresskey values */
> > +       /* Default button and expresskey values, offset buttons 4 and higher
> > +        * by the 4 scroll buttons. */
> >        for (i=0; i<WCM_MAX_BUTTONS; i++)
> > -               priv->button[i] = i + 1;
> > +               priv->button[i] = (i < 3) ? i + 1 : i + 5;
> >        priv->nbuttons = WCM_MAX_BUTTONS;               /* Default number of 
> > buttons */
> >        priv->relup = 5;                        /* Default relative wheel up 
> > event */
> > diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
> > index 872e4aa..68df886 100644
> > --- a/src/xf86Wacom.c
> > +++ b/src/xf86Wacom.c
> > @@ -634,6 +634,9 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
> >
> >        nbaxes = priv->naxes;       /* X, Y, Pressure, Tilt-X, Tilt-Y, Wheel 
> > */
> >        nbbuttons = priv->nbuttons; /* Use actual number of buttons, if 
> > possible */
> > +
> > +       /* if more than 3 buttons, offset by the four scroll buttons */
> > +       nbbuttons = (nbbuttons > 3) ? nbbuttons + 4 : nbbuttons;
> 
> Can we assign button 4 to 7 event to a tool of less than 4 buttons
> with this line (I don't have a Linux system to test with before next
> week :)?

yes, see v3 of the patch below. Changes since last version:
- always alloc at least 7 buttons.

From 2294171f5e13a52da28c83573dd9a85c742a3380 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <[email protected]>
Date: Fri, 19 Feb 2010 13:27:32 +1000
Subject: [PATCH] Take scroll buttons into accounts when allocating buttons.

X expects buttons 4-7 to be the scrolling directions, hence if our device
has more than 3 buttons, we need to add 4 to the actual number of buttons
reported. If the device has 3 buttons only, use 7 anyway so we can scroll.

This affects the internal default button map as well, physical buttons need
to be offset by 4 after the first three.

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/wcmConfig.c |    5 +++--
 src/xf86Wacom.c |    4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 7b05681..bb952e1 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -88,9 +88,10 @@ static int wcmAllocate(LocalDevicePtr local, char* 
type_name, int flag)
        priv->nPressCtrl [2] = 100;  /* pressure curve x1 */
        priv->nPressCtrl [3] = 100;  /* pressure curve y1 */
 
-       /* Default button and expresskey values */
+       /* Default button and expresskey values, offset buttons 4 and higher
+        * by the 4 scroll buttons. */
        for (i=0; i<WCM_MAX_BUTTONS; i++)
-               priv->button[i] = i + 1;
+               priv->button[i] = (i < 3) ? i + 1 : i + 5;
 
        priv->nbuttons = WCM_MAX_BUTTONS;               /* Default number of 
buttons */
        priv->relup = 5;                        /* Default relative wheel up 
event */
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index 6a2921a..e52e8e3 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -622,6 +622,10 @@ static int wcmRegisterX11Devices (LocalDevicePtr local)
 
        nbaxes = priv->naxes;       /* X, Y, Pressure, Tilt-X, Tilt-Y, Wheel */
        nbbuttons = priv->nbuttons; /* Use actual number of buttons, if 
possible */
+
+       /* if more than 3 buttons, offset by the four scroll buttons,
+        * otherwise, alloc 7 buttons for scroll wheel. */
+       nbbuttons = (nbbuttons > 3) ? nbbuttons + 4 : 7;
        nbkeys = nbbuttons;         /* Same number of keys since any button may 
be 
                                     * configured as an either mouse button or 
key */
 
-- 
1.6.6.1


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to