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

Manuel Reimer Manuel.Spam at nurfuerspam.de
Fri Nov 5 12:06:12 PDT 2010


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



More information about the xorg-devel mailing list