[PATCH] Fix for bug Bug 13040 'Make the "cursor" option in xorg.conf useful'

Jesse Adkins jesserayadkins at gmail.com
Fri Nov 5 18:07:19 PDT 2010


Updating the ChangeLog isn't necessary, since the driver shouldn't
have one. It's no big deal, since a future patch can remove the
ChangeLog.

Wouldn't autodetection result in the wrong value being printed to the
log (since I assume the read comes later) if autodetection finds
there's a stylus? I notice that there is a log message right below
where your patch shuts off autodetection in xf86HypInit where the
device type is reported. The device would be wrong if the
autodetection hasn't been carried out...

Is it possible that the autodetection could be done in xf86HypInit? Am
I wrong in this?

On Fri, Nov 5, 2010 at 12:06 PM, Manuel Reimer
<Manuel.Spam at nurfuerspam.de> wrote:
> This patch fixes
> https://bugs.freedesktop.org/show_bug.cgi?id=13040
> I wrote this patch some time ago, but now I fixed it to work well with
> latest git version of the driver.
>
> I think there is some more ugliness in this driver. It would be nice if
> someone could contact me to help with solving another problem.
>
> ---
>  ChangeLog          |    6 ++++++
>  src/xf86HyperPen.c |   20 ++++++++++++--------
>  2 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 2b5bb16..b40ef44 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2010-11-05  Manuel Reimer <manuel.reimer at gmx.de>
> +
> +       * src/xf86HyperPen.c:
> +       Made it possible to disable cursor auto detect by setting
> +       "CURSOR" in xorg.conf
> +
>  2006-04-06  Adam Jackson  <ajax at freedesktop.org>
>
>        * configure.ac:
> diff --git a/src/xf86HyperPen.c b/src/xf86HyperPen.c
> index 3920a04..abf1bbc 100644
> --- a/src/xf86HyperPen.c
> +++ b/src/xf86HyperPen.c
> @@ -129,8 +129,6 @@ static int debug_level = INI_DEBUG_LEVEL;
>  #define INVY_FLAG              8
>  #define BAUD_19200_FLAG                16
>
> -int stylus;
> -
>  typedef struct
>  {
>        char    *hypDevice;     /* device file name */
> @@ -157,6 +155,7 @@ typedef struct
>        int     modelid;        /* model id */
>        int     PT;             /* pressure threshold */
>         int     AutoPT;         /* automatically set PT*/
> +        int     AutoCursor;         /* auto detect used cursor*/
>         int     PMax;           /* maximum pressure read from tablet */
>        unsigned char hypData[7];       /* data read on the device */
>  } HyperPenDeviceRec, *HyperPenDevicePtr;
> @@ -293,7 +292,7 @@ xf86HypReadInput(LocalDevicePtr local)
>  {
>     HyperPenDevicePtr  priv = (HyperPenDevicePtr) local->private;
>     int                        len, loop;
> -    int                        is_absolute;
> +    int                        is_absolute = 0;
>     int f_keys, f_key, tip;
>     int x, y, bx, by, barrel, barrel1, prox, pressure, button, push;
>     int hw_pressure;
> @@ -334,10 +333,13 @@ xf86HypReadInput(LocalDevicePtr local)
>            f_keys = (priv->hypData[0] & F_BIT);
>            pressure = (int) priv->hypData[6] + (((int) priv->hypData[5] &
> ZMASK_BIT) << 3);
>
> -           if ((tip==0) && (button==0) && (pressure>2) && (pressure !=
> 1022)) {priv->flags |= STYLUS_FLAG; stylus=1;} else
> -           if ((tip==0) && (button==0) && (pressure==0)) {priv->flags &=
> ~STYLUS_FLAG; stylus=0; pressure = 1019;}
> -
> -is_absolute = stylus;
> +      // If we are allowed, we try to auto-detect the used cursor
> +      if (priv->AutoCursor) {
> +          if ((tip==0) && (button==0) && (pressure>2) && (pressure !=
> 1022)) {priv->flags |= STYLUS_FLAG; is_absolute=1;} else
> +          if ((tip==0) && (button==0) && (pressure==0)) {priv->flags &=
> ~STYLUS_FLAG; is_absolute=0; pressure = 1019;}
> +      }
> +      else
> +          is_absolute = (priv->flags & STYLUS_FLAG);
>
>        x = priv->hypData[1] + (priv->hypData[2] << 7) + ((priv->hypData[5] &
> XAXIS_BITS) << 14);
>        y = priv->hypData[3] + (priv->hypData[4] << 7) + ((priv->hypData[5] &
> YAXIS_BITS) << 12);
> @@ -991,7 +993,6 @@ xf86HypAllocate(void)
>     priv->flags = ABSOLUTE_FLAG;  /* various flags -- default abs format */
>     priv->hypIndex = 0;           /* number of bytes read */
>     priv->hypRes = 0;            /* resolution */
> -    stylus=0;
>
>     return local;
>  }
> @@ -1049,6 +1050,7 @@ xf86HypInit(InputDriverPtr        drv,
>
>     local->name = dev->identifier;
>     priv->AutoPT = 1;
> +    priv->AutoCursor = 1;
>
>     /* Serial Device is mandatory */
>     priv->hypDevice = xf86FindOptionValue(local->options, "Device");
> @@ -1093,9 +1095,11 @@ xf86HypInit(InputDriverPtr       drv,
>
>     if (s && (xf86NameCmp(s, "stylus") == 0)) {
>        priv->flags = priv->flags | STYLUS_FLAG;
> +       priv->AutoCursor = 0; // deactivate cursor auto detection
>     }
>     else if (s && (xf86NameCmp(s, "puck") == 0)) {
>        priv->flags = priv->flags & ~STYLUS_FLAG;
> +       priv->AutoCursor = 0; // deactivate cursor auto detection
>     }
>     else if (s) {
>        xf86Msg(X_ERROR, "%s: invalid Cursor (should be stylus or puck). "
> --
> 1.7.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>


More information about the xorg-devel mailing list