diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-10-13 20:55:36 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-10-13 20:55:36 +0000 |
commit | 7f47ad24bdf4072baf8bc0f8aa203e65e0feca56 (patch) | |
tree | 14527d8743b64162abbaad6b2a5edcfc8b2544e7 /driver | |
parent | 8e286580df3e8b7ca7e4e5486eb4cd162cf86180 (diff) |
xf86-input-mutouch 1.2.1
Diffstat (limited to 'driver')
-rw-r--r-- | driver/xf86-input-mutouch/configure | 20 | ||||
-rw-r--r-- | driver/xf86-input-mutouch/configure.ac | 2 | ||||
-rw-r--r-- | driver/xf86-input-mutouch/src/xf86MuTouch.c | 676 |
3 files changed, 93 insertions, 605 deletions
diff --git a/driver/xf86-input-mutouch/configure b/driver/xf86-input-mutouch/configure index de6d6f9e2..24260999d 100644 --- a/driver/xf86-input-mutouch/configure +++ b/driver/xf86-input-mutouch/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for xf86-input-mutouch 1.2.0. +# Generated by GNU Autoconf 2.59 for xf86-input-mutouch 1.2.1. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>. # @@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='xf86-input-mutouch' PACKAGE_TARNAME='xf86-input-mutouch' -PACKAGE_VERSION='1.2.0' -PACKAGE_STRING='xf86-input-mutouch 1.2.0' +PACKAGE_VERSION='1.2.1' +PACKAGE_STRING='xf86-input-mutouch 1.2.1' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg' ac_unique_file="Makefile.am" @@ -966,7 +966,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures xf86-input-mutouch 1.2.0 to adapt to many kinds of systems. +\`configure' configures xf86-input-mutouch 1.2.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1032,7 +1032,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xf86-input-mutouch 1.2.0:";; + short | recursive ) echo "Configuration of xf86-input-mutouch 1.2.1:";; esac cat <<\_ACEOF @@ -1181,7 +1181,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -xf86-input-mutouch configure 1.2.0 +xf86-input-mutouch configure 1.2.1 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1195,7 +1195,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by xf86-input-mutouch $as_me 1.2.0, which was +It was created by xf86-input-mutouch $as_me 1.2.1, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1795,7 +1795,7 @@ fi # Define the identity of the package. PACKAGE='xf86-input-mutouch' - VERSION='1.2.0' + VERSION='1.2.1' cat >>confdefs.h <<_ACEOF @@ -20931,7 +20931,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by xf86-input-mutouch $as_me 1.2.0, which was +This file was extended by xf86-input-mutouch $as_me 1.2.1, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20994,7 +20994,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -xf86-input-mutouch config.status 1.2.0 +xf86-input-mutouch config.status 1.2.1 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/driver/xf86-input-mutouch/configure.ac b/driver/xf86-input-mutouch/configure.ac index 702bf2dd4..f4befa191 100644 --- a/driver/xf86-input-mutouch/configure.ac +++ b/driver/xf86-input-mutouch/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.57) AC_INIT([xf86-input-mutouch], - 1.2.0, + 1.2.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xf86-input-mutouch) diff --git a/driver/xf86-input-mutouch/src/xf86MuTouch.c b/driver/xf86-input-mutouch/src/xf86MuTouch.c index 0795e35fe..82c2a25fe 100644 --- a/driver/xf86-input-mutouch/src/xf86MuTouch.c +++ b/driver/xf86-input-mutouch/src/xf86MuTouch.c @@ -1,6 +1,6 @@ /* * Copyright 1996, 1999 by Patrick Lecoanet, France. <lecoanet@cena.dgac.fr> - * + * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that @@ -9,8 +9,8 @@ * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Patrick Lecoanet makes no * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * + * is provided "as is" without express or implied warranty. + * * PATRICK LECOANET DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL PATRICK LECOANET BE LIABLE FOR ANY SPECIAL, INDIRECT OR @@ -49,12 +49,8 @@ #include <string.h> #include <stdio.h> -#include "xf86Version.h" -#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(3,9,0,0,0) -#define XFREE86_V4 -#endif +#include "xorgVersion.h" -#ifdef XFREE86_V4 #include "misc.h" #include "xf86.h" #if !defined(DGUX) @@ -67,110 +63,8 @@ #include "xf86Module.h" #endif -#else /* XFREE86_V4 */ - -#include <X11/Xos.h> -#include <signal.h> -#include <stdio.h> -#define NEED_EVENTS -#include <X11/X.h> -#include <X11/Xproto.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> -#include "compiler.h" - -#include "xf86.h" -#include "xf86Procs.h" -#include "xf86_OSlib.h" -#include "xf86_Config.h" -#include "xf86Xinput.h" - -#include "os.h" -#include "osdep.h" -#include "exevents.h" - -#include "extnsionst.h" -#include "extinit.h" - -#endif /* XFREE86_V4 */ - - -#ifndef XFREE86_V4 -/* - *************************************************************************** - * - * Configuration descriptor. - * - *************************************************************************** - */ -#define FINGER_SECTION_NAME "microtouchfinger" -#define STYLUS_SECTION_NAME "microtouchstylus" - -#define PORT 1 -#define DEVICENAME 2 -#define SCREEN_NO 3 -#define MAXX 5 -#define MAXY 6 -#define MINX 7 -#define MINY 8 -#define DEBUG_LEVEL 9 -#define HISTORY_SIZE 10 -#define LINK_SPEED 11 -#define ALWAYS_CORE 12 -#define SWAP_AXES 13 -#define FREQUENCY 14 -#define PORTRAIT_MODE 15 - -static SymTabRec MuTTab[] = { - { ENDSUBSECTION, "endsubsection" }, - { PORT, "port" }, - { DEVICENAME, "devicename" }, - { SCREEN_NO, "screenno" }, - { MAXX, "maximumxposition" }, - { MAXY, "maximumyposition" }, - { MINX, "minimumxposition" }, - { MINY, "minimumyposition" }, - { DEBUG_LEVEL, "debuglevel" }, - { HISTORY_SIZE, "historysize" }, - { LINK_SPEED, "linkspeed" }, - { ALWAYS_CORE, "alwayscore" }, - { SWAP_AXES, "swapxy" }, - { FREQUENCY, "frequency" }, - { PORTRAIT_MODE, "portraitmode" }, - { -1, "" }, -}; - -#define LS300 1 -#define LS1200 2 -#define LS2400 3 -#define LS9600 4 -#define LS19200 5 - -static SymTabRec LinkSpeedTab[] = { - { LS300, "b300" }, - { LS1200, "b1200" }, - { LS2400, "b2400" }, - { LS9600, "b9600" }, - { LS19200, "b19200" } -}; - - -typedef struct { - int speed; -} LinkParameterStruct; - -static LinkParameterStruct LinkSpeedValues[] = { - { B300 }, - { B1200 }, - { B2400 }, - { B9600 }, - { B19200 } -}; -#endif /* XFREE86_V4 */ /* @@ -217,7 +111,7 @@ static LinkParameterStruct LinkSpeedValues[] = { #define MuT_RESTORE_DEFAULTS "RD" /* Restore factory settings. */ #define MuT_FORMAT_TABLET "FT" /* Report events using tablet format. */ #define MuT_FORMAT_RAW "FR" /* Report events in raw mode (no corrections). */ -#define MuT_CALIBRATE_RAW "CR" /* Calibration in raw mode. */ +#define MuT_CALIBRATE_RAW "CR" /* Calibration in raw mode. */ #define MuT_CALIBRATE_EXT "CX" /* Calibration in extended mode (cooked). */ #define MuT_OUTPUT_IDENT "OI" /* Ask some infos about the firmware. */ #define MuT_UNIT_TYPE "UT" /* Ask some more infos about the firmware. */ @@ -291,7 +185,6 @@ static int debug_level = 0; #define DBG(lvl, f) #endif -#ifdef XFREE86_V4 #undef SYSCALL #undef read #undef write @@ -300,7 +193,6 @@ static int debug_level = 0; #define read(fd, ptr, num) xf86ReadSerial(fd, ptr, num) #define write(fd, ptr, num) xf86WriteSerial(fd, ptr, num) #define close(fd) xf86CloseSerial(fd) -#endif /* @@ -313,16 +205,15 @@ static int debug_level = 0; #define FINGER_ID 1 #define STYLUS_ID 2 #define DEVICE_ID(flags) ((flags) & 0x03) - + typedef struct _MuTPrivateRec { char *input_dev; /* The touchscreen input tty */ int min_x; /* Minimum x reported by calibration */ int max_x; /* Maximum x */ int min_y; /* Minimum y reported by calibration */ int max_y; /* Maximum y */ -#ifndef XFREE86_V4 - int link_speed; /* Speed of the RS232 link connecting the ts. */ -#endif + int x_inverted; /* X axis inverted? */ + int y_inverted; /* Y axis inverted? */ int frequency; /* Frequency for ThruGlass */ int screen_no; /* Screen associated with the device */ int screen_width; /* Width of the associated X screen */ @@ -337,257 +228,6 @@ typedef struct _MuTPrivateRec { } MuTPrivateRec, *MuTPrivatePtr; -#ifndef XFREE86_V4 -/* - *************************************************************************** - * - * xf86MuTConfig -- - * Configure the driver from the configuration data. - * - *************************************************************************** - */ -static Bool -xf86MuTConfig(LocalDevicePtr *array, - int inx, - int max, - LexPtr val) -{ - LocalDevicePtr local = array[inx]; - MuTPrivatePtr priv = (MuTPrivatePtr)(local->private); - int token; - int portrait=0; - - while ((token = xf86GetToken(MuTTab)) != ENDSUBSECTION) { - switch(token) { - - case PORT: - if (xf86GetToken(NULL) != STRING) - xf86ConfigError("MicroTouch input port expected"); - else { - /* - * See if another X device share the same physical - * device and set up the links so that they share - * the same private structure (the one that controls - * the physical device). - */ - int i; - for (i = 0; i < max; i++) { - if (i == inx) - continue; - if (array[i]->device_config == xf86MuTConfig && - (strcmp(((MuTPrivatePtr) array[i]->private)->input_dev, - val->str) == 0)) { - ErrorF("%s MicroTouch config detected a device share between %s and %s\n", - XCONFIG_GIVEN, local->name, array[i]->name); - xfree(priv); - priv = local->private = array[i]->private; - switch (DEVICE_ID(local->private_flags)) { - case FINGER_ID: - priv->finger = local; - break; - case STYLUS_ID: - priv->stylus = local; - break; - } - break; - } - } - if (i == max) { - priv->input_dev = strdup(val->str); - if (xf86Verbose) - ErrorF("%s MicroTouch %s input port: %s\n", - XCONFIG_GIVEN, local->name, priv->input_dev); - } - } - break; - - case DEVICENAME: - if (xf86GetToken(NULL) != STRING) - xf86ConfigError("MicroTouch device name expected"); - local->name = strdup(val->str); - if (xf86Verbose) - ErrorF("%s MicroTouch %s X device name: %s\n", - XCONFIG_GIVEN, local->name, local->name); - break; - - case SCREEN_NO: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch screen number expected"); - priv->screen_no = val->num; - if (xf86Verbose) - ErrorF("%s MicroTouch %s associated screen: %d\n", - XCONFIG_GIVEN, local->name, priv->screen_no); - break; - - case LINK_SPEED: - { - int ltoken = xf86GetToken(LinkSpeedTab); - if (ltoken == EOF || - ltoken == STRING || - ltoken == NUMBER) - xf86ConfigError("MicroTouch link speed expected"); - priv->link_speed = LinkSpeedValues[ltoken-1].speed; - if (xf86Verbose) - ErrorF("%s MicroTouch %s link speed: %s bps\n", - XCONFIG_GIVEN, local->name, (LinkSpeedTab[ltoken-1].name)+1); - } - break; - - case MAXX: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch maximum x position expected"); - priv->max_x = val->num; - if (xf86Verbose) - ErrorF("%s MicroTouch %s maximum x position: %d\n", - XCONFIG_GIVEN, local->name, priv->max_x); - break; - - case MAXY: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch maximum y position expected"); - priv->max_y = val->num; - if (xf86Verbose) - ErrorF("%s Microtouch %s maximum y position: %d\n", - XCONFIG_GIVEN, local->name, priv->max_y); - break; - - case MINX: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch minimum x position expected"); - priv->min_x = val->num; - if (xf86Verbose) - ErrorF("%s MicroTouch %s minimum x position: %d\n", - XCONFIG_GIVEN, local->name, priv->min_x); - break; - - case MINY: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch minimum y position expected"); - priv->min_y = val->num; - if (xf86Verbose) - ErrorF("%s MicroTouch %s minimum y position: %d\n", - XCONFIG_GIVEN, local->name, priv->min_y); - break; - - case DEBUG_LEVEL: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch driver debug expected"); - debug_level = val->num; - if (xf86Verbose) { -#if DEBUG - ErrorF("%s MicroTouch %s debug level sets to %d\n", XCONFIG_GIVEN, - local->name, debug_level); -#else - ErrorF("%s MicroTouch %s debug not available\n", - XCONFIG_GIVEN, local->name, debug_level); -#endif - } - break; - - case HISTORY_SIZE: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch motion history size expected"); - local->history_size = val->num; - if (xf86Verbose) - ErrorF("%s MicroTouch %s motion history size is %d\n", XCONFIG_GIVEN, - local->name, local->history_size); - break; - - case FREQUENCY: - if (xf86GetToken(NULL) != NUMBER) - xf86ConfigError("MicroTouch ThruGlass frequency expected"); - priv->frequency = val->num; - if (xf86Verbose) - ErrorF("%s MicroTouch %s frequency is %d\n", XCONFIG_GIVEN, - local->name, priv->frequency); - break; - - case ALWAYS_CORE: - xf86AlwaysCore(local, TRUE); - if (xf86Verbose) - ErrorF("%s MicroTouch %s device will always stays core pointer\n", - XCONFIG_GIVEN, local->name); - break; - - case SWAP_AXES: - priv->swap_axes = 1; - if (xf86Verbose) { - ErrorF("%s Microtouch %s device will work with X and Y axes swapped\n", - XCONFIG_GIVEN, local->name); - } - break; - - case PORTRAIT_MODE: - if (xf86GetToken(NULL) != STRING) { - portrait_mode_err: - xf86ConfigError("Microtouch portrait mode should be: Portrait, Landscape or PortraitCCW"); - } - if (strcmp(val->str, "portrait") == 0) { - portrait = 1; - } - else if (strcmp(val->str, "portraitccw") == 0) { - portrait = -1; - } - else if (strcmp(val->str, "landscape") != 0) { - goto portrait_mode_err; - } - if (xf86Verbose) { - ErrorF("%s Microtouch %s device will work in %s mode\n", - XCONFIG_GIVEN, local->name, val->str); - } - break; - - case EOF: - FatalError("Unexpected EOF (missing EndSubSection)"); - break; - - default: - xf86ConfigError("MicroTouch subsection keyword expected"); - break; - } - } - - if (priv->max_x - priv->min_x <=0) { - ErrorF("%s MicroTouch: reverse x mode (minimum x position >= maximum x position)\n", - XCONFIG_GIVEN); - } - if (priv->max_y - priv->min_y <=0) { - ErrorF("%s MicroTouch: reverse y mode (minimum y position >= maximum y position)\n", - XCONFIG_GIVEN); - } - - /* - * The portrait adjustments need to be done after axis reversing - * and axes swap. This way the driver can cope with deffective - * hardware and still do the correct processing depending on the - * actual display orientation. - */ - if (portrait == 1) { - /* - * Portrait Clockwise: reverse Y axis and exchange X and Y. - */ - int tmp; - tmp = priv->min_y; - priv->min_y = priv->max_y; - priv->max_y = tmp; - priv->swap_axes = (priv->swap_axes==0) ? 1 : 0; - } - else if (portrait == -1) { - /* - * Portrait Counter Clockwise: reverse X axis and exchange X and Y. - */ - int tmp; - tmp = priv->min_x; - priv->min_x = priv->max_x; - priv->max_x = tmp; - priv->swap_axes = (priv->swap_axes==0) ? 1 : 0; - } - - DBG(2, ErrorF("xf86MuTConfig port name=%s\n", priv->input_dev)) - - return Success; -} -#endif /* @@ -632,15 +272,13 @@ xf86MuTConvert(LocalDevicePtr local, *x = (priv->screen_width * (input_x - priv->min_x)) / width; *y = (priv->screen_height - (priv->screen_height * (input_y - priv->min_y)) / height); - -#ifdef XFREE86_V4 + /* * Need to check if still on the correct screen. * This call is here so that this work can be done after * calib and before posting the event. */ xf86XInputSetScreen(local, priv->screen_no, *x, *y); -#endif return TRUE; } @@ -680,9 +318,9 @@ xf86MuTReadInput(LocalDevicePtr local) int num_bytes; int bytes_in_packet; unsigned char *ptr, *start_ptr; - + DBG(4, ErrorF("Entering ReadInput\n")); - + /* * Try to get a buffer full of report packets. */ @@ -737,19 +375,19 @@ xf86MuTReadInput(LocalDevicePtr local) if (bytes_in_packet == 5) { LocalDevicePtr local_to_use; - + /* * First stick together the various pieces. */ state = start_ptr[0] & 0x7F; cur_x = WORD_ASSEMBLY(start_ptr[1], start_ptr[2]); cur_y = WORD_ASSEMBLY(start_ptr[3], start_ptr[4]); - + DBG(3, ErrorF("Packet: 0x%X 0x%X 0x%X 0x%X 0x%X\n", start_ptr[0], start_ptr[1], start_ptr[2], start_ptr[3], start_ptr[4])); start_ptr = ptr; bytes_in_packet = 0; - + /* * Send events. * @@ -770,25 +408,29 @@ xf86MuTReadInput(LocalDevicePtr local) if (!local_to_use) { /* * We have received an event for a device which we don't care - * about. Drop it, but whinge first, just in case it's a + * about. Drop it, but whinge first, just in case it's a * misconfiguration. */ static int whinged = 0; if (!whinged) { whinged++; - ErrorF("MicroTouch screen sent %s event, but that device is not configured.\n", + ErrorF("MicroTouch screen sent %s event, but that device is not configured.\n", (state & MuT_WHICH_DEVICE)?"stylus":"finger"); ErrorF("You might want to consider altering your config accordingly.\n"); - } + } } else { /* * Emit a motion. If in core pointer mode we need to calibrate * or we will feed X with quite bogus event positions. */ + if (priv->x_inverted) + cur_x = priv->max_x - cur_x; + if (priv->y_inverted) + cur_y = priv->max_y - cur_y; xf86PostMotionEvent(local_to_use->dev, TRUE, 0, 2, cur_x, cur_y); - + /* * Emit a button press or release. */ @@ -890,7 +532,7 @@ xf86MuTGetReply(unsigned char *buffer, int num_bytes; DBG(4, ErrorF("Entering xf86MuTGetReply with buffer_p == %d\n", *buffer_p)); - + /* * Try to read enough bytes to fill up the packet buffer. */ @@ -899,7 +541,7 @@ xf86MuTGetReply(unsigned char *buffer, SYSCALL(num_bytes = read(fd, (char *) (buffer + *buffer_p), MuT_BUFFER_SIZE - *buffer_p)); - + /* * Okay, give up. */ @@ -908,7 +550,7 @@ xf86MuTGetReply(unsigned char *buffer, return !Success; } DBG(4, ErrorF("Read %d bytes of reply\n", num_bytes)); - + while (num_bytes) { /* * Sync with the start of a packet. @@ -953,24 +595,6 @@ xf86MuTGetReply(unsigned char *buffer, * *************************************************************************** */ -#ifndef XFREE86_V4 -static int -xf86WaitForInput(int fd, - int timeout) -{ - fd_set readfds; - struct timeval to; - int r; - - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - to.tv_sec = 0; - to.tv_usec = timeout; - - SYSCALL(r = select(FD_SETSIZE, &readfds, NULL, NULL, &to)); - return r; -} -#endif static Bool xf86MuTWaitReply(unsigned char *reply, @@ -985,7 +609,7 @@ xf86MuTWaitReply(unsigned char *reply, i = MuT_MAX_TRIALS; do { ok = !Success; - + /* * Wait half a second for the reply. The fuse counts down each * timeout and each wrong packet. @@ -1007,7 +631,7 @@ xf86MuTWaitReply(unsigned char *reply, else { DBG(3, ErrorF("No answer from port : %d\n", result)); } - + if (result == 0) i--; } while(ok != Success && i); @@ -1036,7 +660,7 @@ xf86MuTSendCommand(unsigned char *request, int fd) { Bool ok; - + if (xf86MuTSendPacket(request, len, fd) == Success) { ok = xf86MuTWaitReply(reply, fd); return ok; @@ -1059,8 +683,7 @@ static void xf86MuTPrintIdent(unsigned char *packet) { int vers, rev; - -#ifdef XFREE86_V4 + xf86Msg(X_PROBED, "MicroTouch touchscreen is a "); if (strncmp((char *) &packet[1], MuT_TOUCH_PEN_IDENT, 2) == 0) { xf86Msg(X_NONE, "TouchPen"); @@ -1074,21 +697,6 @@ xf86MuTPrintIdent(unsigned char *packet) xf86Msg(X_NONE, ", connected through a serial port.\n"); sscanf((char *) &packet[3], "%2d%2d", &vers, &rev); xf86Msg(X_PROBED, "MicroTouch controller firmware revision is %d.%d.\n", vers, rev); -#else - ErrorF("%s MicroTouch touchscreen is a ", XCONFIG_PROBED); - if (strncmp((char *) &packet[1], MuT_TOUCH_PEN_IDENT, 2) == 0) { - ErrorF("TouchPen"); - } - else if (strncmp((char *) &packet[1], MuT_SMT3_IDENT, 2) == 0) { - ErrorF("Serial/SMT3"); - } - else if (strncmp((char *) &packet[1], MuT_THRU_GLASS_IDENT, 2) == 0) { - ErrorF("ThruGlass"); - } - ErrorF(", connected through a serial port.\n"); - sscanf((char *) &packet[3], "%2d%2d", &vers, &rev); - ErrorF("%s MicroTouch controller firmware revision is %d.%d.\n", XCONFIG_PROBED, vers, rev); -#endif } @@ -1104,11 +712,7 @@ xf86MuTPrintIdent(unsigned char *packet) static void xf86MuTPrintHwStatus(unsigned char *packet) { -#ifdef XFREE86_V4 xf86Msg(X_PROBED, "MicroTouch status of errors: %c%c.\n", packet[7], packet[8]); -#else - ErrorF("%s MicroTouch status of errors: %c%c.\n", XCONFIG_PROBED, packet[7], packet[8]); -#endif } @@ -1145,7 +749,7 @@ xf86MuTControl(DeviceIntPtr dev, unsigned char req[MuT_PACKET_SIZE]; unsigned char reply[MuT_BUFFER_SIZE]; char *id_string = DEVICE_ID(local->private_flags) == FINGER_ID ? "finger" : "stylus"; - + switch(mode) { case DEVICE_INIT: @@ -1166,7 +770,7 @@ xf86MuTControl(DeviceIntPtr dev, ErrorF("Unable to allocate ButtonClassDeviceStruct\n"); return !Success; } - + /* * Device reports motions on 2 axes in absolute coordinates. * Axes min and max values are reported in raw coordinates. @@ -1174,7 +778,10 @@ xf86MuTControl(DeviceIntPtr dev, * max and min values scaled from the approximate size of the * screen to fit one meter. */ - if (InitValuatorClassDeviceStruct(dev, 2, xf86GetMotionEvents, + if (InitValuatorClassDeviceStruct(dev, 2, +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3 + xf86GetMotionEvents, +#endif local->history_size, Absolute) == FALSE) { ErrorF("Unable to allocate ValuatorClassDeviceStruct\n"); return !Success; @@ -1189,32 +796,29 @@ xf86MuTControl(DeviceIntPtr dev, 0 /* min_res */, 10500 /* max_res */); } - + if (InitFocusClassDeviceStruct(dev) == FALSE) { ErrorF("Unable to allocate FocusClassDeviceStruct\n"); } - + /* * Allocate the motion events buffer. */ xf86MotionHistoryAllocate(local); - + /* * This once has caused the server to crash after doing an xalloc & strcpy ?? */ -#ifndef XFREE86_V4 - AssignTypeAndName(dev, local->atom, local->name); -#endif - + DBG(2, ErrorF("Done.\n")); return Success; } - + case DEVICE_ON: { Bool already_open = FALSE; char *report_what = ""; - + DBG(2, ErrorF("MicroTouch %s on...\n", id_string)); /* @@ -1241,51 +845,20 @@ xf86MuTControl(DeviceIntPtr dev, } } if (!already_open) { -#ifndef XFREE86_V4 - struct termios termios_tty; - int result; -#endif - + DBG(2, ErrorF("MicroTouch touchscreen opening : %s\n", priv->input_dev)); -#ifdef XFREE86_V4 local->fd = xf86OpenSerial(local->options); if (local->fd < 0) { Error("Unable to open MicroTouch touchscreen device"); return !Success; } -#else - SYSCALL(local->fd = open(priv->input_dev, O_RDWR|O_NDELAY, 0)); - if (local->fd < 0) { - Error("Unable to open MicroTouch touchscreen device"); - return !Success; - } - - /* - * Try to see if the link is at the specified rate and - * reset the controller. The wait time needed by the - * controller after reset should be compensated by the - * timeouts in the receive section. - */ - DBG(3, ErrorF("Try to see if the link is at the specified rate\n")); - memset(&termios_tty, 0, sizeof(termios_tty)); - termios_tty.c_cflag = priv->link_speed | CS8 | CREAD | CLOCAL; -#ifdef CRTSCTS - termios_tty.c_cflag &= ~CRTSCTS; -#endif - termios_tty.c_cc[VMIN] = 1; - SYSCALL(result = tcsetattr(local->fd, TCSANOW, &termios_tty)); - if (result < 0) { - Error("Unable to configure MicroTouch touchscreen port"); - goto not_success; - } -#endif memset(req, 0, MuT_PACKET_SIZE); strncpy((char *) &req[1], MuT_RESET, strlen(MuT_RESET)); if (xf86MuTSendCommand(req, strlen(MuT_RESET), NULL, local->fd) != Success) { DBG(3, ErrorF("Not at the specified rate, giving up\n")); goto not_success; } - + /* * ask the controller to report identity and status. */ @@ -1305,7 +878,7 @@ xf86MuTControl(DeviceIntPtr dev, goto not_success; } xf86MuTPrintHwStatus(reply); - + /* * Set the operating mode: Format Tablet, Mode stream, Pen. */ @@ -1332,11 +905,7 @@ xf86MuTControl(DeviceIntPtr dev, goto not_success; } /* goto not_success;*/ -#ifndef XFREE86_V4 - xf86AddEnabledDevice(local); -#else AddEnabledDevice(local->fd); -#endif } /* @@ -1369,7 +938,7 @@ xf86MuTControl(DeviceIntPtr dev, ((strcmp(report_what, MuT_PEN_ONLY) == 0) ? "Pen Only" : "Finger Only")); goto not_success; } - dev->public.on = TRUE; + dev->public.on = TRUE; /* * Set frequency for ThruGlass */ @@ -1385,16 +954,16 @@ xf86MuTControl(DeviceIntPtr dev, } } - + DBG(2, ErrorF("Done\n")); return Success; - + not_success: SYSCALL(close(local->fd)); local->fd = -1; return !Success; } - + /* * Deactivate the device. */ @@ -1403,7 +972,7 @@ xf86MuTControl(DeviceIntPtr dev, dev->public.on = FALSE; DBG(2, ErrorF("Done\n")); return Success; - + /* * Final close before server exit. This is used during server shutdown. * Close the port and free all the resources. @@ -1412,11 +981,7 @@ xf86MuTControl(DeviceIntPtr dev, DBG(2, ErrorF("MicroTouch %s close...\n", id_string)); dev->public.on = FALSE; if (local->fd >= 0) { -#ifdef XFREE86_V4 xf86RemoveEnabledDevice(local); -#else - RemoveEnabledDevice(local->fd); -#endif SYSCALL(close(local->fd)); local->fd = -1; /* @@ -1434,7 +999,7 @@ xf86MuTControl(DeviceIntPtr dev, } } } - DBG(2, ErrorF("Done\n")); + DBG(2, ErrorF("Done\n")); return Success; default: @@ -1451,24 +1016,14 @@ xf86MuTControl(DeviceIntPtr dev, *************************************************************************** */ static LocalDevicePtr -#ifndef XFREE86_V4 -xf86MuTAllocate(char *name, - char *type_name, - int flag) -#else xf86MuTAllocate(InputDriverPtr drv, char *name, char *type_name, int flag) -#endif { -#ifndef XFREE86_V4 - LocalDevicePtr local = (LocalDevicePtr) xalloc(sizeof(LocalDeviceRec)); -#else LocalDevicePtr local = xf86AllocateInput(drv, 0); -#endif MuTPrivatePtr priv = (MuTPrivatePtr) xalloc(sizeof(MuTPrivateRec)); - + if (!local) { if (priv) { xfree(priv); @@ -1483,9 +1038,6 @@ xf86MuTAllocate(InputDriverPtr drv, } priv->input_dev = strdup(MuT_PORT); -#ifndef XFREE86_V4 - priv->link_speed = MuT_LINK_SPEED; -#endif priv->min_x = 0; priv->max_x = 0; priv->min_y = 0; @@ -1500,12 +1052,9 @@ xf86MuTAllocate(InputDriverPtr drv, priv->finger = NULL; priv->swap_axes = 0; priv->frequency = 0; - + local->name = name; local->flags = 0 /* XI86_NO_OPEN_ON_INIT */; -#ifndef XFREE86_V4 - local->device_config = xf86MuTConfig; -#endif local->device_control = xf86MuTControl; local->read_input = xf86MuTReadInput; local->control_proc = NULL; @@ -1520,7 +1069,7 @@ xf86MuTAllocate(InputDriverPtr drv, local->private_flags = flag; local->type_name = type_name; local->history_size = 0; - + return local; } @@ -1533,22 +1082,14 @@ xf86MuTAllocate(InputDriverPtr drv, *************************************************************************** */ static LocalDevicePtr -#ifndef XFREE86_V4 -xf86MuTAllocateFinger(void) -#else -xf86MuTAllocateFinger(InputDriverPtr drv) -#endif +xf86MuTAllocateFinger(InputDriverPtr drv) { -#ifndef XFREE86_V4 - LocalDevicePtr local = xf86MuTAllocate(XI_FINGER, "MicroTouch Finger", FINGER_ID); -#else LocalDevicePtr local = xf86MuTAllocate(drv, XI_FINGER, "MicroTouch Finger", FINGER_ID); -#endif if (local) { ((MuTPrivatePtr) local->private)->finger = local; } - return local; + return local; } @@ -1560,17 +1101,9 @@ xf86MuTAllocateFinger(InputDriverPtr drv) *************************************************************************** */ static LocalDevicePtr -#ifndef XFREE86_V4 -xf86MuTAllocateStylus(void) -#else -xf86MuTAllocateStylus(InputDriverPtr drv) -#endif +xf86MuTAllocateStylus(InputDriverPtr drv) { -#ifndef XFREE86_V4 - LocalDevicePtr local = xf86MuTAllocate(XI_STYLUS, "MicroTouch Stylus", STYLUS_ID); -#else LocalDevicePtr local = xf86MuTAllocate(drv, XI_STYLUS, "MicroTouch Stylus", STYLUS_ID); -#endif if (local) { ((MuTPrivatePtr) local->private)->stylus = local; @@ -1579,70 +1112,13 @@ xf86MuTAllocateStylus(InputDriverPtr drv) } -#ifndef XFREE86_V4 -/* - *************************************************************************** - * - * MicroTouch finger device association -- - * - *************************************************************************** - */ -DeviceAssocRec MuT_finger_assoc = -{ - FINGER_SECTION_NAME, /* config_section_name */ - xf86MuTAllocateFinger /* device_allocate */ -}; - -/* - *************************************************************************** - * - * MicroTouch stylus device association -- - * - *************************************************************************** - */ -DeviceAssocRec MuT_stylus_assoc = -{ - STYLUS_SECTION_NAME, /* config_section_name */ - xf86MuTAllocateStylus /* device_allocate */ -}; - - -#ifdef DYNAMIC_MODULE -/* - *************************************************************************** - * - * entry point of dynamic loading - * - *************************************************************************** - */ -int -#ifndef DLSYM_BUG -init_module(unsigned long server_version) -#else -init_xf86MuTouch(unsigned long server_version) -#endif -{ - xf86AddDeviceAssoc(&MuT_finger_assoc); - xf86AddDeviceAssoc(&MuT_stylus_assoc); - - if (server_version != XF86_VERSION_CURRENT) { - ErrorF("Warning: MicroTouch module compiled for version%s\n", XF86_VERSION); - return 0; - } - else { - return 1; - } -} -#endif - -#else /* XFREE86_V4 */ static void xf86MuTUninit(InputDriverPtr drv, LocalDevicePtr local, int flags) { MuTPrivatePtr priv = (MuTPrivatePtr) local->private; - + xf86MuTControl(local->dev, DEVICE_OFF); if (priv) { @@ -1683,7 +1159,7 @@ xf86MuTInit(InputDriverPtr drv, goto init_err; } fake_local->conf_idev = dev; - + xf86CollectInputOptions(fake_local, default_options, NULL); str = xf86FindOptionValue(fake_local->options, "Type"); @@ -1706,7 +1182,7 @@ xf86MuTInit(InputDriverPtr drv, local->conf_idev = fake_local->conf_idev; xfree(fake_local); fake_local = NULL; - + str = xf86FindOptionValue(local->options, "Device"); if (!str) { xf86Msg(X_ERROR, "%s: No Device specified in Microtouch module config.\n", @@ -1749,14 +1225,14 @@ xf86MuTInit(InputDriverPtr drv, /* Process the common options. */ xf86ProcessCommonOptions(local, local->options); - + str = xf86FindOptionValue(local->options, "DeviceName"); if (str) { local->name = strdup(str); } - xf86Msg(X_CONFIG, "Microtouch X device name: %s\n", local->name); + xf86Msg(X_CONFIG, "Microtouch X device name: %s\n", local->name); priv->screen_no = xf86SetIntOption(local->options, "ScreenNo", 0); - xf86Msg(X_CONFIG, "Microtouch associated screen: %d\n", priv->screen_no); + xf86Msg(X_CONFIG, "Microtouch associated screen: %d\n", priv->screen_no); priv->max_x = xf86SetIntOption(local->options, "MaxX", 3000); xf86Msg(X_CONFIG, "Microtouch maximum x position: %d\n", priv->max_x); priv->min_x = xf86SetIntOption(local->options, "MinX", 0); @@ -1775,9 +1251,9 @@ xf86MuTInit(InputDriverPtr drv, debug_level = xf86SetIntOption(local->options, "DebugLevel", 0); if (debug_level) { #if DEBUG - xf86Msg(X_CONFIG, "Microtouch debug level sets to %d\n", debug_level); + xf86Msg(X_CONFIG, "Microtouch debug level sets to %d\n", debug_level); #else - xf86Msg(X_INFO, "Microtouch debug not available\n"); + xf86Msg(X_INFO, "Microtouch debug not available\n"); #endif } str = xf86SetStrOption(local->options, "PortraitMode", "Landscape"); @@ -1791,14 +1267,27 @@ xf86MuTInit(InputDriverPtr drv, xf86Msg(X_ERROR, "Microtouch portrait mode should be: Portrait, Landscape or PortraitCCW"); str = "Landscape"; } - xf86Msg(X_CONFIG, "Microtouch device will work in %s mode\n", str); - + xf86Msg(X_CONFIG, "Microtouch device will work in %s mode\n", str); + if (priv->max_x - priv->min_x <= 0) { + int tmp; xf86Msg(X_INFO, "MicroTouch: reverse x mode (minimum x position >= maximum x position)\n"); - } + tmp = priv->max_x; /* X server doesn't do inverted by itself*/ + priv->max_x = priv->min_x; + priv->min_x = tmp; + priv->x_inverted = TRUE; + } else + priv->x_inverted = FALSE; + if (priv->max_y - priv->min_y <= 0) { - xf86Msg(X_INFO, "MicroTouch: reverse y mode (minimum y position >= maximum y position)\n"); - } + int tmp; + xf86Msg(X_INFO, "MicroTouch: reverse y mode (minimum y position >= maximum y position)\n"); + tmp = priv->max_y; + priv->max_y = priv->min_y; + priv->min_y = tmp; + priv->y_inverted = TRUE; + } else + priv->y_inverted = FALSE; if (portrait == 1) { /* @@ -1890,4 +1379,3 @@ static XF86ModuleVersionInfo version_rec = { _X_EXPORT XF86ModuleData mutouchModuleData = { &version_rec, Plug, Unplug }; #endif -#endif /* XFREE86_V4 */ |