/*- * Copyright (c) 2008-2009, Volker Werth, vwe@ * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id$ */ /* * utouch.h - usb touchscreen declarations */ #ifndef _UTOUCH_H_ #define _UTOUCH_H_ #include #ifndef HUD_TOUCHSCREEN /* HID interface devices */ #warning "HID-profile: still using my own definition of a touchscreen" #define HUD_TOUCHSCREEN 0x04 /* usage page DIGITIZER, type TOUCHSCREEN */ #endif /* sc_flags */ #define UTF_ZUSAGEBROKEN 0x0001 /* device doesn't report it's Z usage correctly */ #define UTF_ZCLIP 0x0002 /* Z value clips (0xff) for touch area too big */ #define UTF_X_AXIS 0x0010 /* presents an X-axis */ #define UTF_Y_AXIS 0x0020 /* presents an Y-axis */ #define UTF_Z_AXIS 0x0040 /* presents pressure value (Z-axis) */ #define UTF_POSABS 0x0080 /* device reports absolute positions */ #define UTF_MSK_TYPE 0xff00 /* mask the device type */ #define UTF_INTR_STALL 0x80000000 /* set if transfer error */ #define UTF_ISHID 0x0100 /* is a (generic) HID device type */ #define UTF_IS_EGSAW 0x0200 /* eGalax (SAW) data packet */ #define UTF_IS_TSHARK 0x0400 /* Hampshire T-Shark */ #define UTF_IS_DTC 0x0800 /* DTC */ #define UTF_IS_ZYTRONIC 0x1000 /* Zytronic USB controller */ #define UTF_IS_3MTOUCH 0x2000 /* 3M MicroTouch */ /* quirks following here! deal with firmware bugs and other stuff */ /* GeneralTouch reports the pressure value (HUG_Z) as "unknown" */ #define _UT_HUG_PRESSURE 0x00 #define _UT_ZCLIP_VAL 0xff #define _UT_ZCLIP_FIX 0xffff #define _UT_PRESSURE 0x7f #define _UT_EGSAWSYN 0x80 #define _UT_EGSAWPRESS 0x01 #define _UT_EGSAWBITMASK 0x06 #define _UT_EGSAWCMD 0x0a #define _UT_TSHARK_PRESS 0x01 #define _UT_DTC_SYN 0x80 #define _UT_DTC_PRESS 0x40 #define _UT_3M_COORD 0x01 #define _UT_3M_PARAM 0x04 #define _UT_3M_STATUS 0x06 #define _UT_3M_CONTR 0x0c #define _3M_REQ_CALIB 0x04 #define _3M_REQ_STATUS 0x06 #define _3M_REQ_RESET 0x07 #define _3M_REQ_DEFAULTS 0x08 #define _3M_REQ_CTLID 0x0a #define _3M_REQ_READPAR 0x10 /* utouch DEFINES */ #define HACK_DEBUG_MODE 1 #define CAL_MSK_UL 0x10 #define CAL_MSK_UR 0x20 #define CAL_MSK_BR 0x40 #define CAL_MSK_BL 0x80 #define _UT_SIGNATURE1 't' #define _UT_SIGNATURE2 'S' #define _UT_VERSION 1 #define _UT_ABSOLUTE 0x0001 #define _UT_RELATIVE 0x0002 #define UT_GET_DEVTYPE( f ) ( f & UTF_MSK_TYPE ) #define UT_GET_HID( f ) ( UT_GET_DEVTYPE( f ) & UTF_ISHID ) #define UT_IS_HID( f ) (UT_GET_HID( f ) ? 1 : 0) #define UT_GET_EGSAW( f ) (UT_GET_DEVTYPE( f ) & UTF_IS_EGSAW ) #define UT_IS_EGSAW( f ) (UT_GET_EGSAW( f ) ? 1 : 0) typedef struct utouch_coord { u_int16_t x; u_int16_t y; u_int16_t pressure; } utouch_coord_t; typedef struct utouch_proto { char sig[2]; u_int8_t version; u_int8_t ssize; u_int16_t mode; utouch_coord_t coord; u_int8_t buttons; char res[1]; } utouch_proto_t; typedef struct utouch_status { utouch_coord_t poscurr; utouch_coord_t poslast; utouch_coord_t posmin; utouch_coord_t posmax; u_int8_t buttons; short pressed; short threshold; short calibrate; short updateflag; } utouch_status_t; /* legacy touch decoder functions */ /* prototype */ typedef uint8_t (touchdecode_t)(char buf[5], utouch_coord_t * coord); uint8_t decode_alphatouch(char buf[5], utouch_coord_t * coord); uint8_t decode_dtc(char buf[5], utouch_coord_t * coord); uint8_t decode_tshark(char buf[5], utouch_coord_t * coord); uint8_t decode_3mmut_ex(char buf[11], utouch_coord_t * coord); //#define TOUCH_CALIBRATE _IOWR('t', 32, ) #define TOUCH_GETSTATUS _IOR('t', 34, utouch_status_t ) #define TOUCH_GETPOSITION _IOR('t', 35, utouch_coord_t ) #define USB_VENDOR_GENERALTOUCH 0x0dfc #define USB_PRODUCT_GENERALTOUCH_ST6101U 0x0001 #define USB_PRODUCT_GENERALTOUCH_ST6101U_2 0x0002 #define USB_VENDOR_EGALAX 0x0eef #define USB_VENDOR_EGALAX_1 0x0123 #define USB_PRODUCT_SAWUSB 0x0001 #define USB_PRODUCT_SAWUSB_2 0x0002 #define USB_VENDOR_ZYTRONIC 0x14c8 #define USB_PRODUCT_ZYTRONIC_USB 0x0003 #define USB_VENDOR_3MTOUCH 0x0596 #define USB_PRODUCT_3M_EX 0x0001 static const struct utouch_product { u_int16_t vendor; u_int16_t product; u_int16_t flags; } utouch_products [] = { { USB_VENDOR_GENERALTOUCH, USB_PRODUCT_GENERALTOUCH_ST6101U, UTF_ZUSAGEBROKEN|UTF_ZCLIP|UTF_ISHID }, { USB_VENDOR_GENERALTOUCH, USB_PRODUCT_GENERALTOUCH_ST6101U_2, UTF_ZUSAGEBROKEN|UTF_ZCLIP|UTF_ISHID }, { USB_VENDOR_EGALAX, USB_PRODUCT_SAWUSB, UTF_IS_EGSAW }, { USB_VENDOR_EGALAX, USB_PRODUCT_SAWUSB_2, UTF_IS_EGSAW }, { USB_VENDOR_EGALAX_1, USB_PRODUCT_SAWUSB, UTF_IS_EGSAW }, { USB_VENDOR_3MTOUCH, USB_PRODUCT_3M_EX, UTF_IS_3MTOUCH }, { 0, 0, 0 } }; #ifndef USBD_ERR_CANCELLED /*#define USBD_ERR_CANCELLED USBD_CANCELLED*/ #endif #ifndef MAKE_WORD #define MAKE_WORD(b1,b2) (((b1) << 8) | (b2)) #endif #endif