Compiling synaptics on xserver git
Ben Gamari
ben at mw0.ath.cx
Thu Mar 27 13:43:11 PDT 2008
Hey all,
I'm not sure if perhaps development of synaptics has moved, but the
driver in git (http://web.telia.com/~u89404340/touchpad/synaptics/.git)
hasn't compiled against xserver master for some time now. As far as I
can tell, most of the changes are pretty straightforward, just using
system library calls as opposed to the xf86* varieties (I thought I read
somewhere that there were deprecated, correct me if I'm wrong). With
these changes, the driver works just fine with xserver master
(6dc369028d3ca741de57ad78febf2f5f82e0696e). Hopefully someone will find
this useful,
- Ben
diff --git a/Makefile b/Makefile
index 334f012..d3d27ab 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ BINDIR = $(DESTDIR)$(PREFIX)/bin
MANDIR = $(DESTDIR)$(PREFIX)/man
ifeq ($(ARCH),)
- ARCH = $(shell /bin/arch)
+ ARCH = $(shell arch)
endif
ifeq ($(ARCH),amd64)
ARCH = x86_64
@@ -75,7 +75,7 @@ MODULE_DEFINES = -DIN_MODULE -DXFree86Module
PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO
STD_DEFINES = -Dlinux -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE
-D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DSHAPE
-DXINPUT -DXKB -DLBX -DXAPPGROUP -DXCSECURITY -DTOGCUP -DDPMSExtension
-DPIXPRIV -DPANORAMIX -DRENDER -DGCCUSESGAS -DAVOID_GLYPHBLT -DPIXPRIV
-DSINGLEDEPTH -DXFreeXDGA -DXvExtension -DXFree86LOADER -DXFree86Server
-DXF86VIDMODE -DSMART_SCHEDULE -DBUILDDEBUG
-DX_BYTE_ORDER=X_LITTLE_ENDIAN -DNDEBUG $(ARCH_DEFINES)
-ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES)
$(MODULE_DEFINES)
+ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES)
$(MODULE_DEFINES) -I/usr/include/pixman-1
check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null
> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
diff --git a/synaptics.c b/synaptics.c
index 802132c..0a07290 100644
--- a/synaptics.c
+++ b/synaptics.c
@@ -67,10 +67,17 @@
#include <unistd.h>
#include <sys/ioctl.h>
+#include <string.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <math.h>
+
#include <misc.h>
#include <xf86.h>
#define NEED_XF86_TYPES
-#include <xf86_ansic.h>
#include <xf86_OSproc.h>
#include <xf86Xinput.h>
#include "mipointer.h"
@@ -236,14 +243,14 @@ alloc_param_data(LocalDevicePtr local)
return TRUE; /* Already allocated */
if (priv->shm_config) {
- if ((shmid = xf86shmget(SHM_SYNAPTICS, 0, 0)) != -1)
- xf86shmctl(shmid, XF86IPC_RMID, NULL);
- if ((shmid = xf86shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
- 0777 | XF86IPC_CREAT)) == -1) {
+ if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
+ shmctl(shmid, IPC_RMID, NULL);
+ if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
+ 0777 | IPC_CREAT)) == -1) {
xf86Msg(X_ERROR, "%s error shmget\n", local->name);
return FALSE;
}
- if ((priv->synpara = (SynapticsSHM*)xf86shmat(shmid, NULL, 0)) ==
NULL) {
+ if ((priv->synpara = (SynapticsSHM*)shmat(shmid, NULL, 0)) == NULL) {
xf86Msg(X_ERROR, "%s error shmat\n", local->name);
return FALSE;
}
@@ -269,8 +276,8 @@ free_param_data(SynapticsPrivate *priv)
return;
if (priv->shm_config) {
- if ((shmid = xf86shmget(SHM_SYNAPTICS, 0, 0)) != -1)
- xf86shmctl(shmid, XF86IPC_RMID, NULL);
+ if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
+ shmctl(shmid, IPC_RMID, NULL);
} else {
xfree(priv->synpara);
}
@@ -284,7 +291,7 @@ synSetFloatOption(pointer options, const char
*optname, double default_value)
char *str_par;
double value;
str_par = xf86FindOptionValue(options, optname);
- if ((!str_par) || (xf86sscanf(str_par, "%lf", &value) != 1))
+ if ((!str_par) || (sscanf(str_par, "%lf", &value) != 1))
return default_value;
return value;
}
@@ -491,17 +498,13 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev,
int flags)
priv->fifofd = -1;
if (repeater) {
/* create repeater fifo */
- if ((xf86mknod(repeater, 666, XF86_S_IFIFO) != 0) &&
- (xf86errno != xf86_EEXIST)) {
- xf86Msg(X_ERROR, "%s can't create repeater fifo\n", local->name);
- } else {
+ mknod(repeater, 666, S_IFIFO);
/* open the repeater fifo */
optList = xf86NewOption("Device", repeater);
if ((priv->fifofd = xf86OpenSerial(optList)) == -1) {
xf86Msg(X_ERROR, "%s repeater device open failed\n", local->name);
}
- }
- xf86free(repeater);
+ free(repeater);
}
if (!QueryHardware(local)) {
@@ -694,7 +697,7 @@ DeviceInit(DeviceIntPtr dev)
static int
move_distance(int dx, int dy)
{
- return xf86sqrt(SQR(dx) + SQR(dy));
+ return sqrt(SQR(dx) + SQR(dy));
}
/*
@@ -729,14 +732,14 @@ angle(SynapticsPrivate *priv, int x, int y)
double xCenter = (priv->synpara->left_edge +
priv->synpara->right_edge) / 2.0;
double yCenter = (priv->synpara->top_edge +
priv->synpara->bottom_edge) / 2.0;
- return xf86atan2(-(y - yCenter), x - xCenter);
+ return atan2(-(y - yCenter), x - xCenter);
}
/* return angle difference */
static double
diffa(double a1, double a2)
{
- double da = xf86fmod(a2 - a1, 2 * M_PI);
+ double da = fmod(a2 - a1, 2 * M_PI);
if (da < 0)
da += 2 * M_PI;
if (da > M_PI)
@@ -844,7 +847,7 @@ SynapticsGetHwState(LocalDevicePtr local,
SynapticsPrivate *priv,
int c;
while ((c = XisbRead(priv->comm.buffer)) >= 0) {
unsigned char u = (unsigned char)c;
- xf86write(priv->fifofd, &u, 1);
+ write(priv->fifofd, &u, 1);
if (++count >= 3)
break;
}
@@ -1402,10 +1405,10 @@ ComputeDeltas(SynapticsPrivate *priv, struct
SynapticsHwState *hw,
/* save the fraction, report the integer part */
tmpf = dx * speed + x_edge_speed * dtime + priv->frac_x;
- priv->frac_x = xf86modf(tmpf, &integral);
+ priv->frac_x = modf(tmpf, &integral);
dx = integral;
tmpf = dy * speed + y_edge_speed * dtime + priv->frac_y;
- priv->frac_y = xf86modf(tmpf, &integral);
+ priv->frac_y = modf(tmpf, &integral);
dy = integral;
}
More information about the xorg
mailing list