I've finished reviewing this one and have no comments beyond Peter's.

Chris

On Sun, Dec 18, 2011 at 8:56 PM, Peter Hutterer
<peter.hutte...@who-t.net> wrote:
> On Tue, Dec 13, 2011 at 01:59:00PM -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 <killert...@gmail.com>
>
> oh, and just noticed: this breaks the xsetwacom check, the number of
> parameters has changed. please fix this before pushing.
>
> Cheers,
>  Peter
>
>
>> ---
>>  src/wcmCommon.c         |   29 +++++++++++++++++++++++++++--
>>  src/wcmConfig.c         |    2 ++
>>  src/wcmValidateDevice.c |    4 ++--
>>  src/wcmXCommand.c       |   19 +++++++++++++++----
>>  src/xf86WacomDefs.h     |    8 +++++---
>>  tools/xsetwacom.c       |   20 ++++++++++++++++++++
>>  6 files changed, 71 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
>> index 44e74eb..57a1826 100644
>> --- a/src/wcmCommon.c
>> +++ b/src/wcmCommon.c
>> @@ -361,6 +361,31 @@ static int getWheelButton(InputInfoPtr pInfo, const 
>> WacomDeviceState* ds,
>>               *fakeKey = (value > 0) ? priv->wheel_keys[2+1] : 
>> priv->wheel_keys[3+1];
>>       }
>>
>> +     /* emulate events for 2nd absolute wheel when it is a touch ring (on 
>> pad) */
>> +     if ( (ds->abswheel2 != priv->oldWheel2) && IsPad(priv) &&
>> +         (priv->oldProximity == ds->proximity))
>> +     {
>> +             int wrap_delta;
>> +             value = priv->oldWheel2 - ds->abswheel2;
>> +
>> +             /* Wraparound detection. If the distance oldvalue..value is
>> +              * larger than the oldvalue..value considering the
>> +              * wraparound, assume wraparound and readjust */
>> +             if (value < 0)
>> +                     wrap_delta = ((MAX_PAD_RING + 1) + priv->oldWheel2) - 
>> ds->abswheel2;
>> +             else
>> +                     wrap_delta = priv->oldWheel2 - ((MAX_PAD_RING + 1) + 
>> ds->abswheel2);
>> +
>> +             DBG(12, priv, "wrap detection for %d (old %d): %d (wrap %d)\n",
>> +                 ds->abswheel2, priv->oldWheel2, value, wrap_delta);
>> +
>> +             if (abs(wrap_delta) < abs(value))
>> +                     value = wrap_delta;
>> +
>> +             fakeButton = (value > 0) ? priv->wheel2up : priv->wheel2dn;
>> +             *fakeKey = (value > 0) ? priv->wheel_keys[4+1] : 
>> priv->wheel_keys[5+1];
>> +     }
>> +
>>       /* emulate events for left strip */
>>       if ( ds->stripx != priv->oldStripX )
>>       {
>> @@ -437,7 +462,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);
>> @@ -538,7 +563,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 8f06b8d..c91c67a 100644
>> --- a/src/xf86WacomDefs.h
>> +++ b/src/xf86WacomDefs.h
>> @@ -237,10 +237,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..b8b3437 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,
>> --
>> 1.7.7.3
>>
>>
>> ------------------------------------------------------------------------------
>> Systems Optimization Self Assessment
>> Improve efficiency and utilization of IT resources. Drive out cost and
>> improve service delivery. Take 5 minutes to use this Systems Optimization
>> Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/
>> _______________________________________________
>> Linuxwacom-devel mailing list
>> Linuxwacom-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>>
>
> ------------------------------------------------------------------------------
> Learn Windows Azure Live!  Tuesday, Dec 13, 2011
> Microsoft is holding a special Learn Windows Azure training event for
> developers. It will provide a great way to learn Windows Azure and what it
> provides. You can attend the event by watching it streamed LIVE online.
> Learn more at http://p.sf.net/sfu/ms-windowsazure
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to