[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-input-joystick: Changes to 'upstream-unstable'



 .gitignore         |    2 
 ChangeLog          |   51 ----
 Makefile.am        |   11 
 configure.ac       |   14 +
 man/.gitignore     |    2 
 man/joystick.man   |   96 +++++++-
 src/bsd_jstk.c     |  371 ++++++++++++++++----------------
 src/jstk.c         |  599 ++++++++++++++++++++++++++++-------------------------
 src/jstk.h         |   67 ++---
 src/jstk_axis.c    |  537 ++++++++++++++++++++++++++---------------------
 src/jstk_axis.h    |    1 
 src/jstk_options.c |  326 +++++++++++++++++-----------
 src/jstk_options.h |    9 
 src/linux_jstk.c   |  180 ++++++++-------
 14 files changed, 1254 insertions(+), 1012 deletions(-)

New commits:
commit 13c850fe77b0a9a8a719bedfa1439e96972a730b
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sun Aug 12 13:01:16 2007 +0200

    configure.ac: prepared for 1.2.3 release

diff --git a/configure.ac b/configure.ac
index 76e0e10..88b5315 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-joystick],
-        1.2.2,
+        1.2.3,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-joystick)
 

commit 3651cc8ee6257a5c8f098c603b892aff45ee1e68
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sun Aug 12 12:49:59 2007 +0200

    Added --enable-debug option to configure script
    
    The options --enable-debug and --disable-debug control if additional debugging messages shall be included in the binary, that can made
    visible with the "DebugLevel" option in the xorg.conf. Default: Enabled.

diff --git a/configure.ac b/configure.ac
index f6653bb..76e0e10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,18 @@ AC_ARG_WITH(xorg-module-dir,
                            [[default=$libdir/xorg/modules]]]),
             [moduledir="$withval"],
             [moduledir="$libdir/xorg/modules"])
+
+AC_ARG_ENABLE(debug,
+            AS_HELP_STRING([--enable-debug],
+                           [Enable debugging (default: enabled)]),
+			   [DEBUGGING=$enableval], [DEBUGGING=yes])
+if test "x$DEBUGGING" = xyes; then
+    AC_DEFINE(DEBUG, 1, [Enable debugging code])
+else
+    AC_DEFINE(NDEBUG, 1, [Disable some debugging code])
+fi
+AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])	   
+
 inputdir=${moduledir}/input
 AC_SUBST(inputdir)
 
diff --git a/src/jstk.c b/src/jstk.c
index 4be8fbe..a15985d 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -499,7 +499,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
 #else
     if (xf86SetIntOption(dev->commonOptions, "DebugLevel", 0) != 0) {
-        xf86Msg(X_WARNING, "%s: DebugLevel: Compiled without Debug support!\n", 
+        xf86Msg(X_WARNING, "%s: DebugLevel: Compiled without debugging support!\n", 
                 local->name);
     }
 #endif
diff --git a/src/jstk.h b/src/jstk.h
index 7a9293c..d17f5af 100644
--- a/src/jstk.h
+++ b/src/jstk.h
@@ -37,17 +37,8 @@
     #undef DBG
 #endif
 
-#ifdef DEBUG
-    #undef DEBUG
-#endif
-#define DEBUG 1
-
-/**
- * DEBUG Makros
- **/
-
 #if DEBUG
-    extern int      debug_level;
+    extern int debug_level;
     #define DBG(lvl, f) {if ((lvl) <= debug_level) f;}
 #else
     #define DBG(lvl, f)

commit ca6968c1800ed30aec78b1e474c2b0ede77cd301
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sun Aug 12 00:04:35 2007 +0200

    Explained new key generation features for axes in man page.
    
    Explained the behaviour of accelerated vs relative axes that are mapped to keys. Added example to man page.

diff --git a/man/joystick.man b/man/joystick.man
index 0544d82..0fcda91 100644
--- a/man/joystick.man
+++ b/man/joystick.man
@@ -116,7 +116,7 @@ will be reported as an additional valuator.
 Where
 .I <axis>
 is one of:
-.B X, Y, ZX, ZY
+.B X, Y, ZX, ZY, KEY (see keylow/keyhigh)
 
 and 
 .I <factor>
@@ -128,18 +128,26 @@ Negative values will invert the movement. Default: 1.0
 .TP 7
 .BI "\*qkeyhigh="<keycode>[,<keycode>[,<keycode>[,<keycode>]]]
 When the axis is moved out of the deadzone, a series of keydown events according 
-to the direction of the movement is generated. When the axis is released, keyup events will be generated. You can specify up to 4 keycodes for each direction. The behaviour is not changed by the specified
-.BR mode ,
-the value in
-.B axis
-is ignored.
+to the direction of the movement is generated. When the axis is released, keyup events will be generated. You can specify up to 4 keycodes for each direction. 
 
 .B keylow
 defines the keys to be generated when the axis is moved in negative direction (ie. left or up),
 .B keyhigh
 defines the keys to be generated when the axis is moved in positive direction (ie. right or down).
 
-The keys will be autorepeated according to current keyboard settings.
+If 
+.B mode
+is set to 
+.IR relative :
+The driver will emulate autorepeat according to the current value of the axis. A keydown and subsequent keyup event will be generated in short time intervals. To modify that interval and the autorepeat speed, supply the
+.BI "\*qaxis="[<factor>]KEY \*q
+parameter.
+
+If 
+.B mode
+is set to 
+.IR accelerated :
+One keydown event is generated, when the axis is moved out of the deadzone, the keyup event is generated, when the axis moves back to the deadzone. The keys will be autorepeated according to the keyboard settings.
 
 See special section about key events below.
 .TP 7
@@ -234,14 +242,17 @@ is for the
 .IR "space " key.
 
 .nf
-.BI "  Option  \*qMapAxis1\*q      \*q" "mode=accelerated keylow=100 keyhigh=102" \*q
-.BI "  Option  \*qMapAxis2\*q      \*q" "mode=accelerated keylow=98  keyhigh=104" \*q
+.BI "  Option  \*qMapAxis1\*q      \*q" "mode=relative    keylow=100 keyhigh=102 axis=0.5key" \*q
+.BI "  Option  \*qMapAxis2\*q      \*q" "mode=relative    keylow=98  keyhigh=104" \*q
+.BI "  Option  \*qMapAxis3\*q      \*q" "mode=accelerated keylow=100 keyhigh=102" \*q
+.BI "  Option  \*qMapAxis4\*q      \*q" "mode=accelerated keylow=98  keyhigh=104" \*q
 .fi
-will map the first axis to the arrow keys
+will map the first and third axis to the arrow keys
 .IR left " and " right
-and the second axis to the arrow keys
+and the second and fourth axis to the arrow keys
 .IR up " and " down .
-The keys are generated once when the axis moves out of the deadzone and when it moves back into the deadzone. X.Org will autorepeat those keys according to current keyboard settings.
+The keys for the first two axes will be generated in an interval according to the value of the axis. The autorepeat speed of the first axis will be half the speed of that of the second axis.
+The keys for the third and fourth axis are generated once when the axis moves out of the deadzone and when it moves back into the deadzone. X.Org will autorepeat those keys according to current keyboard settings.
 
 .SH "VALUATORS"
 The driver reports relative cursor movement as valuators 0 and 1.

commit e24622b48e4304a7b8f9de5bdec0e0633821fa7b
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sat Aug 11 23:27:57 2007 +0200

    Key autorepeat added for axes with mode=relative
    
    If axis is set to relative and keylow and keyhigh are assigned, autorepeat for these keys is emulated with a speed relative to the
    value of the axis (keydown and keyup are generated frequently). A factor for this autorepeat speed can be assigned by
    "axis=<factor>key".
    If mode is "accelerated", the axis behaves like a button: only one keydown and one keyup, X does autorepeat for the key.

diff --git a/src/jstk.c b/src/jstk.c
index e4209d0..4be8fbe 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -85,39 +85,6 @@ jstkConvertProc(LocalDevicePtr	local,
 /*
  ***************************************************************************
  *
- * jstkGenerateKeys
- *
- * Generates a series of keydown or keyup events of the specified 
- * KEYSCANCODES
- *
- ***************************************************************************
- */
-static void
-jstkGenerateKeys(LocalDevicePtr local, KEYSCANCODES keys, char pressed)
-{
-    int i;
-    unsigned int k;
-    JoystickDevPtr priv = local->private;
-    if (priv->keys_enabled == FALSE) return;
-
-    for (i=0;i<MAXKEYSPERBUTTON;i++) {
-        if (pressed != 0) 
-            k = keys[i];
-        else k = keys[MAXKEYSPERBUTTON - i - 1];
-
-        if (k != 0) {
-            DBG(2, ErrorF("Generating key %s event with keycode %d\n", 
-                (pressed)?"press":"release", k));
-            xf86PostKeyboardEvent(local->dev, k, pressed);
-        }
-    }
-}
-
-
-
-/*
- ***************************************************************************
- *
  * jstkReadProc --
  *
  * Called when data is available to read from the device
@@ -170,9 +137,10 @@ jstkReadProc(LocalDevicePtr local)
                 break;
 
             case MAPPING_KEY:
-                jstkGenerateKeys(local, 
-                                 priv->button[number].keys, 
-                                 priv->button[number].pressed);
+                if (priv->keys_enabled == TRUE)
+                    jstkGenerateKeys(local->dev, 
+                                     priv->button[number].keys, 
+                                     priv->button[number].pressed);
                 break;
 
             case MAPPING_SPEED_MULTIPLY:
@@ -262,19 +230,25 @@ jstkReadProc(LocalDevicePtr local)
                 } /* switch (priv->axis[number].type) */
                 break; /* case MAPPING_ZY */
 
-            case MAPPING_KEY:
-                if ((priv->axis[number].value > 0) != 
-                    (priv->axis[number].oldvalue > 0))
-                    jstkGenerateKeys(local, 
-                                     priv->axis[number].keys_high,
-                                     (priv->axis[number].value > 0) ? 1 : 0);
-
-                if ((priv->axis[number].value < 0) != 
-                    (priv->axis[number].oldvalue < 0))
-                    jstkGenerateKeys(local,
-                                     priv->axis[number].keys_low,
-                                     (priv->axis[number].value < 0) ? 1:0);
+            case MAPPING_KEY: if (priv->keys_enabled == TRUE) {
+                if (priv->axis[number].type == TYPE_ACCELERATED) {
+                    if ((priv->axis[number].value > 0) != 
+                        (priv->axis[number].oldvalue > 0))
+                        jstkGenerateKeys(local->dev, 
+                                         priv->axis[number].keys_high,
+                                         (priv->axis[number].value > 0) ? 1:0);
+
+                    if ((priv->axis[number].value < 0) != 
+                        (priv->axis[number].oldvalue < 0))
+                        jstkGenerateKeys(local->dev,
+                                         priv->axis[number].keys_low,
+                                         (priv->axis[number].value < 0) ? 1:0);
+                } else if (priv->axis[number].type == TYPE_BYVALUE) {
+                    if (priv->keys_enabled == TRUE)
+                        jstkStartAxisTimer(local, number);
+                }
                 break;
+            }
 
             case MAPPING_NONE:
             default:
diff --git a/src/jstk_axis.c b/src/jstk_axis.c
index 78c4f29..dd2df0f 100644
--- a/src/jstk_axis.c
+++ b/src/jstk_axis.c
@@ -109,6 +109,7 @@ jstkAxisTimer(OsTimerPtr        timer,
             break;
         case MAPPING_ZX:
         case MAPPING_ZY:
+        case MAPPING_KEY:
             axis->subpixel += p2;
             break;
         default:
@@ -128,6 +129,24 @@ jstkAxisTimer(OsTimerPtr        timer,
             case MAPPING_ZY:
                 movezy += (int)axis->subpixel;
                 break;
+
+            case MAPPING_KEY: if ((priv->keys_enabled == TRUE) && 
+                                  (priv->axis[i].type == TYPE_BYVALUE)) {
+                int num;
+                num = abs((int)axis->subpixel);
+                if ((int)axis->subpixel < 0) {
+                    for (i=0; i<num; i++) {
+                        jstkGenerateKeys(device, axis->keys_low, 1);
+                        jstkGenerateKeys(device, axis->keys_low, 0);
+                    }
+                } else {
+                    for (i=0; i<num; i++) {
+                        jstkGenerateKeys(device, axis->keys_high, 1);
+                        jstkGenerateKeys(device, axis->keys_high, 0);
+                    }
+                }
+                break;
+            }
             default:
                 break;
             }
@@ -363,3 +382,34 @@ jstkHandleAbsoluteAxis(LocalDevicePtr device, int number)
     }
 }
 
+
+
+
+/*
+ ***************************************************************************
+ *
+ * jstkGenerateKeys
+ *
+ * Generates a series of keydown or keyup events of the specified 
+ * KEYSCANCODES
+ *
+ ***************************************************************************
+ */
+void
+jstkGenerateKeys(DeviceIntPtr device, KEYSCANCODES keys, char pressed)
+{
+    int i;
+    unsigned int k;
+
+    for (i=0;i<MAXKEYSPERBUTTON;i++) {
+        if (pressed != 0) 
+            k = keys[i];
+        else k = keys[MAXKEYSPERBUTTON - i - 1];
+
+        if (k != 0) {
+            DBG(2, ErrorF("Generating key %s event with keycode %d\n", 
+                (pressed)?"press":"release", k));
+            xf86PostKeyboardEvent(device, k, pressed);
+        }
+    }
+}
diff --git a/src/jstk_axis.h b/src/jstk_axis.h
index cb2b502..4ba45b4 100644
--- a/src/jstk_axis.h
+++ b/src/jstk_axis.h
@@ -27,5 +27,6 @@
 void jstkStartAxisTimer(LocalDevicePtr device, int number);
 void jstkStartButtonAxisTimer(LocalDevicePtr device, int number);
 void jstkHandleAbsoluteAxis(LocalDevicePtr device, int number);
+void jstkGenerateKeys(DeviceIntPtr device, KEYSCANCODES keys, char pressed);
 
 #endif
diff --git a/src/jstk_options.c b/src/jstk_options.c
index 9180c8e..369c5d1 100644
--- a/src/jstk_options.c
+++ b/src/jstk_options.c
@@ -79,7 +79,9 @@ jstkGetAxisMapping(float *value, const char* param, const char* name)
         if (param[0] == '-')
             *value *= -1.0;
     }
-    if (strstr(param, "zx") != NULL)
+    if (strstr(param, "key") != NULL)
+        return MAPPING_KEY;
+    else if (strstr(param, "zx") != NULL)
         return MAPPING_ZX;
     else if (strstr(param, "zy") != NULL)
         return MAPPING_ZY;

commit 38297b06226f115ca4a25557bcb7f8c936424abc
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sat Aug 11 22:32:54 2007 +0200

    Fixed button mapping to an axis needing amplify value.
    
    Button mapping without amplify value like "axis=x" used uninitialized value for amplify,
    making an amplify value mandatory. With no amplify value, 1.0 is assumed.

diff --git a/src/jstk_options.c b/src/jstk_options.c
index 8991813..9180c8e 100644
--- a/src/jstk_options.c
+++ b/src/jstk_options.c
@@ -128,6 +128,7 @@ jstkParseButtonOption(const char* org,
         button->buttonnumber = jstkGetButtonNumberInMap(priv, value);
     } else if (sscanf(param, "axis=%15s", p) == 1) {
         p[15]='\0';
+        fvalue = 1.0f;
         button->mapping = jstkGetAxisMapping(&fvalue, p, name);
         button->amplify = fvalue;
         button->currentspeed = 1.0f;

commit dd396931b76c682f03323566f28b248afb1cb79d
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sat Aug 11 22:22:49 2007 +0200

    Move subpixel movement from global to per axis/button.
    
    Instead of using one global subpixel variable for all axes and buttons, the axis/button
    struct for each axis/button holds it's own subpixel variable. This is neccessary to
    implement mapping of relative axes to keys, which needs to save own "subpixel" values.

diff --git a/src/jstk.c b/src/jstk.c
index 4ec8204..e4209d0 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -451,10 +451,6 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     priv->fd = -1;
     priv->device = NULL;
     priv->devicedata = NULL;
-    priv->x  = 0.0f;
-    priv->y  = 0.0f;
-    priv->zx = 0.0f;
-    priv->zy = 0.0f;
     priv->timer = NULL;
     priv->timerrunning = FALSE;
     priv->mouse_enabled = TRUE;
@@ -473,6 +469,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
         priv->axis[i].currentspeed = 0.0f;
         priv->axis[i].amplify      = 1.0f;
         priv->axis[i].valuator     = -1;
+        priv->axis[i].subpixel     = 0.0f;
         for (j=0; j<MAXKEYSPERBUTTON; j++)
             priv->axis[i].keys_low[j] = priv->axis[i].keys_high[j] = 0;
     }
@@ -481,6 +478,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
         priv->button[i].buttonnumber = 0;
         priv->button[i].mapping      = MAPPING_NONE;
         priv->button[i].currentspeed = 1.0f;
+        priv->button[i].subpixel     = 0.0f;
         for (j=0; j<MAXKEYSPERBUTTON; j++)
             priv->button[i].keys[j] = 0;
     }
diff --git a/src/jstk.h b/src/jstk.h
index 1505c80..7a9293c 100644
--- a/src/jstk.h
+++ b/src/jstk.h
@@ -86,17 +86,19 @@ typedef struct _AXIS {
     float           currentspeed; /* TYPE_ACCELERATED */
     float           previousposition; /* TYPE_ABSOLUTE */
     float           amplify;
+    float           subpixel; /* Pending subpixel movement */
     KEYSCANCODES    keys_low, keys_high;  /* MAPPING_KEY */
 } AXIS;
 
 typedef struct _BUTTON {
     JOYSTICKMAPPING mapping;
-    char pressed;
-    int buttonnumber;    /* MAPPING_BUTTON */
-    float amplify;       /* MAPPING_X/Y/ZX/ZY, 
-                            MAPPING_SPEED_MULTIPLY */
-    float currentspeed;  /* MAPPING_X/Y/ZX/ZY */
-    KEYSCANCODES keys;   /* MAPPING_KEY */
+    char            pressed;
+    int             buttonnumber;    /* MAPPING_BUTTON */
+    float           amplify;       /* MAPPING_X/Y/ZX/ZY, 
+                                      MAPPING_SPEED_MULTIPLY */
+    float           currentspeed;  /* MAPPING_X/Y/ZX/ZY */
+    float           subpixel; /* Pending subpixel movement */
+    KEYSCANCODES    keys;   /* MAPPING_KEY */
 } BUTTON;
 
 typedef struct _JoystickDevRec {
@@ -106,7 +108,6 @@ typedef struct _JoystickDevRec {
 
     OsTimerPtr   timer;       /* Timer for axis movement */
     Bool         timerrunning;
-    float        x,y,zx,zy;   /* Pending subpixel movements */
 
     Bool         mouse_enabled, keys_enabled;
     float        amplify;     /* Global amplifier of axis movement */
diff --git a/src/jstk_axis.c b/src/jstk_axis.c
index b5ddf9e..78c4f29 100644
--- a/src/jstk_axis.c
+++ b/src/jstk_axis.c
@@ -58,7 +58,10 @@ jstkAxisTimer(OsTimerPtr        timer,
 
     int sigstate, i;
     int nexttimer;
+    int movex,movey,movezx,movezy;
+
     nexttimer = 0;
+    movex = movey = movezx = movezy = 0;
 
     sigstate = xf86BlockSIGIO();
 
@@ -101,20 +104,35 @@ jstkAxisTimer(OsTimerPtr        timer,
         /* Apply movement to global amount of pixels to move */
         switch (axis->mapping) {
         case MAPPING_X:
-            priv->x += p1;
-            break;
         case MAPPING_Y:
-            priv->y += p1;
-           break;
-        case MAPPING_ZX:
-            priv->zx += p2;
+            axis->subpixel += p1;
             break;
+        case MAPPING_ZX:
         case MAPPING_ZY:
-            priv->zy += p2;
+            axis->subpixel += p2;
             break;
         default:
             break;
         }
+        if ((int)axis->subpixel != 0) {
+            switch (axis->mapping) {
+            case MAPPING_X:
+                movex += (int)axis->subpixel;
+                break;
+            case MAPPING_Y:
+                movey += (int)axis->subpixel;
+                break;
+            case MAPPING_ZX:
+                movezx += (int)axis->subpixel;
+                break;
+            case MAPPING_ZY:
+                movezy += (int)axis->subpixel;
+                break;
+            default:
+                break;
+            }
+            axis->subpixel = axis->subpixel - (int)axis->subpixel;
+        }
     }
 
     for (i=0; i<MAXBUTTONS; i++) if (priv->button[i].pressed == 1) {
@@ -129,74 +147,88 @@ jstkAxisTimer(OsTimerPtr        timer,
         p1 *= priv->amplify;
         p2 = p1 / 8.0f;
 
-        /* Apply movement to global amount of pixels to move */
+        /* Apply movement to amount of pixels to move */
         switch (priv->button[i].mapping) {
         case MAPPING_X:
-            priv->x += p1;
-            nexttimer = NEXTTIMER;
-            break;
         case MAPPING_Y:
-            priv->y += p1;
+            priv->button[i].subpixel += p1;
             nexttimer = NEXTTIMER;
             break;
         case MAPPING_ZX:
-            priv->zx += p2;
-            nexttimer = NEXTTIMER;
-            break;
         case MAPPING_ZY:
-            priv->zy += p2;
+            priv->button[i].subpixel += p2;
             nexttimer = NEXTTIMER;
             break;
         default:
             break;
         }
+        if ((int)priv->button[i].subpixel != 0) {
+            switch (priv->button[i].mapping) {
+            case MAPPING_X:
+                movex += (int)priv->button[i].subpixel;
+                break;
+            case MAPPING_Y:
+                movey += (int)priv->button[i].subpixel;
+                break;
+            case MAPPING_ZX:
+                movezx += (int)priv->button[i].subpixel;
+                break;
+            case MAPPING_ZY:
+                movezy += (int)priv->button[i].subpixel;
+                break;
+            default:
+                break;
+            }
+            priv->button[i].subpixel -= (int)priv->button[i].subpixel;
+        }
     }
 
     /* Actually move the cursor, if there is enough movement in the buffer */
-    if (((int)priv->x != 0)||((int)priv->y != 0)) {
-        xf86PostMotionEvent(device, 0, 0, 2, (int)priv->x, (int)priv->y);
-        priv->x = priv->x - (int)priv->x;
-        priv->y = priv->y - (int)priv->y;
+    if ((movex != 0)||(movey != 0)) {
+        xf86PostMotionEvent(device, 0, 0, 2, movex, movey);
     }
 
     /* Generate scrolling events */
-    while (priv->zy >= 1.0f) {  /* down */
+    while (movezy >= 1) {  /* down */
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[1], 
                             1, 0, 0);
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[1], 
                             0, 0, 0);
-        priv->zy-=1.0f;
+        movezy -= 1;
     }
-    while (priv->zy <= -1.0f) { /* up */
+    while (movezy <= -1) { /* up */
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[0], 
                             1, 0, 0);
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[0], 
                             0, 0, 0);
-        priv->zy+=1.0f;
+        movezy += 1;
     }
 
-    while (priv->zx >= 1.0f) {  /* right */
+    while (movezx >= 1) {  /* right */
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[3], 
                             1, 0, 0);
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[3], 
                             0, 0, 0);
-        priv->zx-=1.0f;
+        movezx -= 1;
     }
-    while (priv->zx <= -1.0f) { /* left */
+    while (movezx <= -1) { /* left */
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[2], 
                             1, 0, 0);
         xf86PostButtonEvent(device, 0, priv->buttonmap.scrollbutton[2], 
                             0, 0, 0);
-        priv->zx+=1.0f;
+        movezx += 1;
     }
 
-    if (priv->mouse_enabled == FALSE) nexttimer = 0;
-    if (nexttimer == 0) { /* No next timer (no subpixel added), so stop */
+    if ((priv->mouse_enabled == FALSE) &&
+        (priv->keys_enabled == FALSE))
+        nexttimer = 0;
+
+    if (nexttimer == 0) { /* No next timer (no subpixel added), stop */
         priv->timerrunning = FALSE;
-        priv->x  = 0.0f;
-        priv->y  = 0.0f;
-        priv->zx = 0.0f;
-        priv->zy = 0.0f;
+
+        for (i=0; i<MAXBUTTONS; i++) priv->button[i].subpixel = 0.0f;
+        for (i=0; i<MAXAXES; i++) priv->axis[i].subpixel = 0.0f;
+
         DBG(2, ErrorF("Stopping Axis Timer\n"));
     }
     xf86UnblockSIGIO (sigstate);
@@ -224,22 +256,7 @@ jstkStartAxisTimer(LocalDevicePtr device, int number)
 
     pixel = 1;
     if (priv->axis[number].value < 0) pixel = -1;
-    switch (priv->axis[number].mapping) {
-    case MAPPING_X:
-        priv->x += pixel;
-        break;
-    case MAPPING_Y:
-        priv->y += pixel;
-        break;
-    case MAPPING_ZX:
-        priv->zx += pixel;
-        break;
-    case MAPPING_ZY:
-        priv->zy += pixel;
-        break;
-    default:
-        break;
-    }
+    priv->axis[number].subpixel += pixel;
 
     DBG(2, ErrorF("Starting Axis Timer (triggered by axis %d)\n", number));
     priv->timer = TimerSet(
@@ -273,16 +290,10 @@ jstkStartButtonAxisTimer(LocalDevicePtr device, int number)
     if (priv->button[number].amplify < 0) pixel = -1;
     switch (priv->button[number].mapping) {
     case MAPPING_X:
-        priv->x += pixel;
-        break;
     case MAPPING_Y:
-        priv->y += pixel;
-        break;
     case MAPPING_ZX:
-        priv->zx += pixel;
-        break;
     case MAPPING_ZY:
-        priv->zy += pixel;
+        priv->button[number].subpixel += pixel;
         break;
     default:
         break;
diff --git a/src/jstk_options.c b/src/jstk_options.c
index 3e8cb00..8991813 100644
--- a/src/jstk_options.c
+++ b/src/jstk_options.c
@@ -215,10 +215,10 @@ jstkParseAxisOption(const char* org, AXIS *axis, const char *name)
             axis->mapping = jstkGetAxisMapping(&fvalue, p, name);
             if ((axis->type == TYPE_ABSOLUTE) &&
                 ((fvalue <= 1.1)&&(fvalue >= -1.1))) {
-              if (axis->mapping == MAPPING_X)
-                  fvalue *= (int)screenInfo.screens[0]->width;
-              if (axis->mapping == MAPPING_Y)
-                  fvalue *= (int)screenInfo.screens[0]->height;
+                if (axis->mapping == MAPPING_X)
+                    fvalue *= (int)screenInfo.screens[0]->width;
+                if (axis->mapping == MAPPING_Y)
+                    fvalue *= (int)screenInfo.screens[0]->height;
             }
             axis->amplify = fvalue;
             if (axis->mapping == MAPPING_NONE)

commit b685505f1411ffa5f326aa3ba9e5cd5e172e5c5e
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Sat Aug 11 20:47:13 2007 +0200

    Reformatted whole source to 4-space-indents
    
    Large parts of the code were written with 2-space-indents only.
    Upgraded to 4-space indents to improve readability. Sorry for touching almost
    every line. :-S

diff --git a/man/.gitignore b/man/.gitignore
index c858bd6..62796a4 100644
--- a/man/.gitignore
+++ b/man/.gitignore
@@ -1,3 +1,3 @@
 Makefile
 Makefile.in
-joystick.4
+joystick.4*
diff --git a/src/bsd_jstk.c b/src/bsd_jstk.c
index bc0d208..64af0cb 100644
--- a/src/bsd_jstk.c
+++ b/src/bsd_jstk.c
@@ -78,121 +78,116 @@ struct jstk_bsd_hid_data {
 int
 jstkOpenDevice(JoystickDevPtr joystick)
 {
-  int cur_axis;
-  int is_joystick, report_id = 0;
-  int got_something;
-  struct hid_data *d;
-  struct hid_item h;
-  report_desc_t rd;
-  struct jstk_bsd_hid_data *bsddata;
-
-  if ((joystick->fd = open(joystick->device, O_RDWR | O_NDELAY, 0)) < 0) {
-    xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n", joystick->device,
-            strerror(errno));
-    return -1;
-  }
-
-  if ((rd = hid_get_report_desc(joystick->fd)) == 0) {
-    xf86Msg(X_ERROR, "Joystick: hid_get_report_desc failed: %s\n",
-            strerror(errno));
-    close(joystick->fd);
-    joystick->fd = -1;
-    return -1;
-  }
-
-  if (ioctl(joystick->fd, USB_GET_REPORT_ID, &report_id) < 0) {
-    xf86Msg(X_ERROR, "Joystick: ioctl USB_GET_REPORT_ID failed: %s\n",
-            strerror(errno));
-    close(joystick->fd);
-    joystick->fd = -1;
-    return -1;
-  }
-
-  bsddata = (struct jstk_bsd_hid_data*)
-            malloc(sizeof(struct jstk_bsd_hid_data));
-  bsddata->dlen = hid_report_size(rd, hid_input, report_id);
-
-  if ((bsddata->data_buf = malloc(bsddata->dlen)) == NULL) {
-    fprintf(stderr, "error: couldn't malloc %d bytes\n", bsddata->dlen);
-    hid_dispose_report_desc(rd);
-    free(bsddata);
-    close(joystick->fd);
-    joystick->fd = -1;
-    return -1;
-  }
-
-  is_joystick = 0;
-  got_something = 0;
-  cur_axis = 0;
-  bsddata->hats = 0;
-  bsddata->axes = 0;
-  bsddata->buttons = 0;
-
-  for (d = hid_start_parse(rd, 1 << hid_input, report_id);
-       hid_get_item(d, &h); ) {
-      int usage, page;
-
-      page = HID_PAGE(h.usage);
-      usage = HID_USAGE(h.usage);
-
-      is_joystick = is_joystick ||
-        (h.kind == hid_collection &&
-         page == HUP_GENERIC_DESKTOP &&
-         (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD));
-
-      if (h.kind != hid_input)
-        continue;
-
-      if (!is_joystick)
-        continue;
-
-      if (page == HUP_GENERIC_DESKTOP)
-	{
-	  if (usage == HUG_HAT_SWITCH)
-	    {
-              if ((bsddata->hats < MAXAXES) && (bsddata->axes <= MAXAXES-2)) {
-	        got_something = 1;
-	        memcpy(&bsddata->hat_item[bsddata->hats], &h, sizeof(h));
-                bsddata->hats++;
-                bsddata->axes += 2;
-              }
-	    }
-	  else
-	    {
-              if (bsddata->axes < MAXAXES) {
-		got_something = 1;
-		memcpy(&bsddata->axis_item[cur_axis], &h, sizeof(h));
-		cur_axis++;
-                bsddata->axes++;
-	      }
-	    }
-	}
-      else if (page == HUP_BUTTON)
-	{
-          if (bsddata->buttons < MAXBUTTONS) {
-	    got_something = 1;
-            memcpy(&bsddata->button_item[bsddata->buttons], &h, sizeof(h));
-            bsddata->buttons++;
-          }
+    int cur_axis;
+    int is_joystick, report_id = 0;
+    int got_something;
+    struct hid_data *d;
+    struct hid_item h;
+    report_desc_t rd;
+    struct jstk_bsd_hid_data *bsddata;
+
+    if ((joystick->fd = open(joystick->device, O_RDWR | O_NDELAY, 0)) < 0) {
+        xf86Msg(X_ERROR, "Cannot open joystick '%s' (%s)\n", joystick->device,
+                strerror(errno));
+        return -1;
+    }
+
+    if ((rd = hid_get_report_desc(joystick->fd)) == 0) {
+        xf86Msg(X_ERROR, "Joystick: hid_get_report_desc failed: %s\n",
+                strerror(errno));
+        close(joystick->fd);
+        joystick->fd = -1;
+        return -1;
+    }
+
+    if (ioctl(joystick->fd, USB_GET_REPORT_ID, &report_id) < 0) {
+        xf86Msg(X_ERROR, "Joystick: ioctl USB_GET_REPORT_ID failed: %s\n",
+                strerror(errno));
+        close(joystick->fd);
+        joystick->fd = -1;
+        return -1;
+    }
+
+    bsddata = (struct jstk_bsd_hid_data*)
+              malloc(sizeof(struct jstk_bsd_hid_data));
+    bsddata->dlen = hid_report_size(rd, hid_input, report_id);
+
+    if ((bsddata->data_buf = malloc(bsddata->dlen)) == NULL) {
+        fprintf(stderr, "error: couldn't malloc %d bytes\n", bsddata->dlen);
+        hid_dispose_report_desc(rd);
+        free(bsddata);
+        close(joystick->fd);
+        joystick->fd = -1;
+        return -1;
+    }
+
+    is_joystick = 0;
+    got_something = 0;
+    cur_axis = 0;
+    bsddata->hats = 0;
+    bsddata->axes = 0;
+    bsddata->buttons = 0;
+
+    for (d = hid_start_parse(rd, 1 << hid_input, report_id);
+         hid_get_item(d, &h); )
+    {
+        int usage, page;
+
+        page = HID_PAGE(h.usage);
+        usage = HID_USAGE(h.usage);
+
+        is_joystick = is_joystick ||
+                      (h.kind == hid_collection &&
+                       page == HUP_GENERIC_DESKTOP &&
+                       (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD));
+
+        if (h.kind != hid_input)
+            continue;
+
+        if (!is_joystick)
+            continue;
+
+        if (page == HUP_GENERIC_DESKTOP) {
+            if (usage == HUG_HAT_SWITCH) {
+                if ((bsddata->hats < MAXAXES) && (bsddata->axes <= MAXAXES-2)) {
+                    got_something = 1;
+                    memcpy(&bsddata->hat_item[bsddata->hats], &h, sizeof(h));
+                    bsddata->hats++;
+                    bsddata->axes += 2;
+                }
+            } else {
+                if (bsddata->axes < MAXAXES) {
+                    got_something = 1;
+                    memcpy(&bsddata->axis_item[cur_axis], &h, sizeof(h));
+                    cur_axis++;
+                    bsddata->axes++;
+                }
+            }
+        } else if (page == HUP_BUTTON) {
+            if (bsddata->buttons < MAXBUTTONS) {
+                got_something = 1;
+                memcpy(&bsddata->button_item[bsddata->buttons], &h, sizeof(h));
+                bsddata->buttons++;
+            }
 	}
     }
-  hid_end_parse(d);
-
-  if (!got_something) {
-    free(bsddata->data_buf);
-    xf86Msg(X_ERROR, "Joystick: Didn't find any usable axes.\n");
-    free(bsddata);
-    close(joystick->fd);
-    joystick->fd = -1;
-    return -1;
-  }
-
-  bsddata->hotdata = 0;
-  joystick->devicedata = (void*) bsddata;
-  xf86Msg(X_INFO, "Joystick: %d buttons, %d axes\n", 
-      bsddata->buttons, bsddata->axes);
-
-  return joystick->fd;
+    hid_end_parse(d);
+
+    if (!got_something) {
+        free(bsddata->data_buf);
+        xf86Msg(X_ERROR, "Joystick: Didn't find any usable axes.\n");
+        free(bsddata);
+        close(joystick->fd);
+        joystick->fd = -1;
+        return -1;
+    }
+
+    bsddata->hotdata = 0;
+    joystick->devicedata = (void*) bsddata;
+    xf86Msg(X_INFO, "Joystick: %d buttons, %d axes\n", 
+            bsddata->buttons, bsddata->axes);
+
+    return joystick->fd;
 }
 
 
@@ -208,15 +203,15 @@ jstkOpenDevice(JoystickDevPtr joystick)
 void
 jstkCloseDevice(JoystickDevPtr joystick)
 {
-  if ((joystick->fd >= 0)) {
-    xf86CloseSerial(joystick->fd);
-    joystick->fd = -1;
-  }
-  if (joystick->devicedata != NULL) {
-    if ((((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf) != NULL)
-      free(((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf);
-    free(joystick->devicedata);
-  }
+    if ((joystick->fd >= 0)) {
+      xf86CloseSerial(joystick->fd);
+      joystick->fd = -1;
+    }
+    if (joystick->devicedata != NULL) {
+        if (((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf)
+            free(((struct jstk_bsd_hid_data*)joystick->devicedata)->data_buf);



Reply to: