/*- * 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$ */ /* * touch_controller.c - device specific (legacy) decoder functions */ #include #include #include #include #include "utouch.h" /* * proto spec - legacy protocols: * * where T = touch-status (1=touched, 0=untouched) * * eGalax (alphatouch) SAW32PA5: * Bit 7 6 5 4 3 2 1 0 * byte 1: 1 0 0 0 0 0 0 T * byte 2: 0 0 0 0 x10 x9 x8 x7 * byte 3: 0 x6 x5 x4 x3 x2 x1 x0 * byte 4: 0 0 0 0 y10 y9 y8 y7 * byte 5: 0 y6 y5 y4 y3 y2 y1 y0 * * * Hampshire TShark * Bit 7 6 5 4 3 2 1 0 * byte 1: 0 0 0 0 0 0 0 T * byte 2: x7 x6 x5 x4 x3 x2 x1 x0 * byte 3: 0 0 0 0 x11 x10 x9 x8 * byte 4: y7 y6 y5 y4 y3 y2 y1 y0 * byte 5: 0 0 0 0 y11 y10 y9 y8 * * * Digitech DTC-01U: * Bit 7 6 5 4 3 2 1 0 * byte 1: 1 T x11 x10 x9 x8 x7 x6 * byte 2: 0 T y11 y10 y9 y8 y7 y6 * byte 3: 0 T x5 x4 x3 x2 x1 x0 * byte 4: 0 T y5 y4 y3 y2 y1 y0 * * * 3M MicroTouch * * Bit 7 6 5 4 3 2 1 0 * byte 1: 0 0 0 0 0 0 0 1 * byte 2: (loop counter) * byte 3: 1 T 0 0 0 0 0 0 * byte 4: compensated X 0 * byte 5: compensated X 1 * byte 6: compensated Y 0 * byte 7: compensated Y 1 * byte 8: raw X 0 * byte 9: raw X 1 * byte a: raw Y 0 * byte b: raw Y 1 * * * elotouch smartset * * * semtech * */ /* * decoder for eGalax (alphatouch) SAW32PA5 */ uint8_t decode_alphatouch(char buf[5], utouch_coord_t * coord) { if (buf == NULL || coord == NULL) return (1); //if(UT_IS_EGSAW(sc->sc_flags)) { if(buf[0] & _UT_EGSAWSYN) { if(buf[0] & _UT_EGSAWPRESS) { coord->pressure = _UT_PRESSURE; //buttons = 1; } else { coord->pressure = 0; //buttons = 0; } coord->x = buf[1] << 7 | buf[2]; coord->y = buf[3] << 7 | buf[4]; return(0); } else { if((buf[0] & _UT_EGSAWCMD) == _UT_EGSAWCMD) { /* command response received - what do we do now? */ coord->x = coord->y = coord->pressure = 0; } } return(1); } uint8_t decode_tshark(char buf[5], utouch_coord_t * coord) { if (buf == NULL || coord == NULL) return (1); if (buf[0] & 0x01) coord->pressure = _UT_PRESSURE; else coord->pressure = 0; coord->x = buf[2] << 8 | buf[1]; coord->y = buf[4] << 8 | buf[3]; return (0); } uint8_t decode_dtc(char buf[5], utouch_coord_t * coord) { if (buf == NULL || coord == NULL) return (1); if (buf[0] & 0x80) { if (buf[0] & 0x40) coord->pressure = _UT_PRESSURE; else coord->pressure = 0; coord->x = buf[2] << 8 | buf[1]; coord->y = buf[4] << 8 | buf[3]; return (0); } return (1); } /* 3M MicroTouch USB EX111/121 */ uint8_t decode_3mmut_ex(char buf[11], utouch_coord_t * coord) { int i; if (buf == NULL || coord == NULL) return (1); if (buf[0] == 0x1 && buf[2] & 0x80) { for( i=0; i<11; i++) printf(" %02x", ((char)buf[i]&0xff)); printf("\n"); if (buf[2] & 0x40) coord->pressure = _UT_PRESSURE; else coord->pressure = 0; /* use raw data */ /* * according to the documentation, the raw data * is in the range of -8192 to 8192 * make sure, we got a positive value by adding 8192 */ coord->x = (int)(buf[8] << 8 | buf[7]); coord->y = (int)(buf[10] << 8 | buf[9]); return (0); } return (1); }