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

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



 .gitignore                  |   78 +++++--
 COPYING                     |   49 +++-
 Makefile.am                 |   10 
 config/50-joystick-all.conf |   51 ++++
 config/Makefile.am          |    2 
 configure.ac                |  126 +++++------
 include/Makefile.am         |    2 
 man/Makefile.am             |   62 +----
 man/joystick.man            |   47 +---
 src/Makefile.am             |    3 
 src/backend_bsd.c           |    1 
 src/backend_evdev.c         |    1 
 src/backend_joystick.c      |    1 
 src/jstk.c                  |  319 +++++++++--------------------
 src/jstk.h                  |   13 -
 src/jstk_axis.c             |   15 -
 src/jstk_axis.h             |    8 
 src/jstk_key.c              |  482 ++++++++++----------------------------------
 src/jstk_key.h              |    9 
 src/jstk_options.c          |    5 
 src/jstk_properties.c       |    7 
 21 files changed, 505 insertions(+), 786 deletions(-)

New commits:
commit bd6c54fe672a913334bfba1ca5dc0f2e0f1f1152
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Wed Apr 20 20:55:24 2011 +0200

    joystick 1.6.0
    
    Signed-off-by: Sascha Hlusiak <saschahlusiak@arcor.de>

diff --git a/configure.ac b/configure.ac
index 563b15c..73afa9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-input-joystick],
-        [1.5.99.901],
+        [1.6.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-input-joystick])
 AC_CONFIG_SRCDIR([Makefile.am])

commit f1b8ef560049f1bb1bca9caa12c1529c9f992a09
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Wed Apr 20 20:48:28 2011 +0200

    Updated man page to reflect latest changes

diff --git a/man/joystick.man b/man/joystick.man
index 97e3ba3..da92ceb 100644
--- a/man/joystick.man
+++ b/man/joystick.man
@@ -4,14 +4,19 @@
 .SH NAME
 joystick \- Joystick input driver
 .SH SYNOPSIS
+Snipped for xorg.conf.d(5):
+
 .nf
-.B "Section \*qInputDevice\*q"
-.BI "  Identifier \*q" devname \*q
-.B  "  Driver \*qjoystick\*q"
-.BI "  Option \*qDevice\*q   \*q" devpath \*q
+.B "Section \*qInputClass\*q"
+.BI "  Identifier \*q" joystick-all \*q
+.BI  "  Driver \*q" joystick \*q
+.BI "  Option \*qMatchIsJoystick\*q   \*q" on \*q
+.BI "  Option \*qMatchDevicePath \*q" /dev/input/event* \*q
 \ \ ...
 .B EndSection
 .fi
+
+
 .SH DESCRIPTION
 .B joystick
 is an __xservername__ input driver for Joysticks. There are 3 backends available that are used in the following order, if support was found:
@@ -314,33 +319,21 @@ The keys for the first two axes will be generated in an interval according to th
 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 "NOTES"
-The driver does not do hotplugging on it's own. The joystick needs to be plugged in when the driver is loaded.
-If the joystick is unplugged, the device will be automatically deactivated.
-.P
-There is an example hal policy in
+Configuration through
+.I InputClass
+sections is recommended in X servers 1.8 and later. See xorg.conf.d(5) for more details. An example xorg.conf.d snipped is provided in 
+.I ${sourcecode}/config/50-joystick-all.conf
+
+Configuration through hal fdi files is recommended in X servers 1.5,
+1.6 and 1.7. An example hal policy file is still provided in 
 .I ${sourcecode}/config/50-x11-input-joystick.fdi
-which will take care of hotplugging. Place it in
-.I /etc/hal/fdi/policy 
-and customize it to your needs. Pass custom options to the driver using x11_options properties. This requires xorg-server-1.5 or 
-higher.
-.P
-Make sure you add the 
-.I \*qSendCoreEvents\*q
-keyword to the device entry of your
-.B ServerLayout
-section of the 
-.I xorg.conf
-file, otherwise the device won't report core pointer and core key events.
-
-Example: 
-.nf
-.BI "    InputDevice     " "\*qJoystick1\*q     \*qSendCoreEvents\*q"
-.fi
+to be placed in
+.IR /etc/hal/fdi/policy .
 
 
 .SH "SEE ALSO"
-__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__), xmodmap(1)
+__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorg.conf.d(5), Xserver(__appmansuffix__), X(__miscmansuffix__), xmodmap(1)
 .SH AUTHORS
-Sascha Hlusiak (2007-2009),
+Sascha Hlusiak (2007-2011),
 .fi
 Frederic Lepied (1995-1999)

commit aa78e01edabb27d1b5dcd4ffe2be32878a45e342
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Wed Apr 20 20:47:33 2011 +0200

    Added xorg.conf.d example snipped
    
    Not installed by default, left for distributors.
    
    Copy 50-joystick-all.conf to /etc/X11/xorg.conf.d/ and modify to your needs.

diff --git a/config/50-joystick-all.conf b/config/50-joystick-all.conf
new file mode 100644
index 0000000..ee03dd5
--- /dev/null
+++ b/config/50-joystick-all.conf
@@ -0,0 +1,51 @@
+# Example xorg.conf.d snippet that assigns the joystick driver
+# to all joysticks. See xorg.conf.d(5) for more information on
+# InputClass.
+# DO NOT EDIT THIS FILE, your distribution will likely overwrite
+# it when updating. Copy (and rename) this file into
+# /etc/X11/xorg.conf.d first.
+# Additional options may be added in the form of
+#   Option "OptionName" "value"
+#
+
+Section "InputClass"
+	Identifier "joystick-all"
+
+	# UNCOMMENT TO ENABLE HOTPLUGGING OF JOYSTICKS
+#	Driver "joystick"
+#	MatchIsJoystick "on"
+#	MatchDevicePath "/dev/input/event*"
+
+	Option "MapButton1" "button=1"
+	Option "MapButton2" "button=2"
+	Option "MapButton3" "button=3"
+
+	Option "MapAxis1"   "mode=relative axis=+1x deadzone=5000"
+	Option "MapAxis2"   "mode=relative axis=+1y deadzone=5000"
+	Option "MapAxis3"   "mode=relative axis=+1zx deadzone=5000"
+	Option "MapAxis4"   "mode=relative axis=+1zy deadzone=5000"
+	Option "MapAxis5"   "mode=accelerated axis=+1x deadzone=5000"
+	Option "MapAxis6"   "mode=accelerated axis=+1y deadzone=5000"
+
+        
+	# Map Alt+Tab to button #4
+#	Option "MapButton4" "key=64+23"
+
+	# Button 8 will slow down all movement to factor 0.3
+#	Option "MapButton8" "amplify=0.3"
+
+	# Button 9 will disable all events except button #9 itself
+#	Option "MapButton9" "disable-all"
+
+	# Map button #10 to Space
+#	Option "MapButton10" "key=65"
+
+	# Map axis #1 and #2 to the keycodes for Left, Right, Up and Down rather 
+	# than pointer movement
+#	Option "MapAxis1" "mode=accelerated keylow=113 keyhigh=114"
+#	Option "MapAxis2" "mode=accelerated keylow=111 keyhigh=116"
+
+#	Option "XkbLayout" "de"
+#	Option "XkbVariant" "nodeadkeys"
+#	Option "AutoRepeat" "400 25"
+EndSection
diff --git a/config/Makefile.am b/config/Makefile.am
index c96ffeb..2aef071 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = 50-x11-input-joystick.fdi
+EXTRA_DIST = 50-x11-input-joystick.fdi 50-joystick-all.conf

commit 29d3745e73d266db173828f40231cb78ec1c383a
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Wed Apr 20 19:48:28 2011 +0200

    Revert "config: fdi file must be installed in $(datadir)/hal/fdi/policy/20thirdparty"
    
    The fdi file was never meant to be installed by default but exists merely as an
    example and documentation for distributors who may decide to ship it by default or
    install it in share/doc/...
    
    This reverts commit 1d67a2da26fa3ba0b8f5498da89c01aeaa551515.

diff --git a/config/Makefile.am b/config/Makefile.am
index 776308f..c96ffeb 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -1,3 +1 @@
-fdidir = $(datadir)/hal/fdi/policy/20thirdparty
-dist_fdi_DATA = 50-x11-input-joystick.fdi
-
+EXTRA_DIST = 50-x11-input-joystick.fdi

commit 4358209e7e4383b4ebdec93cc116bb1c21d373a7
Author: Sascha Hlusiak <saschahlusiak@arcor.de>
Date:   Wed Apr 20 19:33:10 2011 +0200

    Free pInfo->private only once to fix server crash on unplug (bug #35391)
    
    The hotplugged keyboard device and the main device share the same pInfo->private data
    and the same jstkCoreUnInit, so the data is freed twice. Furthermore, since the keyboard
    device will delete itself, we must not delete it from within the deletion of the main device.
    
    Freeing pInfo->private is done by the main device, hopefully done independently of the order
    in which the two devices will be removed by the server.
    
    Should fix bug #35391

diff --git a/src/jstk.c b/src/jstk.c
index 9796a46..ec6b79a 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -611,6 +611,10 @@ SetupProc_fail:
  * jstkCoreUnInit --
  *
  * Called when a device is unplugged and needs to be removed
+ * This is a bit tricky, because the keyboard device and the main device
+ * share the same private data, which must be freed only once, which is done
+ * by the main device.
+ * 
  *
  ***************************************************************************
  */
@@ -620,15 +624,24 @@ jstkCoreUnInit(InputDriverPtr    drv,
                InputInfoPtr      pInfo,
                int               flags)
 {
-    JoystickDevPtr device = (JoystickDevPtr) pInfo->private;
-
-    if (device->keyboard_device != NULL)
-    {
-        xf86DisableDevice(device->keyboard_device->dev, TRUE);
-        device->keyboard_device = NULL;
+    if (pInfo->private) {
+	JoystickDevPtr priv = (JoystickDevPtr) pInfo->private;
+	if (priv->keyboard_device == pInfo) {
+	    /* this is the keyboard device */
+	    /* Unlink from private data to notify that the 
+	     * keyboard device is no more, but don't free */
+	    priv->keyboard_device = NULL;
+	} else {
+	    /* freeing main device
+	       if keyboard still exists, notify keyboard device that it's
+	       private data is gone */
+	    if (priv->keyboard_device)
+		priv->keyboard_device->private = NULL;
+	    
+	    free (priv);
+	}
     }
 
-    free (device);
     pInfo->private = NULL;
     xf86DeleteInput(pInfo, 0);
 }

commit 3f03fa76f8fb152210c6ed80191f34e428af2c00
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Apr 6 21:02:49 2011 +1000

    joystick 1.5.99.901
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index 04b2f44..563b15c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-input-joystick],
-        [1.5.99],
+        [1.5.99.901],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-input-joystick])
 AC_CONFIG_SRCDIR([Makefile.am])

commit 8c7ad54d6d869bb4202aee8408c72ed72bf929a7
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Dec 14 17:00:28 2010 +1000

    Support input ABI 12
    
    This commit adds support for input ABI 12, consisting of a number of
    changes:
    - requires an X server with an ABI of 12
    - valuators have a per-mode setting
    - new PreInit prototype.
    
    Because of the new PreInit prototype, the hotplug system has been switched
    around too (should have probably been done in a separate commit before,
    but...).
    
    The old hotplug mechanism added a separate ModuleInfoRec for the keyboard
    part of the driver. This isn't feasable for InputClass configurations, the
    driver part may get overwritten.
    
    On entering the driver, after checking a few default values, hotplug the
    keyboard device (wacom-style) and let it initialize. Because NIDR calls
    DEVICE_INIT and DEVICE_ON the keyboard must initialise the private pointer
    and pass it back to the original device.
    
    Call order is:
    NewInputDeviceRequest
     - jstkCorePreInit
       - jstkKeyboardHotplug
         - NewInputDeviceRequest
           - jstkCorePreInit
             immediately return jstkKeyboardPreInit()
           - keyboard DEVICE_INIT
           - keyboard DEVICE_ON
         return keyboard device
       - copy keyboard->priv to joystick->priv
       - finish jstkCorePreInit as normal
       - joystick DEVICE_INIT
       - joystick DEVICE_ON
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Trevor Woerner <twoerner@gmail.com>

diff --git a/configure.ac b/configure.ac
index 6da920b..04b2f44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ XORG_DRIVER_CHECK_EXT(XINPUT, inputproto)
 XORG_DRIVER_CHECK_EXT(XKB, kbproto)
 
 # Checks for pkg-config packages
-PKG_CHECK_MODULES(XORG, [xorg-server >= 1.9.0] xproto $REQUIRED_MODULES)
+PKG_CHECK_MODULES(XORG, [xorg-server >= 1.9.99.2] xproto $REQUIRED_MODULES)
 
 DRIVER_NAME=joystick
 AC_SUBST([DRIVER_NAME])
diff --git a/src/jstk.c b/src/jstk.c
index 1d5befc..9796a46 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -347,7 +347,8 @@ jstkDeviceControlProc(DeviceIntPtr       pJstk,
                                    screenInfo.screens[0]->width, /* max val */
                                    1, /* resolution */
                                    0, /* min_res */
-                                   1); /* max_res */
+                                   1, /* max_res */
+                                   Absolute);
             InitValuatorAxisStruct(pJstk,
                                    1, /* valuator num */
                                    XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y),
@@ -355,7 +356,8 @@ jstkDeviceControlProc(DeviceIntPtr       pJstk,
                                    screenInfo.screens[0]->height, /* max val */
                                    1, /* resolution */
                                    0, /* min_res */
-                                   1); /* max_res */
+                                   1, /* max_res */
+                                   Absolute);
             for (i=0; i<MAXAXES; i++) 
                 if (priv->axis[i].valuator != -1)
             {
@@ -366,23 +368,13 @@ jstkDeviceControlProc(DeviceIntPtr       pJstk,
                                        32767,  /* max val */
                                        1, /* resolution */
                                        0, /* min_res */
-                                       1); /* max_res */
+                                       1, /* max_res */
+                                       Absolute);
             }
             /* allocate the motion history buffer if needed */
             xf86MotionHistoryAllocate(pInfo);
         }
 
-
-        if (priv->keyboard_device != NULL)
-        {
-            DBG(2, ErrorF("Activating keyboard device\n"));
-            xf86ActivateDevice(priv->keyboard_device);
-            priv->keyboard_device->dev->inited = 
-                (priv->keyboard_device->device_control(priv->keyboard_device->dev, DEVICE_INIT) == Success);
-            xf86EnableDevice(priv->keyboard_device->dev);
-            DBG(2, ErrorF("Keyboard device activated\n"));
-        }
-
 	jstkInitProperties(pJstk, priv);
 
         break;
@@ -433,18 +425,6 @@ jstkDeviceControlProc(DeviceIntPtr       pJstk,
     return Success;
 }
 
-
-
-
-_X_EXPORT InputDriverRec JSTK_KEYBOARD = {
-    1,
-    "joystick_keyboard",
-    NULL,
-    jstkKeyboardPreInit,
-    jstkKeyboardUnInit,
-    NULL
-};
-
 /*
  ***************************************************************************
  *
@@ -452,37 +432,41 @@ _X_EXPORT InputDriverRec JSTK_KEYBOARD = {
  *
  * Called when a device will be instantiated
  *
+ * This is a tad complicated. NewInputDeviceRequest(), which we use to
+ * hotplug a keyboard device,. enables the device, so we need to make sure
+ * that all options for the dependent device are set correctly.
+ *
+ * This means that we parse the keyboard-specific options into the
+ * keyboard device's PreInit, and re-use the keyboard's priv field.
+ *
  ***************************************************************************
  */
 
-static InputInfoPtr
-jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
+static int
+jstkCorePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
-    InputInfoPtr        pInfo = NULL;
+    InputInfoPtr        keyboard_device;
     JoystickDevPtr      priv = NULL;
     char                *s;
     int                 i, j;
 
-    pInfo = xf86AllocateInput(drv, 0);
-    if (!pInfo) {
-        goto SetupProc_fail;
-    }
-
-    pInfo->private = (JoystickDevPtr)malloc(sizeof(JoystickDevRec));
-    priv = (JoystickDevPtr)pInfo->private;
+    s = xf86CheckStrOption(pInfo->options, "_source", "");
+    if (strcmp(s, "_driver/joystick") == 0)
+        return jstkKeyboardPreInit(drv, pInfo, flags);
 
-    pInfo->name   = dev->identifier;
-    pInfo->flags  = XI86_SEND_DRAG_EVENTS;
     pInfo->device_control = jstkDeviceControlProc;
     pInfo->read_input = jstkReadProc;
     pInfo->control_proc = NULL;
     pInfo->switch_mode = NULL;
     pInfo->fd = -1;
     pInfo->dev = NULL;
-    pInfo->private = priv;
     pInfo->type_name = XI_JOYSTICK;
-    pInfo->always_core_feedback = NULL;
-    pInfo->conf_idev = dev;
+
+    keyboard_device = jstkKeyboardHotplug(pInfo, flags);
+    if (!keyboard_device)
+        return BadAlloc;
+
+    pInfo->private = priv = keyboard_device->private;
 
     priv->fd = -1;
     priv->open_proc = NULL;
@@ -495,9 +479,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     priv->mouse_enabled = TRUE;
     priv->keys_enabled = TRUE;
     priv->amplify = 1.0f;
-    priv->keyboard_device = NULL;
-    priv->repeat_delay = 0;
-    priv->repeat_interval = 0;
+    priv->keyboard_device = keyboard_device;
     priv->num_axes    = MAXAXES;
     priv->num_buttons = MAXBUTTONS;
 
@@ -555,8 +537,6 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     priv->axis[5].type      = JSTK_TYPE_ACCELERATED;
     priv->axis[5].mapping   = JSTK_MAPPING_Y;
 
-    xf86CollectInputOptions(pInfo, NULL, NULL);
-
     /* Joystick device is mandatory */
     priv->device = xf86SetStrOption(pInfo->options, "Device", NULL);
     if (!priv->device)
@@ -567,8 +547,6 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
         goto SetupProc_fail;
     }
 
-    xf86ProcessCommonOptions(pInfo, pInfo->options);
-
 #if DEBUG
     debug_level = xf86SetIntOption(pInfo->options, "DebugLevel", 0);
     if (debug_level > 0) {
@@ -582,43 +560,6 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
 #endif
 
-    /* Parse option for autorepeat */
-    if ((s = xf86SetStrOption(pInfo->options, "AutoRepeat", NULL))) {
-        int delay, rate;
-        if (sscanf(s, "%d %d", &delay, &rate) != 2) {
-            xf86Msg(X_ERROR, "%s: \"%s\" is not a valid AutoRepeat value", 
-                    pInfo->name, s);
-        } else {
-            priv->repeat_delay = delay;
-            if (rate != 0)
-                priv->repeat_interval = 1000/rate;
-            else priv->repeat_interval = 0;
-            DBG(1, xf86Msg(X_CONFIG, "Autorepeat set to delay=%d, interval=%d\n",
-                           priv->repeat_delay,priv->repeat_interval));
-        }
-        free(s);
-    }
-    
-    priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "xkb_rules", NULL);
-    if (!priv->rmlvo.rules)
-	priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "XkbRules", "evdev");
-
-    priv->rmlvo.model = xf86SetStrOption(pInfo->options, "xkb_model", NULL);
-    if (!priv->rmlvo.model)
-	priv->rmlvo.model = xf86SetStrOption(pInfo->options, "XkbModel", "evdev");
-
-    priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "xkb_layout", NULL);
-    if (!priv->rmlvo.layout)
-	priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "XkbLayout", "us");
-
-    priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "xkb_variant", NULL);
-    if (!priv->rmlvo.variant)
-	priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "XkbVariant", "");
-
-    priv->rmlvo.options = xf86SetStrOption(pInfo->options, "xkb_options", NULL);
-    if (!priv->rmlvo.options)
-	priv->rmlvo.options = xf86SetStrOption(pInfo->options, "XkbOptions", "");
-
     priv->mouse_enabled = xf86SetBoolOption(pInfo->options, "StartMouseEnabled", TRUE);
     priv->keys_enabled = xf86SetBoolOption(pInfo->options, "StartKeysEnabled", TRUE);
 
@@ -649,23 +590,17 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
                        priv->axis[i].amplify));
     }
 
-    /* return the LocalDevice */
-    pInfo->flags |= XI86_CONFIGURED;
-
-    priv->keyboard_device = jstkKeyboardPreInit(&JSTK_KEYBOARD, dev, flags);
-    if (priv->keyboard_device) {
-        priv->keyboard_device->private = priv;
-    }
-
-    return (pInfo);
+    return Success;
 
 SetupProc_fail:
-    if (priv)
+    if (priv) {
         free(priv);
+        if (keyboard_device)
+            keyboard_device->private = NULL;
+    }
     if (pInfo)
         pInfo->private = NULL;
-    return NULL;
-/*    return (pInfo); */ /* Makes X segfault on error */
+    return BadValue;
 }
 
 
@@ -710,7 +645,6 @@ _X_EXPORT InputDriverRec JOYSTICK = {
     NULL
 };
 
-
 /*
  ***************************************************************************
  *
@@ -728,7 +662,6 @@ jstkDriverPlug(pointer  module,
                int      *errmin)
 {
     xf86AddInputDriver(&JOYSTICK, module, 0);
-    xf86AddInputDriver(&JSTK_KEYBOARD, module, 0);
     return module;
 }
 
diff --git a/src/jstk_key.c b/src/jstk_key.c
index acd981b..3c471ce 100644
--- a/src/jstk_key.c
+++ b/src/jstk_key.c
@@ -137,7 +137,7 @@ jstkGenerateKeys(InputInfoPtr device, KEYSCANCODES keys, char pressed)
  *
  ***************************************************************************
  */
-static Bool
+Bool
 jstkKeyboardDeviceControlProc(DeviceIntPtr       dev,
                               int                what)
 {
@@ -180,62 +180,116 @@ jstkKeyboardDeviceControlProc(DeviceIntPtr       dev,
  *
  * jstkKeyboardPreInit --
  *
- * Called manually to create a keyboard device for the joystick
+ * See comment in jstkCorePreInit() for details.
  *
  ***************************************************************************
  */
-InputInfoPtr
-jstkKeyboardPreInit(InputDriverPtr drv, IDevPtr _dev, int flags)
-{
-    InputInfoPtr pInfo = NULL;
-    IDevPtr dev = NULL;
-    char name[512] = {0};
 
-    pInfo = xf86AllocateInput(drv, 0);
-    if (!pInfo) {
-        goto SetupProc_fail;
-    }
+int jstkKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
+{
+    JoystickDevPtr priv = NULL;
+    char *s;
 
-    dev = calloc(sizeof(IDevRec), 1);
-    strcpy(name, _dev->identifier);
-    strcat(name, " (keys)");
-    dev->identifier = xstrdup(name);
-    dev->driver = xstrdup(_dev->driver);
-    dev->commonOptions = (pointer)xf86optionListDup(_dev->commonOptions);
-    dev->extraOptions = (pointer)xf86optionListDup(_dev->extraOptions);
+    pInfo->private = priv = calloc(1, sizeof(JoystickDevRec));
+    if (!priv)
+        return BadAlloc;
 
-    pInfo->name   = dev->identifier;
-    pInfo->flags  = XI86_KEYBOARD_CAPABLE;
     pInfo->device_control = jstkKeyboardDeviceControlProc;
     pInfo->read_input = NULL;
     pInfo->control_proc = NULL;
     pInfo->switch_mode = NULL;
     pInfo->fd = -1;
-    pInfo->dev = NULL;
-    pInfo->private = NULL;
     pInfo->type_name = XI_JOYSTICK;
-    pInfo->history_size = 0;
-    pInfo->always_core_feedback = 0;
-    pInfo->conf_idev = dev;
 
-    xf86CollectInputOptions(pInfo, NULL, NULL);
-    xf86ProcessCommonOptions(pInfo, pInfo->options);
+    /* parse keyboard-related options */
+    priv->repeat_delay = 0;
+    priv->repeat_interval = 0;
+
+    /* Parse option for autorepeat */
+    if ((s = xf86SetStrOption(pInfo->options, "AutoRepeat", NULL))) {
+        int delay, rate;
+        if (sscanf(s, "%d %d", &delay, &rate) != 2) {
+            xf86Msg(X_ERROR, "%s: \"%s\" is not a valid AutoRepeat value",
+                    pInfo->name, s);
+        } else {
+            priv->repeat_delay = delay;
+            if (rate != 0)
+                priv->repeat_interval = 1000/rate;
+            else priv->repeat_interval = 0;
+            DBG(1, xf86Msg(X_CONFIG, "Autorepeat set to delay=%d, interval=%d\n",
+                           priv->repeat_delay,priv->repeat_interval));
+        }
+        free(s);
+    }
+
+    priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "xkb_rules", NULL);
+    if (!priv->rmlvo.rules)
+	priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "XkbRules", "evdev");
+
+    priv->rmlvo.model = xf86SetStrOption(pInfo->options, "xkb_model", NULL);
+    if (!priv->rmlvo.model)
+	priv->rmlvo.model = xf86SetStrOption(pInfo->options, "XkbModel", "evdev");
+
+    priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "xkb_layout", NULL);
+    if (!priv->rmlvo.layout)
+	priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "XkbLayout", "us");
+
+    priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "xkb_variant", NULL);
+    if (!priv->rmlvo.variant)
+	priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "XkbVariant", "");
+
+    priv->rmlvo.options = xf86SetStrOption(pInfo->options, "xkb_options", NULL);
+    if (!priv->rmlvo.options)
+	priv->rmlvo.options = xf86SetStrOption(pInfo->options, "XkbOptions", "");
 
+    return Success;
+}
+
+InputInfoPtr
+jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
+{
+    int rc;
+    char name[512] = {0};
+    InputAttributes *attrs = NULL;
+    InputOption *options;
+    InputOption *iopts = NULL, *tmp;
+    DeviceIntPtr dev;
+
+    /* duplicate option list, append to name */
+    options = xf86OptionListDuplicate(pInfo->options);
+    strcpy(name, pInfo->name);
+    strcat(name, " (keys)");
+    options = xf86ReplaceStrOption(options, "Name", name);
+    options = xf86ReplaceStrOption(options, "_source", "_driver/joystick");
 
-    /* return the LocalDevice */
-    pInfo->flags |= XI86_CONFIGURED;
+    while(options)
+    {
+        tmp = calloc(1, sizeof(InputOption));
+
+        tmp->key = xf86OptionName(options);
+        tmp->value = xf86OptionValue(options);
+        tmp->next = iopts;
+        iopts = tmp;
+        options = xf86NextOption(options);
+    }
+
+    /* duplicate attribute list */
+    attrs = DuplicateInputAttributes(pInfo->attrs);
 
-    return (pInfo);
+    rc = NewInputDeviceRequest(iopts, attrs, &dev);
 
-SetupProc_fail:
-    if (pInfo)
-        pInfo->private = NULL;
-    if (dev) {
-        if (dev->identifier) free(dev->identifier);
-        if (dev->driver) free(dev->driver);
-        free(dev);
+    while(iopts)
+    {
+        tmp = iopts->next;
+        free(iopts->key);
+        free(iopts->value);
+        free(iopts);
+        iopts = tmp;
     }
-    return NULL;
+
+    FreeInputAttributes(attrs);
+
+    return (rc == Success) ? dev->public.devicePrivate : NULL;
 }
 
 
diff --git a/src/jstk_key.h b/src/jstk_key.h
index 01327f6..fc0c782 100644
--- a/src/jstk_key.h
+++ b/src/jstk_key.h
@@ -27,7 +27,8 @@
 
 void jstkGenerateKeys(InputInfoPtr device, KEYSCANCODES keys, char pressed);
 
-InputInfoPtr jstkKeyboardPreInit(InputDriverPtr drv, IDevPtr dev, int flags);
+int jstkKeyboardPreInit(InputDriverPtr pInfo, InputInfoPtr dev, int flags);
 void jstkKeyboardUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
-
+Bool jstkKeyboardDeviceControlProc(DeviceIntPtr dev, int what);
+InputInfoPtr jstkKeyboardHotplug(InputInfoPtr dev, int flags);
 #endif

commit f2050e6be5b6b3f8c429060992cc3ead0cfe86c1
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Dec 14 16:51:15 2010 +1000

    Get the option values from pInfo instead of from the IDevRec.
    
    Doesn't matter which one we take, but ABI 12 dropped the IDevRec.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Trevor Woerner <twoerner@gmail.com>

diff --git a/src/jstk.c b/src/jstk.c
index 1cc837f..1d5befc 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -558,9 +558,9 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     xf86CollectInputOptions(pInfo, NULL, NULL);
 
     /* Joystick device is mandatory */
-    priv->device = xf86SetStrOption(dev->commonOptions, "Device", NULL);
+    priv->device = xf86SetStrOption(pInfo->options, "Device", NULL);
     if (!priv->device)
-        priv->device = xf86SetStrOption(dev->commonOptions, "Path", NULL);
+        priv->device = xf86SetStrOption(pInfo->options, "Path", NULL);
 
     if (!priv->device) {
         xf86Msg (X_ERROR, "%s: No Device specified.\n", pInfo->name);
@@ -570,20 +570,20 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
 #if DEBUG
-    debug_level = xf86SetIntOption(dev->commonOptions, "DebugLevel", 0);
+    debug_level = xf86SetIntOption(pInfo->options, "DebugLevel", 0);
     if (debug_level > 0) {
         xf86Msg(X_CONFIG, "%s: debug level set to %d\n", 
                 pInfo->name, debug_level);
     }
 #else
-    if (xf86SetIntOption(dev->commonOptions, "DebugLevel", 0) != 0) {
+    if (xf86SetIntOption(pInfo->options, "DebugLevel", 0) != 0) {
         xf86Msg(X_WARNING, "%s: DebugLevel: Compiled without debugging support!\n", 
                 pInfo->name);
     }
 #endif
 
     /* Parse option for autorepeat */
-    if ((s = xf86SetStrOption(dev->commonOptions, "AutoRepeat", NULL))) {
+    if ((s = xf86SetStrOption(pInfo->options, "AutoRepeat", NULL))) {
         int delay, rate;
         if (sscanf(s, "%d %d", &delay, &rate) != 2) {
             xf86Msg(X_ERROR, "%s: \"%s\" is not a valid AutoRepeat value", 
@@ -599,34 +599,34 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
         free(s);
     }
     
-    priv->rmlvo.rules = xf86SetStrOption(dev->commonOptions, "xkb_rules", NULL);
+    priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "xkb_rules", NULL);
     if (!priv->rmlvo.rules)
-	priv->rmlvo.rules = xf86SetStrOption(dev->commonOptions, "XkbRules", "evdev");
+	priv->rmlvo.rules = xf86SetStrOption(pInfo->options, "XkbRules", "evdev");
 
-    priv->rmlvo.model = xf86SetStrOption(dev->commonOptions, "xkb_model", NULL);
+    priv->rmlvo.model = xf86SetStrOption(pInfo->options, "xkb_model", NULL);
     if (!priv->rmlvo.model)
-	priv->rmlvo.model = xf86SetStrOption(dev->commonOptions, "XkbModel", "evdev");
+	priv->rmlvo.model = xf86SetStrOption(pInfo->options, "XkbModel", "evdev");
 
-    priv->rmlvo.layout = xf86SetStrOption(dev->commonOptions, "xkb_layout", NULL);
+    priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "xkb_layout", NULL);
     if (!priv->rmlvo.layout)
-	priv->rmlvo.layout = xf86SetStrOption(dev->commonOptions, "XkbLayout", "us");
+	priv->rmlvo.layout = xf86SetStrOption(pInfo->options, "XkbLayout", "us");
 
-    priv->rmlvo.variant = xf86SetStrOption(dev->commonOptions, "xkb_variant", NULL);
+    priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "xkb_variant", NULL);
     if (!priv->rmlvo.variant)
-	priv->rmlvo.variant = xf86SetStrOption(dev->commonOptions, "XkbVariant", "");
+	priv->rmlvo.variant = xf86SetStrOption(pInfo->options, "XkbVariant", "");
 
-    priv->rmlvo.options = xf86SetStrOption(dev->commonOptions, "xkb_options", NULL);
+    priv->rmlvo.options = xf86SetStrOption(pInfo->options, "xkb_options", NULL);
     if (!priv->rmlvo.options)
-	priv->rmlvo.options = xf86SetStrOption(dev->commonOptions, "XkbOptions", "");
+	priv->rmlvo.options = xf86SetStrOption(pInfo->options, "XkbOptions", "");
 
-    priv->mouse_enabled = xf86SetBoolOption(dev->commonOptions, "StartMouseEnabled", TRUE);
-    priv->keys_enabled = xf86SetBoolOption(dev->commonOptions, "StartKeysEnabled", TRUE);
+    priv->mouse_enabled = xf86SetBoolOption(pInfo->options, "StartMouseEnabled", TRUE);
+    priv->keys_enabled = xf86SetBoolOption(pInfo->options, "StartKeysEnabled", TRUE);
 
     /* Process button mapping options */
     for (i=0; i<MAXBUTTONS; i++) {
         char p[64];
         sprintf(p,"MapButton%d",i+1);
-        s = xf86SetStrOption(dev->commonOptions, p, NULL);
+        s = xf86SetStrOption(pInfo->options, p, NULL);
         if (s != NULL) {
             jstkParseButtonOption(s, priv, i, pInfo->name);
         }
@@ -638,7 +638,7 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     for (i=0; i<MAXAXES; i++) {
         char p[64];
         sprintf(p,"MapAxis%d",i+1);
-        s = xf86SetStrOption(dev->commonOptions, p, NULL);
+        s = xf86SetStrOption(pInfo->options, p, NULL);
         if (s != NULL) {
             jstkParseAxisOption(s, priv, &priv->axis[i], pInfo->name);
         }

commit df0567d2fa2d67a00dce78a89803e8925d20e324
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Dec 14 16:48:50 2010 +1000

    Don't call xf86OptionListReport()
    
    All options used by the driver will show up in the log anyway.
    And new xserver versions will call this for debugging purposes for us.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Trevor Woerner <twoerner@gmail.com>

diff --git a/src/jstk.c b/src/jstk.c
index c3ea3da..1cc837f 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -556,7 +556,6 @@ jstkCorePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     priv->axis[5].mapping   = JSTK_MAPPING_Y;
 
     xf86CollectInputOptions(pInfo, NULL, NULL);
-    xf86OptionListReport(pInfo->options);
 
     /* Joystick device is mandatory */
     priv->device = xf86SetStrOption(dev->commonOptions, "Device", NULL);
diff --git a/src/jstk_key.c b/src/jstk_key.c
index cdbd440..acd981b 100644
--- a/src/jstk_key.c
+++ b/src/jstk_key.c
@@ -219,7 +219,6 @@ jstkKeyboardPreInit(InputDriverPtr drv, IDevPtr _dev, int flags)
     pInfo->conf_idev = dev;
 
     xf86CollectInputOptions(pInfo, NULL, NULL);
-    xf86OptionListReport(pInfo->options);
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
 

commit 135aaf612bcb591ae1692ae47b2d36a814230cbe
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Dec 14 15:19:08 2010 +1000

    Purge use of XI_PRIVATE macro.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Trevor Woerner <twoerner@gmail.com>

diff --git a/src/jstk.c b/src/jstk.c
index 9e0f55c..c3ea3da 100644
--- a/src/jstk.c
+++ b/src/jstk.c
@@ -293,7 +293,7 @@ jstkDeviceControlProc(DeviceIntPtr       pJstk,
 {
     int i;
     InputInfoPtr     pInfo = (InputInfoPtr)pJstk->public.devicePrivate;
-    JoystickDevPtr   priv  = (JoystickDevPtr)XI_PRIVATE(pJstk);
+    JoystickDevPtr   priv  = pInfo->private;
     Atom             btn_labels[BUTTONMAP_SIZE+1] = {0}; /* TODO: fillme */
     Atom             axes_labels[MAXAXES] = {0}; /* TODO: fillme */
 
diff --git a/src/jstk_axis.c b/src/jstk_axis.c
index 7bea816..95ebfe9 100644
--- a/src/jstk_axis.c
+++ b/src/jstk_axis.c
@@ -56,7 +56,8 @@ jstkAxisTimer(OsTimerPtr        timer,
 {
     #define NEXTTIMER 15
     DeviceIntPtr          device = (DeviceIntPtr)arg;
-    JoystickDevPtr        priv = (JoystickDevPtr)XI_PRIVATE(device);
+    InputInfoPtr          pInfo = device->public.devicePrivate;
+    JoystickDevPtr        priv  = pInfo->private;
 
     int sigstate, i;
     int nexttimer;
@@ -407,7 +408,8 @@ jstkPWMAxisTimer(OsTimerPtr        timer,
                  pointer           arg)
 {
     DeviceIntPtr          device = (DeviceIntPtr)arg;
-    JoystickDevPtr        priv = (JoystickDevPtr)XI_PRIVATE(device);
+    InputInfoPtr          pInfo = device->public.devicePrivate;
+    JoystickDevPtr        priv  = pInfo->private;
 
     int sigstate, i;
     int nexttimer;
diff --git a/src/jstk_key.c b/src/jstk_key.c
index c3636b6..cdbd440 100644
--- a/src/jstk_key.c
+++ b/src/jstk_key.c
@@ -141,7 +141,8 @@ static Bool
 jstkKeyboardDeviceControlProc(DeviceIntPtr       dev,
                               int                what)
 {
-    JoystickDevPtr priv  = (JoystickDevPtr)XI_PRIVATE(dev);
+    InputInfoPtr pInfo = dev->public.devicePrivate;
+    JoystickDevPtr priv  = pInfo->private;
     if (!priv) {
         DBG(2, ErrorF("jstkKeyboardDeviceControlProc: priv == NULL\n"));
         return !Success;


Reply to: