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 3028515619Smrg#ifdef HAVE_CONFIG_H 3128515619Smrg#include "config.h" 3228515619Smrg#endif 3328515619Smrg 34b85037dbSmrg#include <unistd.h> 35b85037dbSmrg#include <sys/ioctl.h> 36b85037dbSmrg#include <xf86Xinput.h> 37b85037dbSmrg#include <xisb.h> 38b85037dbSmrg 3928515619Smrgstruct _SynapticsPrivateRec; 4028515619Smrgtypedef struct _SynapticsPrivateRec SynapticsPrivate; 4128515619Smrg 4228515619Smrgenum SynapticsSlotState { 4328515619Smrg SLOTSTATE_EMPTY = 0, 4428515619Smrg SLOTSTATE_OPEN, 4528515619Smrg SLOTSTATE_CLOSE, 4628515619Smrg SLOTSTATE_OPEN_EMPTY, 4728515619Smrg SLOTSTATE_UPDATE, 4828515619Smrg}; 4928515619Smrg 5028515619Smrg/* used to mark emulated hw button state */ 5128515619Smrg#define BTN_EMULATED_FLAG 0x80 5228515619Smrg 53b85037dbSmrg/* 54b85037dbSmrg * A structure to describe the state of the touchpad hardware (buttons and pad) 55b85037dbSmrg */ 56b85037dbSmrgstruct SynapticsHwState { 5728515619Smrg CARD32 millis; /* Timestamp in milliseconds */ 5828515619Smrg int x; /* X position of finger */ 5928515619Smrg int y; /* Y position of finger */ 6028515619Smrg int z; /* Finger pressure */ 6128515619Smrg int cumulative_dx; /* Cumulative delta X for clickpad dragging */ 6228515619Smrg int cumulative_dy; /* Cumulative delta Y for clickpad dragging */ 63b85037dbSmrg int numFingers; 64b85037dbSmrg int fingerWidth; 65b85037dbSmrg 66b85037dbSmrg Bool left; 67b85037dbSmrg Bool right; 68b85037dbSmrg Bool up; 69b85037dbSmrg Bool down; 70b85037dbSmrg 71b85037dbSmrg Bool multi[8]; 7228515619Smrg Bool middle; /* Some ALPS touchpads have a middle button */ 7328515619Smrg 7428515619Smrg int num_mt_mask; 7528515619Smrg ValuatorMask **mt_mask; 7628515619Smrg enum SynapticsSlotState *slot_state; 77b85037dbSmrg}; 78b85037dbSmrg 79b85037dbSmrgstruct CommData { 80b85037dbSmrg XISBuffer *buffer; 8128515619Smrg unsigned char protoBuf[6]; /* Buffer for Packet */ 8228515619Smrg unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */ 8328515619Smrg int outOfSync; /* How many consecutive incorrect packets we 8428515619Smrg have received */ 85b85037dbSmrg int protoBufTail; 86b85037dbSmrg 87b85037dbSmrg /* Used for keeping track of partial HwState updates. */ 8828515619Smrg struct SynapticsHwState *hwState; 89b85037dbSmrg Bool oneFinger; 90b85037dbSmrg Bool twoFingers; 91b85037dbSmrg Bool threeFingers; 92b85037dbSmrg}; 93b85037dbSmrg 94b85037dbSmrgstruct _SynapticsParameters; 95b85037dbSmrg 96b85037dbSmrgstruct SynapticsProtocolOperations { 9728515619Smrg Bool (*DeviceOnHook) (InputInfoPtr pInfo, 9828515619Smrg struct _SynapticsParameters * para); 9928515619Smrg Bool (*DeviceOffHook) (InputInfoPtr pInfo); 10028515619Smrg Bool (*QueryHardware) (InputInfoPtr pInfo); 10128515619Smrg Bool (*ReadHwState) (InputInfoPtr pInfo, 10228515619Smrg struct CommData * comm, 10328515619Smrg struct SynapticsHwState * hwRet); 10428515619Smrg Bool (*AutoDevProbe) (InputInfoPtr pInfo, const char *device); 10528515619Smrg void (*ReadDevDimensions) (InputInfoPtr pInfo); 106b85037dbSmrg}; 107b85037dbSmrg 10828515619Smrg#ifdef BUILD_PS2COMM 109b85037dbSmrgextern struct SynapticsProtocolOperations psaux_proto_operations; 11028515619Smrgextern struct SynapticsProtocolOperations alps_proto_operations; 11128515619Smrg#endif /* BUILD_PS2COMM */ 112b85037dbSmrg#ifdef BUILD_EVENTCOMM 113b85037dbSmrgextern struct SynapticsProtocolOperations event_proto_operations; 11428515619Smrg#endif /* BUILD_EVENTCOMM */ 115b85037dbSmrg#ifdef BUILD_PSMCOMM 116b85037dbSmrgextern struct SynapticsProtocolOperations psm_proto_operations; 11728515619Smrg#endif /* BUILD_PSMCOMM */ 11828515619Smrg 11928515619Smrgextern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate * priv); 12028515619Smrgextern void SynapticsHwStateFree(struct SynapticsHwState **hw); 12128515619Smrgextern void SynapticsCopyHwState(struct SynapticsHwState *dst, 12228515619Smrg const struct SynapticsHwState *src); 12328515619Smrgextern void SynapticsResetHwState(struct SynapticsHwState *hw); 12428515619Smrgextern void SynapticsResetTouchHwState(struct SynapticsHwState *hw, 12528515619Smrg Bool set_slot_empty); 126b85037dbSmrg 12728515619Smrgextern Bool SynapticsIsSoftButtonAreasValid(int *values); 128b85037dbSmrg 12928515619Smrg#endif /* _SYNPROTO_H_ */ 130