summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-11-25 21:19:39 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2021-12-20 15:01:56 +1000
commit4b055af87e2b3b9fa29c0cf3d0a20ecf6c0917c6 (patch)
tree797b58c8d5a3a64b728adfcc10d54fa10fc365fd /src
parent98748db8508be740615dc9c12ae1da9a3650baf2 (diff)
downloadxf86-input-wacom-4b055af87e2b3b9fa29c0cf3d0a20ecf6c0917c6.tar.gz
Add the WacomInterface header file
This header file now declares the functions required by any frontend implementation of this driver. The core part of the driver (all files but xf86Wacom.c) will eventually be independent of X altogether, with the X driver bit in xf86Wacom.c the layer that connects the wacom driver to the X server - with the APIs the server requires. This interface is currently semi-complete, we still rely on pInfo in the driver and we still use several X-specific interfaces but the remaining ones are ones that require simple 1:1 conversion but not functional changes (e.g. option handling, fd retrieval, etc.) Since Bool is not used anywhere but in X, switch to bool instead. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/WacomInterface.h170
-rw-r--r--src/common.mk1
-rw-r--r--src/xf86Wacom.c16
-rw-r--r--src/xf86Wacom.h136
-rw-r--r--src/xf86WacomDefs.h2
5 files changed, 183 insertions, 142 deletions
diff --git a/src/WacomInterface.h b/src/WacomInterface.h
new file mode 100644
index 0000000..297336f
--- /dev/null
+++ b/src/WacomInterface.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright 1995-2002 by Frederic Lepied, France. <Lepied@XFree86.org>
+ * Copyright 2002-2010 by Ping Cheng, Wacom. <pingc@wacom.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* This header file declares the functions that need to be implemented to use
+ * the driver. See xf86Wacom.c for the Xorg driver implementation.
+ *
+ * THIS IS NOT A STABLE API
+ */
+
+#include <config.h>
+
+#ifndef __WACOM_INTERFACE_H
+#define __WACOM_INTERFACE_H
+
+#include <stdbool.h>
+
+typedef struct _WacomDeviceRec *WacomDevicePtr;
+
+/* Identical to MessageType */
+typedef enum {
+ W_PROBED, /* Value was probed */
+ W_CONFIG, /* Value was given in the config file */
+ W_DEFAULT, /* Value is a default */
+ W_CMDLINE, /* Value was given on the command line */
+ W_NOTICE, /* Notice */
+ W_ERROR, /* Error message */
+ W_WARNING, /* Warning message */
+ W_INFO, /* Informational message */
+ W_NONE, /* No prefix */
+ W_NOT_IMPLEMENTED, /* Not implemented */
+ W_DEBUG, /* Debug message */
+ W_UNKNOWN = -1 /* unknown -- this must always be last */
+} WacomLogType;
+
+enum WacomAxisType {
+ WACOM_AXIS_X = (1 << 0),
+ WACOM_AXIS_Y = (1 << 1),
+ WACOM_AXIS_PRESSURE = (1 << 2),
+ WACOM_AXIS_TILT_X = (1 << 3),
+ WACOM_AXIS_TILT_Y = (1 << 4),
+ WACOM_AXIS_STRIP_X = (1 << 5),
+ WACOM_AXIS_STRIP_Y = (1 << 6),
+ WACOM_AXIS_ROTATION = (1 << 7),
+ WACOM_AXIS_THROTTLE = (1 << 8),
+ WACOM_AXIS_WHEEL = (1 << 9),
+ WACOM_AXIS_RING = (1 << 10),
+ WACOM_AXIS_RING2 = (1 << 11),
+
+ _WACOM_AXIS_LAST = WACOM_AXIS_RING2,
+};
+
+typedef struct {
+ uint32_t mask;
+ int x, y;
+ int pressure;
+ int tilt_x, tilt_y;
+ int strip_x, strip_y;
+ int rotation;
+ int throttle;
+ int wheel;
+ int ring, ring2;
+} WacomAxisData;
+
+
+/**
+ * General logging function. If priv is NULL, use a generic logging method,
+ * otherwise priv is the device to log the message for.
+ */
+__attribute__((__format__(__printf__ ,3, 4)))
+void wcmLog(WacomDevicePtr priv, WacomLogType type, const char *format, ...);
+
+/**
+ * @retval 0 to abort the loop (counts as match)
+ * @retval -ENODEV if the device is not a match
+ * @retval 1 for success (counts as match).
+ * @retval -errno for an error (to abort)
+ */
+typedef int (*WacomDeviceCallback)(WacomDevicePtr priv, void *data);
+
+/**
+ * Returns the number of devices processed or a negative errno
+ */
+int wcmForeachDevice(WacomDevicePtr priv, WacomDeviceCallback func, void *data);
+
+/* Open the device with the right serial parmeters */
+int wcmOpen(WacomDevicePtr priv);
+
+/* Close the device */
+void wcmClose(WacomDevicePtr priv);
+
+static inline void wcmAxisSet(WacomAxisData *data,
+ enum WacomAxisType which, int value)
+{
+ data->mask |= which;
+ switch (which){
+ case WACOM_AXIS_X: data->x = value; break;
+ case WACOM_AXIS_Y: data->y = value; break;
+ case WACOM_AXIS_PRESSURE: data->pressure = value; break;
+ case WACOM_AXIS_TILT_X: data->tilt_x = value; break;
+ case WACOM_AXIS_TILT_Y: data->tilt_y = value; break;
+ case WACOM_AXIS_STRIP_X: data->strip_x = value; break;
+ case WACOM_AXIS_STRIP_Y: data->strip_y = value; break;
+ case WACOM_AXIS_ROTATION: data->rotation = value; break;
+ case WACOM_AXIS_THROTTLE: data->wheel = value; break;
+ case WACOM_AXIS_WHEEL: data->wheel = value; break;
+ case WACOM_AXIS_RING: data->ring = value; break;
+ case WACOM_AXIS_RING2: data->ring2 = value; break;
+ default:
+ abort();
+ }
+}
+
+static inline bool wcmAxisGet(const WacomAxisData *data,
+ enum WacomAxisType which, int *value_out)
+{
+ if (!(data->mask & which))
+ return FALSE;
+
+ switch (which){
+ case WACOM_AXIS_X: *value_out = data->x; break;
+ case WACOM_AXIS_Y: *value_out = data->y; break;
+ case WACOM_AXIS_PRESSURE: *value_out = data->pressure; break;
+ case WACOM_AXIS_TILT_X: *value_out = data->tilt_x; break;
+ case WACOM_AXIS_TILT_Y: *value_out = data->tilt_y; break;
+ case WACOM_AXIS_STRIP_X: *value_out = data->strip_x; break;
+ case WACOM_AXIS_STRIP_Y: *value_out = data->strip_y; break;
+ case WACOM_AXIS_ROTATION: *value_out = data->rotation; break;
+ case WACOM_AXIS_THROTTLE: *value_out = data->wheel; break;
+ case WACOM_AXIS_WHEEL: *value_out = data->wheel; break;
+ case WACOM_AXIS_RING: *value_out = data->ring; break;
+ case WACOM_AXIS_RING2: *value_out = data->ring2; break;
+ default:
+ abort();
+ }
+ return TRUE;
+}
+
+void wcmInitAxis(WacomDevicePtr priv, enum WacomAxisType type, int min, int max, int res);
+bool wcmInitButtons(WacomDevicePtr priv, unsigned int nbuttons);
+bool wcmInitKeyboard(WacomDevicePtr priv);
+bool wcmInitPointer(WacomDevicePtr priv, int naxes, bool is_absolute);
+bool wcmInitTouch(WacomDevicePtr priv, int ntouches, bool is_direct_touch);
+
+
+void wcmEmitKeycode(WacomDevicePtr priv, int keycode, int state);
+void wcmEmitMotion(WacomDevicePtr priv, bool is_absolute, const WacomAxisData *axes);
+void wcmEmitButton(WacomDevicePtr priv, bool is_absolute, int button, bool is_press,
+ const WacomAxisData *axes);
+void wcmEmitProximity(WacomDevicePtr priv, bool is_proximity_in,
+ const WacomAxisData *axes);
+void wcmEmitTouch(WacomDevicePtr priv, int type, unsigned int touchid, int x, int y);
+
+#endif
+
diff --git a/src/common.mk b/src/common.mk
index 7f1eadd..cbd5a96 100644
--- a/src/common.mk
+++ b/src/common.mk
@@ -1,6 +1,7 @@
# shared makefile between src/Makefile.am and test/Makefile.am
DRIVER_SOURCES= \
+ $(top_srcdir)/src/WacomInterface.h \
$(top_srcdir)/src/xf86Wacom.c \
$(top_srcdir)/src/xf86Wacom.h \
$(top_srcdir)/src/wcmCommon.c \
diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
index e45a869..557b06b 100644
--- a/src/xf86Wacom.c
+++ b/src/xf86Wacom.c
@@ -51,6 +51,8 @@
#include <X11/extensions/XKB.h>
#include <xkbsrv.h>
+#include <stdbool.h>
+
#ifndef XI86_SERVER_FD
#define XI86_SERVER_FD 0x20
#define XI86_DRV_CAP_SERVER_FD 0x01
@@ -129,7 +131,7 @@ convertAxes(const WacomAxisData *axes, int *first_out, int *num_out, int valuato
*num_out = last - first + 1;
}
-void wcmEmitProximity(WacomDevicePtr priv, Bool is_proximity_in,
+void wcmEmitProximity(WacomDevicePtr priv, bool is_proximity_in,
const WacomAxisData *axes)
{
InputInfoPtr pInfo = priv->pInfo;
@@ -141,7 +143,7 @@ void wcmEmitProximity(WacomDevicePtr priv, Bool is_proximity_in,
xf86PostProximityEventP(pInfo->dev, is_proximity_in, first_val, num_vals, valuators);
}
-void wcmEmitMotion(WacomDevicePtr priv, Bool is_absolute, const WacomAxisData *axes)
+void wcmEmitMotion(WacomDevicePtr priv, bool is_absolute, const WacomAxisData *axes)
{
InputInfoPtr pInfo = priv->pInfo;
int valuators[7];
@@ -152,7 +154,7 @@ void wcmEmitMotion(WacomDevicePtr priv, Bool is_absolute, const WacomAxisData *a
xf86PostMotionEventP(pInfo->dev, is_absolute, first_val, num_vals, valuators);
}
-void wcmEmitButton(WacomDevicePtr priv, Bool is_absolute, int button, Bool is_press, const WacomAxisData *axes)
+void wcmEmitButton(WacomDevicePtr priv, bool is_absolute, int button, bool is_press, const WacomAxisData *axes)
{
InputInfoPtr pInfo = priv->pInfo;
int valuators[7];
@@ -245,7 +247,7 @@ void wcmInitAxis(WacomDevicePtr priv, enum WacomAxisType type,
Absolute);
}
-Bool wcmInitButtons(WacomDevicePtr priv, unsigned int nbuttons)
+bool wcmInitButtons(WacomDevicePtr priv, unsigned int nbuttons)
{
InputInfoPtr pInfo = priv->pInfo;
unsigned char butmap[WCM_MAX_BUTTONS+1];
@@ -263,7 +265,7 @@ Bool wcmInitButtons(WacomDevicePtr priv, unsigned int nbuttons)
static void wcmKbdLedCallback(DeviceIntPtr di, LedCtrl * lcp) { }
static void wcmKbdCtrlCallback(DeviceIntPtr di, KeybdCtrl* ctrl) { }
-Bool wcmInitKeyboard(WacomDevicePtr priv)
+bool wcmInitKeyboard(WacomDevicePtr priv)
{
InputInfoPtr pInfo = priv->pInfo;
return InitFocusClassDeviceStruct(pInfo->dev) &&
@@ -273,7 +275,7 @@ Bool wcmInitKeyboard(WacomDevicePtr priv)
static void wcmDevControlProc(DeviceIntPtr device, PtrCtrl* ctrl) { }
-Bool wcmInitPointer(WacomDevicePtr priv, int naxes, Bool is_absolute)
+bool wcmInitPointer(WacomDevicePtr priv, int naxes, bool is_absolute)
{
InputInfoPtr pInfo = priv->pInfo;
Atom axis_labels[MAX_VALUATORS] = {0};
@@ -290,7 +292,7 @@ Bool wcmInitPointer(WacomDevicePtr priv, int naxes, Bool is_absolute)
mode | OutOfProximity);
}
-Bool wcmInitTouch(WacomDevicePtr priv, int ntouches, Bool is_direct_touch)
+bool wcmInitTouch(WacomDevicePtr priv, int ntouches, bool is_direct_touch)
{
InputInfoPtr pInfo = priv->pInfo;
WacomCommonPtr common = priv->common;
diff --git a/src/xf86Wacom.h b/src/xf86Wacom.h
index 62d8818..a19527c 100644
--- a/src/xf86Wacom.h
+++ b/src/xf86Wacom.h
@@ -32,6 +32,8 @@
#include <wacom-util.h>
+#include <WacomInterface.h>
+
#ifndef _fallthrough_
#define _fallthrough_ __attribute__((fallthrough))
#endif
@@ -68,27 +70,6 @@
/* The rest are defined in a separate .h-file */
#include "xf86WacomDefs.h"
-/* Identical to MessageType */
-typedef enum {
- W_PROBED, /* Value was probed */
- W_CONFIG, /* Value was given in the config file */
- W_DEFAULT, /* Value is a default */
- W_CMDLINE, /* Value was given on the command line */
- W_NOTICE, /* Notice */
- W_ERROR, /* Error message */
- W_WARNING, /* Warning message */
- W_INFO, /* Informational message */
- W_NONE, /* No prefix */
- W_NOT_IMPLEMENTED, /* Not implemented */
- W_DEBUG, /* Debug message */
- W_UNKNOWN = -1 /* unknown -- this must always be last */
-} WacomLogType;
-
-
-_X_ATTRIBUTE_PRINTF(3, 4)
-void
-wcmLog(WacomDevicePtr priv, WacomLogType type, const char *format, ...);
-
/*****************************************************************************
* General Inlined functions and Prototypes
****************************************************************************/
@@ -114,25 +95,6 @@ void wcmDevClose(WacomDevicePtr priv);
Bool wcmDevStart(WacomDevicePtr priv);
void wcmDevStop(WacomDevicePtr priv);
-/**
- * @retval 0 to abort the loop (counts as match)
- * @retval -ENOENT if the device is not a match
- * @retval 1 for success (counts as match).
- * @retval -errno for an error (to abort)
- */
-typedef int (*WacomDeviceCallback)(WacomDevicePtr priv, void *data);
-
-/**
- * Returns the number of devices processed or a negative errno
- */
-extern int wcmForeachDevice(WacomDevicePtr priv, WacomDeviceCallback func, void *data);
-
-/* Open the device with the right serial parmeters */
-extern Bool wcmOpen(WacomDevicePtr priv);
-
-/* Close the device */
-extern void wcmClose(WacomDevicePtr priv);
-
void wcmRemoveActive(WacomDevicePtr priv);
/* device autoprobing */
@@ -221,100 +183,6 @@ static inline void wcmActionSet(WacomAction *action, unsigned idx, unsigned act)
action->nactions = idx + 1;
}
-/* Axis and event handling */
-
-enum WacomAxisType {
- WACOM_AXIS_X = (1 << 0),
- WACOM_AXIS_Y = (1 << 1),
- WACOM_AXIS_PRESSURE = (1 << 2),
- WACOM_AXIS_TILT_X = (1 << 3),
- WACOM_AXIS_TILT_Y = (1 << 4),
- WACOM_AXIS_STRIP_X = (1 << 5),
- WACOM_AXIS_STRIP_Y = (1 << 6),
- WACOM_AXIS_ROTATION = (1 << 7),
- WACOM_AXIS_THROTTLE = (1 << 8),
- WACOM_AXIS_WHEEL = (1 << 9),
- WACOM_AXIS_RING = (1 << 10),
- WACOM_AXIS_RING2 = (1 << 11),
-
- _WACOM_AXIS_LAST = WACOM_AXIS_RING2,
-};
-
-typedef struct {
- uint32_t mask;
- int x, y;
- int pressure;
- int tilt_x, tilt_y;
- int strip_x, strip_y;
- int rotation;
- int throttle;
- int wheel;
- int ring, ring2;
-} WacomAxisData;
-
-static inline void wcmAxisSet(WacomAxisData *data,
- enum WacomAxisType which, int value)
-{
- data->mask |= which;
- switch (which){
- case WACOM_AXIS_X: data->x = value; break;
- case WACOM_AXIS_Y: data->y = value; break;
- case WACOM_AXIS_PRESSURE: data->pressure = value; break;
- case WACOM_AXIS_TILT_X: data->tilt_x = value; break;
- case WACOM_AXIS_TILT_Y: data->tilt_y = value; break;
- case WACOM_AXIS_STRIP_X: data->strip_x = value; break;
- case WACOM_AXIS_STRIP_Y: data->strip_y = value; break;
- case WACOM_AXIS_ROTATION: data->rotation = value; break;
- case WACOM_AXIS_THROTTLE: data->wheel = value; break;
- case WACOM_AXIS_WHEEL: data->wheel = value; break;
- case WACOM_AXIS_RING: data->ring = value; break;
- case WACOM_AXIS_RING2: data->ring2 = value; break;
- default:
- abort();
- }
-}
-
-static inline Bool wcmAxisGet(const WacomAxisData *data,
- enum WacomAxisType which, int *value_out)
-{
- if (!(data->mask & which))
- return FALSE;
-
- switch (which){
- case WACOM_AXIS_X: *value_out = data->x; break;
- case WACOM_AXIS_Y: *value_out = data->y; break;
- case WACOM_AXIS_PRESSURE: *value_out = data->pressure; break;
- case WACOM_AXIS_TILT_X: *value_out = data->tilt_x; break;
- case WACOM_AXIS_TILT_Y: *value_out = data->tilt_y; break;
- case WACOM_AXIS_STRIP_X: *value_out = data->strip_x; break;
- case WACOM_AXIS_STRIP_Y: *value_out = data->strip_y; break;
- case WACOM_AXIS_ROTATION: *value_out = data->rotation; break;
- case WACOM_AXIS_THROTTLE: *value_out = data->wheel; break;
- case WACOM_AXIS_WHEEL: *value_out = data->wheel; break;
- case WACOM_AXIS_RING: *value_out = data->ring; break;
- case WACOM_AXIS_RING2: *value_out = data->ring2; break;
- default:
- abort();
- }
- return TRUE;
-}
-
-void wcmInitAxis(WacomDevicePtr priv, enum WacomAxisType type, int min, int max, int res);
-Bool wcmInitButtons(WacomDevicePtr priv, unsigned int nbuttons);
-Bool wcmInitKeyboard(WacomDevicePtr priv);
-Bool wcmInitPointer(WacomDevicePtr priv, int naxes, Bool is_absolute);
-Bool wcmInitTouch(WacomDevicePtr priv, int ntouches, Bool is_direct_touch);
-
-
-void wcmEmitKeycode(WacomDevicePtr priv, int keycode, int state);
-void wcmEmitMotion(WacomDevicePtr priv, Bool is_absolute, const WacomAxisData *axes);
-void wcmEmitButton(WacomDevicePtr priv, Bool is_absolute, int button, Bool is_press,
- const WacomAxisData *axes);
-void wcmEmitProximity(WacomDevicePtr priv, Bool is_proximity_in,
- const WacomAxisData *axes);
-void wcmEmitTouch(WacomDevicePtr priv, int type, unsigned int touchid, int x, int y);
-
-
enum WacomSuppressMode {
SUPPRESS_NONE = 8, /* Process event normally */
SUPPRESS_ALL, /* Supress and discard the whole event */
diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
index c599a28..a013116 100644
--- a/src/xf86WacomDefs.h
+++ b/src/xf86WacomDefs.h
@@ -69,7 +69,7 @@
*****************************************************************************/
typedef struct _WacomModel WacomModel, *WacomModelPtr;
-typedef struct _WacomDeviceRec WacomDeviceRec, *WacomDevicePtr;
+typedef struct _WacomDeviceRec WacomDeviceRec;
typedef struct _WacomDeviceState WacomDeviceState, *WacomDeviceStatePtr;
typedef struct _WacomChannel WacomChannel, *WacomChannelPtr;
typedef struct _WacomCommonRec WacomCommonRec, *WacomCommonPtr;