synproto.h revision b85037db
1b85037dbSmrg/* 2b85037dbSmrg * Copyright © 2004 Peter Osterlund 3b85037dbSmrg * 4b85037dbSmrg * Permission to use, copy, modify, distribute, and sell this software 5b85037dbSmrg * and its documentation for any purpose is hereby granted without 6b85037dbSmrg * fee, provided that the above copyright notice appear in all copies 7b85037dbSmrg * and that both that copyright notice and this permission notice 8b85037dbSmrg * appear in supporting documentation, and that the name of Red Hat 9b85037dbSmrg * not be used in advertising or publicity pertaining to distribution 10b85037dbSmrg * of the software without specific, written prior permission. Red 11b85037dbSmrg * Hat makes no representations about the suitability of this software 12b85037dbSmrg * for any purpose. It is provided "as is" without express or implied 13b85037dbSmrg * warranty. 14b85037dbSmrg * 15b85037dbSmrg * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16b85037dbSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 17b85037dbSmrg * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18b85037dbSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 19b85037dbSmrg * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 20b85037dbSmrg * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21b85037dbSmrg * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22b85037dbSmrg * 23b85037dbSmrg * Authors: 24b85037dbSmrg * Peter Osterlund (petero2@telia.com) 25b85037dbSmrg */ 26b85037dbSmrg 27b85037dbSmrg#ifndef _SYNPROTO_H_ 28b85037dbSmrg#define _SYNPROTO_H_ 29b85037dbSmrg 30b85037dbSmrg#include <unistd.h> 31b85037dbSmrg#include <sys/ioctl.h> 32b85037dbSmrg#include <xf86Xinput.h> 33b85037dbSmrg#include <xisb.h> 34b85037dbSmrg 35b85037dbSmrg/* 36b85037dbSmrg * A structure to describe the state of the touchpad hardware (buttons and pad) 37b85037dbSmrg */ 38b85037dbSmrgstruct SynapticsHwState { 39b85037dbSmrg int millis; /* Timestamp in milliseconds */ 40b85037dbSmrg int x; /* X position of finger */ 41b85037dbSmrg int y; /* Y position of finger */ 42b85037dbSmrg int z; /* Finger pressure */ 43b85037dbSmrg int numFingers; 44b85037dbSmrg int fingerWidth; 45b85037dbSmrg 46b85037dbSmrg Bool left; 47b85037dbSmrg Bool right; 48b85037dbSmrg Bool up; 49b85037dbSmrg Bool down; 50b85037dbSmrg 51b85037dbSmrg Bool multi[8]; 52b85037dbSmrg Bool middle; /* Some ALPS touchpads have a middle button */ 53b85037dbSmrg}; 54b85037dbSmrg 55b85037dbSmrgstruct CommData { 56b85037dbSmrg XISBuffer *buffer; 57b85037dbSmrg unsigned char protoBuf[6]; /* Buffer for Packet */ 58b85037dbSmrg unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */ 59b85037dbSmrg int outOfSync; /* How many consecutive incorrect packets we 60b85037dbSmrg have received */ 61b85037dbSmrg int protoBufTail; 62b85037dbSmrg 63b85037dbSmrg /* Used for keeping track of partial HwState updates. */ 64b85037dbSmrg struct SynapticsHwState hwState; 65b85037dbSmrg Bool oneFinger; 66b85037dbSmrg Bool twoFingers; 67b85037dbSmrg Bool threeFingers; 68b85037dbSmrg}; 69b85037dbSmrg 70b85037dbSmrgenum SynapticsProtocol { 71b85037dbSmrg SYN_PROTO_PSAUX, /* Raw psaux device */ 72b85037dbSmrg#ifdef BUILD_EVENTCOMM 73b85037dbSmrg SYN_PROTO_EVENT, /* Linux kernel event interface */ 74b85037dbSmrg#endif /* BUILD_EVENTCOMM */ 75b85037dbSmrg#ifdef BUILD_PSMCOMM 76b85037dbSmrg SYN_PROTO_PSM, /* FreeBSD psm driver */ 77b85037dbSmrg#endif /* BUILD_PSMCOMM */ 78b85037dbSmrg SYN_PROTO_ALPS /* ALPS touchpad protocol */ 79b85037dbSmrg}; 80b85037dbSmrg 81b85037dbSmrgstruct _SynapticsParameters; 82b85037dbSmrgstruct SynapticsHwInfo; 83b85037dbSmrgstruct CommData; 84b85037dbSmrg 85b85037dbSmrgstruct SynapticsProtocolOperations { 86b85037dbSmrg void (*DeviceOnHook)(LocalDevicePtr local, struct _SynapticsParameters *para); 87b85037dbSmrg void (*DeviceOffHook)(LocalDevicePtr local); 88b85037dbSmrg Bool (*QueryHardware)(LocalDevicePtr local); 89b85037dbSmrg Bool (*ReadHwState)(LocalDevicePtr local, 90b85037dbSmrg struct SynapticsProtocolOperations *proto_ops, 91b85037dbSmrg struct CommData *comm, struct SynapticsHwState *hwRet); 92b85037dbSmrg Bool (*AutoDevProbe)(LocalDevicePtr local); 93b85037dbSmrg void (*ReadDevDimensions)(LocalDevicePtr local); 94b85037dbSmrg}; 95b85037dbSmrg 96b85037dbSmrgextern struct SynapticsProtocolOperations psaux_proto_operations; 97b85037dbSmrg#ifdef BUILD_EVENTCOMM 98b85037dbSmrgextern struct SynapticsProtocolOperations event_proto_operations; 99b85037dbSmrg#endif /* BUILD_EVENTCOMM */ 100b85037dbSmrg#ifdef BUILD_PSMCOMM 101b85037dbSmrgextern struct SynapticsProtocolOperations psm_proto_operations; 102b85037dbSmrg#endif /* BUILD_PSMCOMM */ 103b85037dbSmrgextern struct SynapticsProtocolOperations alps_proto_operations; 104b85037dbSmrg 105b85037dbSmrg 106b85037dbSmrg#endif /* _SYNPROTO_H_ */ 107