[PATCH acecad 7/7] Adjust to new PreInit for ABI 12.

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 9 17:56:41 PDT 2010


Most of the init is now handled by the server, not by the driver.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
CC: Giuseppe Bilotta <giuseppe.bilotta at gmail.org>
---
 src/acecad.c |   50 ++++++++++++++++++++++++++++++++++++++------------
 src/acecad.h |    4 ++++
 2 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/src/acecad.c b/src/acecad.c
index c76b641..24261c4 100644
--- a/src/acecad.c
+++ b/src/acecad.c
@@ -126,7 +126,10 @@ _X_EXPORT InputDriverRec ACECAD =
 	AceCadPreInit,
 	NULL,
 	NULL,
-	0
+	0,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+        default_options
+#endif
 };
 
 static XF86ModuleVersionInfo VersionRec =
@@ -329,20 +332,18 @@ ProbeFound:
 
 #endif
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+static int NewAceCadPreInit(InputDriverPtr drv, InputInfoPtr dev, int flags);
+
 static InputInfoPtr
 AceCadPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
 {
     InputInfoPtr local = xf86AllocateInput(drv, 0);
     AceCadPrivatePtr priv = calloc (1, sizeof(AceCadPrivateRec));
-    int speed;
-    int msgtype;
-    char *s;
 
-    if ((!local) || (!priv))
+    if ((!local))
         goto SetupProc_fail;
 
-    memset(priv, 0, sizeof(AceCadPrivateRec));
-
     local->name = dev->identifier;
     local->type_name = XI_TABLET;
     local->flags = XI86_SEND_DRAG_EVENTS;
@@ -357,13 +358,38 @@ AceCadPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     local->private = priv;
     local->private_flags = 0;
     local->conf_idev = dev;
-    local->device_control = DeviceControl;
     /*local->always_core_feedback = 0;*/
 
     xf86CollectInputOptions(local, default_options, NULL);
 
     xf86OptionListReport(local->options);
 
+    if (NewAceCadPreInit(drv, local, flags) == Success)
+        return local;
+
+SetupProc_fail:
+    return NULL;
+}
+
+static int
+NewAceCadPreInit(InputDriverPtr drv, InputInfoPtr local, int flags)
+#else
+static int
+AceCadPreInit(InputDriverPtr drv, InputInfoPtr local, int flags)
+#endif
+{
+    AceCadPrivatePtr priv = calloc (1, sizeof(AceCadPrivateRec));
+    int speed;
+    int msgtype;
+    char *s;
+
+    if (!priv)
+        return BadAlloc;
+
+    memset(priv, 0, sizeof(AceCadPrivateRec));
+
+    local->device_control = DeviceControl;
+
     priv->acecadInc = xf86SetIntOption(local->options, "Increment", 0 );
 
     s = xf86FindOptionValue(local->options, "Device");
@@ -458,11 +484,11 @@ AceCadPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     xf86Msg(msgtype, "%s is in %s mode\n", local->name, (priv->flags & ABSOLUTE_FLAG) ? "absolute" : "relative");
     DBG (9, XisbTrace (priv->buffer, 1));
 
-    local->history_size = xf86SetIntOption(local->options , "HistorySize", 0);
-
     xf86ProcessCommonOptions(local, local->options);
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
     local->flags |= XI86_CONFIGURED;
+#endif
 
     if (local->fd != -1)
     {
@@ -476,7 +502,7 @@ AceCadPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
     RemoveEnabledDevice (local->fd);
     local->fd = -1;
-    return local;
+    return Success;
 
     /*
      * If something went wrong, cleanup and return NULL
@@ -492,7 +518,7 @@ SetupProc_fail:
 		local->private = NULL;
     }
     xf86DeleteInput(local, 0);
-    return NULL;
+    return BadAlloc;
 }
 
 static Bool
diff --git a/src/acecad.h b/src/acecad.h
index 342b940..a2b5c66 100644
--- a/src/acecad.h
+++ b/src/acecad.h
@@ -106,7 +106,11 @@ static Bool ReverseConvertProc(InputInfoPtr , int , int , int*);
 static Bool QueryHardware (AceCadPrivatePtr);
 static void NewPacket (AceCadPrivatePtr priv);
 static Bool AceCadGetPacket (AceCadPrivatePtr);
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
 static InputInfoPtr AceCadPreInit(InputDriverPtr, IDevPtr , int);
+#else
+static int AceCadPreInit(InputDriverPtr, InputInfoPtr , int);
+#endif
 #ifdef HAVE_LINUX_INPUT_H
 static void USBReadInput (InputInfoPtr);
 static Bool USBQueryHardware (InputInfoPtr);
-- 
1.7.2.3



More information about the xorg-devel mailing list