On Wed, Dec 21, 2011 at 03:28:57PM -0800, Jason Gerecke wrote:
> Touch strips as well as the first touch ring are set up to emulate
> mouse wheel events by default. This patch duplicates this behavior
> for the second touch ring, so that it behaves in an identical manner.
> 
> Signed-off-by: Jason Gerecke <[email protected]>

Reviewed-by: Peter Hutterer <[email protected]>

Cheers,
  Peter

> 
> ---
> Changes from v3:
>  * Move after de-duplication patch
>  * Update property docs in wacom-properties.h
>  * Update count of xsetwacom properties
> 
>  include/wacom-properties.h |    4 ++--
>  src/wcmCommon.c            |   14 ++++++++++++--
>  src/wcmConfig.c            |    2 ++
>  src/wcmValidateDevice.c    |    4 ++--
>  src/wcmXCommand.c          |   19 +++++++++++++++----
>  src/xf86WacomDefs.h        |    8 +++++---
>  tools/xsetwacom.c          |   22 +++++++++++++++++++++-
>  7 files changed, 59 insertions(+), 14 deletions(-)
> 
> diff --git a/include/wacom-properties.h b/include/wacom-properties.h
> index 29d5056..0bb84b1 100644
> --- a/include/wacom-properties.h
> +++ b/include/wacom-properties.h
> @@ -46,9 +46,9 @@
>    */
>  #define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"
>  
> -/* 8 bit, 4 values, rel wheel up, rel wheel down, abs wheel up, abs wheel 
> down
> +/* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel 
> down, abs wheel 2 up, abs wheel 2 down
>     OR
> -   Atom, 4 values , rel wheel up, rel wheel down, abs wheel up, abs wheel 
> down
> +   Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel 
> down, abs wheel 2 up, abs wheel 2 down
>   */
>  #define WACOM_PROP_WHEELBUTTONS "Wacom Wheel Buttons"
>  
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 32eb4e4..885b6b9 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -470,6 +470,16 @@ static void sendWheelStripEvents(InputInfoPtr pInfo, 
> const WacomDeviceState* ds,
>                                           priv->wheel_keys[2+1], 
> priv->wheel_keys[3+1], &fakeKey);
>               sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
> num_vals, valuators);
>       }
> +
> +     /* emulate events for right touch ring */
> +     delta = getScrollDelta(ds->abswheel2, priv->oldWheel2, MAX_PAD_RING, 
> AXIS_INVERT);
> +     if (delta && IsPad(priv) && priv->oldProximity == ds->proximity)
> +     {
> +             DBG(10, priv, "Right touch wheel scroll delta = %d\n", delta);
> +             fakeButton = getWheelButton(delta, priv->wheel2up, 
> priv->wheel2dn,
> +                                         priv->wheel_keys[4+1], 
> priv->wheel_keys[5+1], &fakeKey);
> +             sendWheelStripEvent(fakeButton, fakeKey, pInfo, first_val, 
> num_vals, valuators);
> +     }
>  }
>  
>  
> /*****************************************************************************
> @@ -488,7 +498,7 @@ static void sendCommonEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds,
>               wcmSendButtons(pInfo,buttons, first_val, num_vals, valuators);
>  
>       /* emulate wheel/strip events when defined */
> -     if ( ds->relwheel || (ds->abswheel != priv->oldWheel) ||
> +     if ( ds->relwheel || (ds->abswheel != priv->oldWheel) || (ds->abswheel2 
> != priv->oldWheel2) ||
>               ( (ds->stripx - priv->oldStripX) && ds->stripx && 
> priv->oldStripX) || 
>                       ((ds->stripy - priv->oldStripY) && ds->stripy && 
> priv->oldStripY) )
>               sendWheelStripEvents(pInfo, ds, first_val, num_vals, valuators);
> @@ -589,7 +599,7 @@ wcmSendPadEvents(InputInfoPtr pInfo, const 
> WacomDeviceState* ds,
>               if (valuators[i])
>                       break;
>       if (i < num_vals || ds->buttons || ds->relwheel ||
> -         (ds->abswheel != priv->oldWheel))
> +         (ds->abswheel != priv->oldWheel) || (ds->abswheel2 != 
> priv->oldWheel2))
>       {
>               sendCommonEvents(pInfo, ds, first_val, num_vals, valuators);
>  
> diff --git a/src/wcmConfig.c b/src/wcmConfig.c
> index 783966a..5920e11 100644
> --- a/src/wcmConfig.c
> +++ b/src/wcmConfig.c
> @@ -80,6 +80,8 @@ static int wcmAllocate(InputInfoPtr pInfo)
>        * later in wcmParseOptions, when we have IsPad() available */
>       priv->wheelup = 0;                      /* Default absolute wheel up 
> event */
>       priv->wheeldn = 0;                      /* Default absolute wheel down 
> event */
> +     priv->wheel2up = 0;                     /* Default absolute wheel2 up 
> event */
> +     priv->wheel2dn = 0;                     /* Default absolute wheel2 down 
> event */
>       priv->striplup = 4;                     /* Default left strip up event 
> */
>       priv->stripldn = 5;                     /* Default left strip down 
> event */
>       priv->striprup = 4;                     /* Default right strip up event 
> */
> diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
> index 97df312..862e005 100644
> --- a/src/wcmValidateDevice.c
> +++ b/src/wcmValidateDevice.c
> @@ -729,8 +729,8 @@ Bool wcmPreInitParseOptions(InputInfoPtr pInfo, Bool 
> is_primary,
>        */
>       if (IsPad(priv))
>       {
> -             priv->wheelup = 4;
> -             priv->wheeldn = 5;
> +             priv->wheelup = priv->wheel2up = 4;
> +             priv->wheeldn = priv->wheel2dn = 5;
>               set_absolute(pInfo, TRUE);
>       }
>  
> diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> index 82f9b80..40393dc 100644
> --- a/src/wcmXCommand.c
> +++ b/src/wcmXCommand.c
> @@ -237,7 +237,7 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
>       if (IsPad(priv) || IsCursor(priv))
>       {
>               memset(values, 0, sizeof(values));
> -             prop_wheel_buttons = InitWcmAtom(pInfo->dev, 
> WACOM_PROP_WHEELBUTTONS, XA_ATOM, 32, 4, values);
> +             prop_wheel_buttons = InitWcmAtom(pInfo->dev, 
> WACOM_PROP_WHEELBUTTONS, XA_ATOM, 32, 6, values);
>       }
>  
>       values[0] = common->vendor_id;
> @@ -456,6 +456,8 @@ struct wheel_strip_update_t {
>       int *dn1;
>       int *up2;
>       int *dn2;
> +     int *up3;
> +     int *dn3;
>  
>       /* for CARD32 values, points to atom array of atoms to be
>        * monitored.*/
> @@ -477,7 +479,8 @@ static int wcmSetWheelOrStripProperty(DeviceIntPtr dev, 
> Atom property,
>               CARD32 *v32;
>       } values;
>  
> -     if (prop->size != 4)
> +     if ((property == prop_strip_buttons && prop->size != 4) ||
> +         (property == prop_wheel_buttons && prop->size != 6))
>               return BadValue;
>  
>       /* see wcmSetPropertyButtonActions for how this works. The wheel is
> @@ -492,7 +495,9 @@ static int wcmSetWheelOrStripProperty(DeviceIntPtr dev, 
> Atom property,
>                       if (values.v8[0] > WCM_MAX_MOUSE_BUTTONS ||
>                           values.v8[1] > WCM_MAX_MOUSE_BUTTONS ||
>                           values.v8[2] > WCM_MAX_MOUSE_BUTTONS ||
> -                         values.v8[3] > WCM_MAX_MOUSE_BUTTONS)
> +                         values.v8[3] > WCM_MAX_MOUSE_BUTTONS ||
> +                         values.v8[4] > WCM_MAX_MOUSE_BUTTONS ||
> +                         values.v8[5] > WCM_MAX_MOUSE_BUTTONS)
>                               return BadValue;
>  
>                       if (!checkonly) {
> @@ -500,6 +505,8 @@ static int wcmSetWheelOrStripProperty(DeviceIntPtr dev, 
> Atom property,
>                               *wsup->dn1 = values.v8[1];
>                               *wsup->up2 = values.v8[2];
>                               *wsup->dn2 = values.v8[3];
> +                             *wsup->up3 = values.v8[4];
> +                             *wsup->dn3 = values.v8[5];
>                       }
>                       break;
>               case 32:
> @@ -534,10 +541,12 @@ static int wcmSetWheelProperty(DeviceIntPtr dev, Atom 
> property,
>               .dn1 = &priv->reldn,
>               .up2 = &priv->wheelup,
>               .dn2 = &priv->wheeldn,
> +             .up3 = &priv->wheel2up,
> +             .dn3 = &priv->wheel2dn,
>  
>               .handlers = priv->wheel_actions,
>               .keys     = priv->wheel_keys,
> -             .skeys    = 4,
> +             .skeys    = 6,
>       };
>  
>       return wcmSetWheelOrStripProperty(dev, property, prop, checkonly, 
> &wsup);
> @@ -554,6 +563,8 @@ static int wcmSetStripProperty(DeviceIntPtr dev, Atom 
> property,
>               .dn1 = &priv->stripldn,
>               .up2 = &priv->striprup,
>               .dn2 = &priv->striprdn,
> +             .up3 = NULL,
> +             .dn3 = NULL,
>  
>               .handlers = priv->strip_actions,
>               .keys     = priv->strip_keys,
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index e0e58fe..2f3f7b4 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -239,10 +239,12 @@ struct _WacomDeviceRec
>       int reldn;
>       int wheelup;
>       int wheeldn;
> +     int wheel2up;
> +     int wheel2dn;
>       /* keystrokes assigned to wheel events (default is the buttons above).
> -      * Order is relup, reldwn, wheelup, wheeldn. Like 'keys', this array
> -      * is one-indexed */
> -     unsigned wheel_keys[4+1][256];
> +      * Order is relup, reldwn, wheelup, wheeldn, wheel2up, wheel2dn.
> +      * Like 'keys', this array is one-indexed */
> +     unsigned wheel_keys[6+1][256];
>  
>       int striplup;
>       int stripldn;
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index 99ca974..9ab285b 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -301,6 +301,26 @@ static param_t parameters[] =
>               .get_func = get_map,
>       },
>       {
> +             .name = "AbsWheel2Up",
> +             .desc = "X11 event to which absolute wheel up should be mapped. 
> ",
> +             .prop_name = WACOM_PROP_WHEELBUTTONS,
> +             .prop_format = 8,
> +             .prop_offset = 4,
> +             .arg_count = 0,
> +             .set_func = map_actions,
> +             .get_func = get_map,
> +     },
> +     {
> +             .name = "AbsWheel2Down",
> +             .desc = "X11 event to which absolute wheel down should be 
> mapped. ",
> +             .prop_name = WACOM_PROP_WHEELBUTTONS,
> +             .prop_format = 8,
> +             .prop_offset = 5,
> +             .arg_count = 0,
> +             .set_func = map_actions,
> +             .get_func = get_map,
> +     },
> +     {
>               .name = "StripLeftUp",
>               .desc = "X11 event to which left strip up should be mapped. ",
>               .prop_name = WACOM_PROP_STRIPBUTTONS,
> @@ -2669,7 +2689,7 @@ static void test_parameter_number(void)
>        * deprecated them.
>        * Numbers include trailing NULL entry.
>        */
> -     assert(ARRAY_SIZE(parameters) == 34);
> +     assert(ARRAY_SIZE(parameters) == 36);
>       assert(ARRAY_SIZE(deprecated_parameters) == 17);
>  }
>  
> -- 
> 1.7.7.3
> 
> 
> ------------------------------------------------------------------------------
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create 
> new or port existing apps to sell to consumers worldwide. Explore the 
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> http://p.sf.net/sfu/intel-appdev
> _______________________________________________
> Linuxwacom-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
> 

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to