2 * Copyright (c) 2001 Edouard TISSERANT <tissered@esstin.u-nancy.fr>
3 * Parts inspired from Shane Watts <shane@bofh.asn.au> Xfree 3 Acecad Driver
4 * Thanks to Emily, from AceCad, For giving me documents.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
21 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 /******************************************************************************
32 * structs, typedefs, #defines, enums
33 *****************************************************************************/
34 #define ACECAD_PACKET_SIZE 7
36 #define ACECAD_CONFIG "a" /* Send configuration (max coords) */
38 #define ACECAD_ABSOLUTE 'F' /* Absolute mode */
39 #define ACECAD_RELATIVE 'E' /* Relative mode */
41 #define ACECAD_UPPER_ORIGIN "b" /* Origin upper left */
43 #define ACECAD_PROMPT_MODE "B" /* Prompt mode */
44 #define ACECAD_STREAM_MODE "@" /* Stream mode */
45 #define ACECAD_INCREMENT 'I' /* Set increment */
46 #define ACECAD_BINARY_FMT "zb" /* Binary reporting */
48 #define ACECAD_PROMPT "P" /* Prompt for current position */
50 #define PHASING_BIT 0x80
51 #define PROXIMITY_BIT 0x40
52 #define TABID_BIT 0x20
53 #define XSIGN_BIT 0x10
54 #define YSIGN_BIT 0x08
55 #define BUTTON_BITS 0x07
56 #define COORD_BITS 0x7f
58 #define ABSOLUTE_FLAG 1
60 #define AUTODEV_FLAG 4
63 #define NOTAVAIL ((errno == ENODEV) || (errno == ENXIO) || (errno == ENOENT))
65 #define milisleep(ms) usleep (ms * 1000)
67 #define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
69 static const char * acecad_initstr = ACECAD_BINARY_FMT ACECAD_STREAM_MODE;
74 int acecadInc; /* increment between transmits */
75 int acecadOldX; /* previous X position */
76 int acecadOldY; /* previous Y position */
77 int acecadOldZ; /* previous Z position */
78 int acecadOldProximity; /* previous proximity */
79 int acecadOldButtons; /* previous buttons state */
80 int acecadMaxX; /* max X value */
81 int acecadMaxY; /* max Y value */
82 int acecadMaxZ; /* max Y value */
83 char acecadReportSpeed; /* report speed */
84 int flags; /* various flags */
85 int packeti; /* number of bytes read */
86 int PacketSize; /* number of bytes read */
87 unsigned char packet[ACECAD_PACKET_SIZE]; /* data read on the device */
88 } AceCadPrivateRec, *AceCadPrivatePtr;
91 /******************************************************************************
93 *****************************************************************************/
95 static MODULESETUPPROTO( SetupProc );
96 static void TearDownProc (void *);
98 static Bool DeviceControl (DeviceIntPtr, int);
99 static Bool DeviceOn (DeviceIntPtr);
100 static Bool DeviceOff (DeviceIntPtr);
101 static Bool DeviceClose (DeviceIntPtr);
102 static Bool DeviceInit (DeviceIntPtr);
103 static void ReadInput (InputInfoPtr);
104 static Bool ConvertProc (InputInfoPtr, int, int, int, int, int, int, int, int, int *, int *);
105 static Bool QueryHardware (AceCadPrivatePtr);
106 static void NewPacket (AceCadPrivatePtr priv);
107 static Bool AceCadGetPacket (AceCadPrivatePtr);
108 static int AceCadPreInit(InputDriverPtr, InputInfoPtr , int);
109 static void AceCadUnInit(InputDriverPtr, InputInfoPtr , int);
110 #ifdef HAVE_LINUX_INPUT_H
111 static void USBReadInput (InputInfoPtr);
112 static Bool USBQueryHardware (InputInfoPtr);
113 static int IsUSBLine(int);
114 static Bool fd_query_acecad(int, const char*);
115 static Bool AceCadAutoDevProbe(InputInfoPtr, int);