diff options
author | Nicolas Bruguier <nicolas.bruguier@supersonicimagine.fr> | 2009-05-20 00:06:53 +0200 |
---|---|---|
committer | Nicolas Bruguier <gandalfn@rohan.(none)> | 2009-05-20 00:06:53 +0200 |
commit | 7cfaac7434728b225ef623c46bd49e361b926ff7 (patch) | |
tree | 28b494db49b0ab52ff109f43694ace9680cfc222 | |
parent | d4d578a0481aa54f1df920b0a2903b8679256679 (diff) |
Start implementation of hal configuration write on property change.
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/evtouch2.c | 124 |
3 files changed, 124 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac index 6d47cf0..dd3f462 100644 --- a/configure.ac +++ b/configure.ac @@ -53,6 +53,14 @@ AC_ARG_WITH(xorg-module-dir, inputdir=${moduledir}/input AC_SUBST(inputdir) +AC_ARG_WITH(config-dir, + AC_HELP_STRING([--with-config-dir=DIR], + [Default driver config directory [[default=$sysconfdir/evtouch2]]]), + [configdir="$withval"], + [configdir="$sysconfdir/evtouch2"]) +EVTOUCH2_CONFIG_FILE=$configdir/evtouch2.conf +AC_SUBST(EVTOUCH2_CONFIG_FILE) + # Checks for extensions XORG_DRIVER_CHECK_EXT(XINPUT, inputproto) diff --git a/src/Makefile.am b/src/Makefile.am index 2927994..0029db7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,7 @@ # -avoid-version prevents gratuitous .0.0.0 version numbers on the end # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -AM_CFLAGS = $(XORG_CFLAGS) +AM_CFLAGS = $(XORG_CFLAGS) -DEVTOUCH2_CONFIG_FILE=\""$(EVTOUCH2_CONFIG_FILE)"\" @DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version diff --git a/src/evtouch2.c b/src/evtouch2.c index 1d947ce..0317a27 100644 --- a/src/evtouch2.c +++ b/src/evtouch2.c @@ -57,8 +57,15 @@ #endif /***************************************************************************** - * Variables without includable headers + * Defines ****************************************************************************/ +#define EVTOUCH2_DEFAULT_DEBUG_LEVEL 0 +#define EVTOUCH2_DEFAULT_TOUCH_BUTTON 0 +#define EVTOUCH2_DEFAULT_EMULATE3 FALSE +#define EVTOUCH2_DEFAULT_EMULATE3_TIMEOUT 50 +#define EVTOUCH2_DEFAULT_SWAP_X FALSE +#define EVTOUCH2_DEFAULT_SWAP_Y FALSE +#define EVTOUCH2_DEFAULT_SWAP_AXES FALSE /***************************************************************************** * Local Variables @@ -117,7 +124,9 @@ static XF86ModuleVersionInfo EvTouch2VersionRec = MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, - 0, 1, 0, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, ABI_CLASS_XINPUT, ABI_XINPUT_VERSION, MOD_CLASS_XINPUT, @@ -1206,14 +1215,18 @@ EVTouch2PreInit(InputDriverPtr drv, IDevPtr dev, int flags) priv->phys_height); priv->touch_button = xf86SetIntOption(local->options, - "TouchButtonEmulate", 1); + "TouchButtonEmulate", + EVTOUCH2_DEFAULT_TOUCH_BUTTON); priv->emulate3.enabled = xf86SetBoolOption(local->options, - "Emulate3Buttons", FALSE); + "Emulate3Buttons", + EVTOUCH2_DEFAULT_EMULATE3); priv->emulate3.timeout = xf86SetIntOption(local->options, - "Emulate3Timeout", 50); + "Emulate3Timeout", + EVTOUCH2_DEFAULT_EMULATE3_TIMEOUT); - debug_level = xf86SetIntOption(local->options, "DebugLevel", 0); + debug_level = xf86SetIntOption(local->options, "DebugLevel", + EVTOUCH2_DEFAULT_DEBUG_LEVEL); libtouchSetDebugLevel(debug_level); timeo = xf86SetIntOption(local->options, "TapTimer", 90); @@ -1240,9 +1253,12 @@ EVTouch2PreInit(InputDriverPtr drv, IDevPtr dev, int flags) } } - priv->swap_y = xf86SetBoolOption(local->options, "SwapY", FALSE); - priv->swap_x = xf86SetBoolOption(local->options, "SwapX", FALSE); - priv->swap_axes = xf86SetBoolOption(local->options, "SwapAxes", FALSE); + priv->swap_y = xf86SetBoolOption(local->options, "SwapY", + EVTOUCH2_DEFAULT_SWAP_Y); + priv->swap_x = xf86SetBoolOption(local->options, "SwapX", + EVTOUCH2_DEFAULT_SWAP_X); + priv->swap_axes = xf86SetBoolOption(local->options, "SwapAxes", + EVTOUCH2_DEFAULT_SWAP_AXES); /* get calibration parameters from XF86Config @@ -1470,6 +1486,94 @@ EVTouch2InitProperty(DeviceIntPtr dev) XISetDevicePropertyDeletable(dev, prop_calibration_axes_diff, FALSE); } +static void +EVTouch2WriteHalConfig(EVTouch2PrivatePtr priv) +{ + int fd; + char line[512]; + + fd = open(EVTOUCH2_CONFIG_FILE, O_CREAT | O_TRUNC | O_RDWR, 0644); + if (fd < 0) + { + xf86ErrorFVerb(2, "open " EVTOUCH2_CONFIG_FILE " failed\n"); + return; + } + + memset(line, 0, 512); + snprintf(line, 512, "# configuration file autogenerated do not edit directly\n"); + write(fd, line, strlen(line)); + + if (debug_level != EVTOUCH2_DEFAULT_DEBUG_LEVEL) + { + memset(line, 0, 512); + snprintf(line, 512, "DebugLevel=%d\n", debug_level); + write(fd, line, strlen(line)); + } + + if (priv->touch_button != EVTOUCH2_DEFAULT_TOUCH_BUTTON) + { + memset(line, 0, 512); + snprintf(line, 512, "TouchButtonEmulate=%d\n", priv->touch_button); + write(fd, line, strlen(line)); + } + + if (priv->emulate3.enabled != EVTOUCH2_DEFAULT_EMULATE3) + { + memset(line, 0, 512); + snprintf(line, 512, "Emulate3Buttons=%s\n", + priv->emulate3.enabled ? "true" : "false"); + write(fd, line, strlen(line)); + } + + if (priv->emulate3.timeout != EVTOUCH2_DEFAULT_EMULATE3_TIMEOUT) + { + memset(line, 0, 512); + snprintf(line, 512, "Emulate3Timeout=%d\n", priv->emulate3.timeout); + write(fd, line, strlen(line)); + } + + if (priv->swap_x != EVTOUCH2_DEFAULT_SWAP_X) + { + memset(line, 0, 512); + snprintf(line, 512, "SwapX=%s\n", + priv->swap_x ? "True" : "False"); + write(fd, line, strlen(line)); + } + + if (priv->swap_y != EVTOUCH2_DEFAULT_SWAP_Y) + { + memset(line, 0, 512); + snprintf(line, 512, "SwapY=%s\n", + priv->swap_y ? "True" : "False"); + write(fd, line, strlen(line)); + } + + if (priv->swap_axes != EVTOUCH2_DEFAULT_SWAP_AXES) + { + memset(line, 0, 512); + snprintf(line, 512, "SwapAxes=%s\n", + priv->swap_axes ? "True" : "False"); + write(fd, line, strlen(line)); + } + + if (priv->pan_viewport.width > 0 && priv->pan_viewport.height > 0) + { + memset(line, 0, 512); + snprintf(line, 512, "PanViewportGeometry=%dx%d\n", + priv->pan_viewport.width, priv->pan_viewport.height); + write(fd, line, strlen(line)); + + if (priv->pan_viewport.x > 0 || priv->pan_viewport.y > 0) + { + memset(line, 0, 512); + snprintf(line, 512, "PanViewportPosition=%d,%d\n", + priv->pan_viewport.x, priv->pan_viewport.y); + write(fd, line, strlen(line)); + } + } + close (fd); +} + static int EVTouch2SetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, BOOL checkonly) @@ -1643,6 +1747,8 @@ EVTouch2SetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, priv->calibration.enabled = FALSE; } } + + EVTouch2WriteHalConfig(priv); return Success; } |