synproto.h revision 28515619
1/* 2 * Copyright © 2004 Peter Osterlund 3 * 4 * Permission to use, copy, modify, distribute, and sell this software 5 * and its documentation for any purpose is hereby granted without 6 * fee, provided that the above copyright notice appear in all copies 7 * and that both that copyright notice and this permission notice 8 * appear in supporting documentation, and that the name of Red Hat 9 * not be used in advertising or publicity pertaining to distribution 10 * of the software without specific, written prior permission. Red 11 * Hat makes no representations about the suitability of this software 12 * for any purpose. It is provided "as is" without express or implied 13 * warranty. 14 * 15 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 17 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 * 23 * Authors: 24 * Peter Osterlund (petero2@telia.com) 25 */ 26 27#ifndef _SYNPROTO_H_ 28#define _SYNPROTO_H_ 29 30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 34#include <unistd.h> 35#include <sys/ioctl.h> 36#include <xf86Xinput.h> 37#include <xisb.h> 38 39struct _SynapticsPrivateRec; 40typedef struct _SynapticsPrivateRec SynapticsPrivate; 41 42enum SynapticsSlotState { 43 SLOTSTATE_EMPTY = 0, 44 SLOTSTATE_OPEN, 45 SLOTSTATE_CLOSE, 46 SLOTSTATE_OPEN_EMPTY, 47 SLOTSTATE_UPDATE, 48}; 49 50/* used to mark emulated hw button state */ 51#define BTN_EMULATED_FLAG 0x80 52 53/* 54 * A structure to describe the state of the touchpad hardware (buttons and pad) 55 */ 56struct SynapticsHwState { 57 CARD32 millis; /* Timestamp in milliseconds */ 58 int x; /* X position of finger */ 59 int y; /* Y position of finger */ 60 int z; /* Finger pressure */ 61 int cumulative_dx; /* Cumulative delta X for clickpad dragging */ 62 int cumulative_dy; /* Cumulative delta Y for clickpad dragging */ 63 int numFingers; 64 int fingerWidth; 65 66 Bool left; 67 Bool right; 68 Bool up; 69 Bool down; 70 71 Bool multi[8]; 72 Bool middle; /* Some ALPS touchpads have a middle button */ 73 74 int num_mt_mask; 75 ValuatorMask **mt_mask; 76 enum SynapticsSlotState *slot_state; 77}; 78 79struct CommData { 80 XISBuffer *buffer; 81 unsigned char protoBuf[6]; /* Buffer for Packet */ 82 unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */ 83 int outOfSync; /* How many consecutive incorrect packets we 84 have received */ 85 int protoBufTail; 86 87 /* Used for keeping track of partial HwState updates. */ 88 struct SynapticsHwState *hwState; 89 Bool oneFinger; 90 Bool twoFingers; 91 Bool threeFingers; 92}; 93 94struct _SynapticsParameters; 95 96struct SynapticsProtocolOperations { 97 Bool (*DeviceOnHook) (InputInfoPtr pInfo, 98 struct _SynapticsParameters * para); 99 Bool (*DeviceOffHook) (InputInfoPtr pInfo); 100 Bool (*QueryHardware) (InputInfoPtr pInfo); 101 Bool (*ReadHwState) (InputInfoPtr pInfo, 102 struct CommData * comm, 103 struct SynapticsHwState * hwRet); 104 Bool (*AutoDevProbe) (InputInfoPtr pInfo, const char *device); 105 void (*ReadDevDimensions) (InputInfoPtr pInfo); 106}; 107 108#ifdef BUILD_PS2COMM 109extern struct SynapticsProtocolOperations psaux_proto_operations; 110extern struct SynapticsProtocolOperations alps_proto_operations; 111#endif /* BUILD_PS2COMM */ 112#ifdef BUILD_EVENTCOMM 113extern struct SynapticsProtocolOperations event_proto_operations; 114#endif /* BUILD_EVENTCOMM */ 115#ifdef BUILD_PSMCOMM 116extern struct SynapticsProtocolOperations psm_proto_operations; 117#endif /* BUILD_PSMCOMM */ 118 119extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate * priv); 120extern void SynapticsHwStateFree(struct SynapticsHwState **hw); 121extern void SynapticsCopyHwState(struct SynapticsHwState *dst, 122 const struct SynapticsHwState *src); 123extern void SynapticsResetHwState(struct SynapticsHwState *hw); 124extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw, 125 Bool set_slot_empty); 126 127extern Bool SynapticsIsSoftButtonAreasValid(int *values); 128 129#endif /* _SYNPROTO_H_ */ 130