1
/************************************************************************
2
* File name: tpconfig.c *
3
* Written by: C. Scott Ananian modified by Bruce Kall *
4
* Now Supported by: Bruce Kall (kall@compass.com) *
6
* Purpose: This programs configures synaptics touchpads and is compati- *
7
* ble with version 3.2+ firmware supporting a single mode byte. *
8
************************************************************************/
11
/*$Log: tpconfig.c,v $
12
*Revision 2.13 2002/02/22 20:33:11 bruce
13
*Aded for Mode 3 and Mode 4 options.
15
*Revision 2.12 2000/11/15 15:37:50 bruce
16
*Added back in copyright call().
18
*Revision 2.11 2000/11/01 19:56:38 cph
19
*Change call to ioctl AUX_GRAB to handle case where it returns EAGAIN.
21
*Revision 2.10 2000/10/31 19:29:45 cph
22
*Unpatched kernel signals ENOTTY for ioctl.
24
*Revision 2.9 2000/10/31 18:57:53 cph
25
*Use symbolic value for DEBUG_LEVEL.
27
*Revision 2.8 2000/10/31 18:38:12 cph
28
*Implement --sleep option to control sleep mode.
30
*Revision 2.7 2000/10/31 18:03:22 cph
31
*Move copyright into --help screen. Move variable declarations from .h
34
*Revision 2.6 2000/10/31 15:19:49 cph
35
*Add support for Linux kernel patch to grab the mouse device.
37
*Revision 2.5 2000/10/23 16:28:14 bruce
40
*Revision 2.4 2000/09/29 20:17:39 bruce
41
*Changed ALPS_GLIDEPOINT to ALPS_GLIDEPAD.
43
*Revision 2.3 2000/09/28 13:37:57 bruce
44
*Exatracted synaptics code into synaptics.c. Added support for
45
*ALPS Glidepad/Stickpointer
47
*Revision 2.2 1999/02/16 17:52:56 bruce
48
*Changed check for 2.2.1 kernel in is_Synaptics().
49
*Added to time-out gracefully.
51
*Revision 2.1 1999/02/13 22:29:52 bruce
52
*Modified to work with newer 2.2.x kernel.
54
*Revision 2.0 1998/11/27 14:16:50 bruce
55
*Changed to work with modern Synaptic touchpads which contain
56
*newer firmware (that have a single mode byte). Also added
57
*detection of newer touchpad info ('Super' 'Ultrathin',
58
*'Widepad','Stamppad','Submini','Multiswich').
60
*Revision 0.1 1998/07/08 15:23:33 bruce
61
*Initial revision by C. Scott Ananian
64
static char rcsid[]="$Id: tpconfig.c,v 2.13 2002/02/22 20:33:11 bruce Exp $";
68
/* tpconfig --- Command-line TouchPad configuration utility.
69
* Copyright (C) 1997 C. Scott Ananian <cananian@alumni.princeton.edu>
70
* Copyright (c) 1998-1999 Bruce Kalk <kall@compass.com>
72
* Currently maintained by: Bruce Kall, <kall@compass.com>
74
* This program is free software; you can redistribute it and/or
75
* modify it under the terms of the GNU General Public License
76
* as published by the Free Software Foundation; either version 2
77
* of the License, or (at your option) any later version.
79
* This program is distributed in the hope that it will be useful,
80
* but WITHOUT ANY WARRANTY; without even the implied warranty of
81
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82
* GNU General Public License for more details.
84
* You should have received a copy of the GNU General Public License
85
* along with this program; if not, write to the Free Software
86
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
88
* $Id: tpconfig.c,v 2.13 2002/02/22 20:33:11 bruce Exp $
95
#include <sys/ioctl.h>
97
#include <sys/timeb.h>
102
#include <linux/ioctl.h>
104
#define AUX_GRAB _IO('M', 1)
107
#include "tpconfig.h"
109
extern void synaptics_usage(char *progname);
110
extern void set_firmware_options(int fd, FILE *out);
111
extern void ALPS_usage(char *progname);
112
extern void synaptics_functions(int c,int fd,char **argv);
113
extern void alps_functions(int c,int fd,char **argv);
114
extern int is_ALPS(int fd);
115
extern int is_Synaptics(int fd);
120
char single_mode_byte;
123
/* initialize file description if hasn't already been done. */
124
void init_fd(int *fd)
129
*fd = open("/dev/psaux", O_RDWR|O_NDELAY);
131
fatal("Could not open PS/2 Port [/dev/psaux]");
133
/* If AUX_GRAB kernel patch present, use it. */
134
while (ioctl (*fd, AUX_GRAB, 0) < 0)
140
perror ("/dev/psaux");
141
fatal ("Unable to get exclusive access to PS/2 Port.");
146
tcflush(*fd,TCIOFLUSH);
147
if (!is_Synaptics(*fd))
149
status = is_ALPS(*fd);
152
fatal("\n\nNo Synaptics or ALPS touchpad device found\n\n");
157
if(touchpad_type == ALPS_GLIDEPAD)
158
printf ("Found ALPS GlidePad.\n");
159
else if (touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT)
160
printf ("Found ALPS Dual StickPoint/Glidepad.\n");
163
fprintf (stderr, "Undefined touchpad found[%d]\n", touchpad_type);
170
printf ("Found Synaptics Touchpad.\n");
171
touchpad_type = SYNAPTICS_TOUCHPAD;
179
int main(int argc, char **argv)
183
int option_index = 0;
187
single_mode_byte = TRUE;
189
DEBUG_LEVEL = DEBUG_NONE;
191
DEBUG_LEVEL = DEBUG_LOW;
197
/* Open file descriptor and determine if we are connected to a touchpad */
200
if(touchpad_type == SYNAPTICS_TOUCHPAD)
201
set_firmware_options(fd,stdout);
203
if((argc < 2) && (touchpad_type == SYNAPTICS_TOUCHPAD))
204
synaptics_usage(argv[0]); /* no command line options */
205
else if((argc < 2) &&
206
((touchpad_type == ALPS_GLIDEPAD) || (touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT)))
212
static struct option synaptics_long_options[] =
214
{"help", no_argument, NULL, 'h'},
215
{"silent", no_argument, NULL, 'q'}, /* -q */
216
{"quiet", no_argument, NULL, 'q'}, /* -q */
217
{"info", no_argument, NULL, 'i'}, /* -i */
218
{"version", no_argument, NULL, 'v'}, /* -v */
219
{"reset", no_argument, NULL, 'x'}, /* -x */
221
{"zthreshold", optional_argument, NULL, 'z'}, /* -z */
222
{"threshold", optional_argument, NULL, 'z'}, /* -z */
223
{"corner", optional_argument, NULL, 'c'}, /* -c */
224
{"tapmode", optional_argument, NULL, 't'}, /* -t */
225
{"edgemode", optional_argument, NULL, 'e'}, /* -e */
227
{"absolute", no_argument, NULL, 'A'}, /* similar to -a */
228
{"relative", no_argument, NULL, 'R'}, /* similar to -a */
229
{"rate", optional_argument, NULL, 'r'}, /* -r */
230
{"two-button", no_argument, NULL, '2'}, /* -2 */
231
{"three-button", no_argument, NULL, '3'}, /* -3 */
232
{"middle-button", no_argument, NULL, '<'}, /* similar to -m */
233
{"right-button", no_argument, NULL, '>'}, /* similar to -m */
234
{"sleep", optional_argument, NULL, 's'}, /* -s */
236
{"right-margin", optional_argument, NULL, '4'}, /* similar to -M */
237
{"left-margin", optional_argument, NULL, '5'}, /* similar to -M */
239
{"top-margin", optional_argument, NULL, '6'}, /* similar to -M */
240
{"bottom-margin", optional_argument, NULL, '7'}, /* similar to -M */
241
{NULL, no_argument, NULL, 0}
244
static struct option ALPS_long_options[] =
246
{"help", no_argument, NULL, 'h'},
247
{"info", no_argument, NULL, 'i'}, /* -i */
248
{"reset", no_argument, NULL, 'x'}, /* -x */
249
{"tapmode", optional_argument, NULL, 't'}, /* -t */
250
{"version", no_argument, NULL, 'v'}, /* -v */
251
{NULL, no_argument, NULL, 0}
254
if(touchpad_type == SYNAPTICS_TOUCHPAD)
255
c = getopt_long (argc, argv, "qivzx::c::t::e::a::r::23m::s::M",
256
synaptics_long_options, &option_index);
257
else if((touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) || (touchpad_type == ALPS_GLIDEPAD))
258
c = getopt_long (argc, argv, "hirtv",
259
ALPS_long_options, &option_index);
264
if(touchpad_type == SYNAPTICS_TOUCHPAD)
265
synaptics_functions(c,fd,argv);
266
else if((touchpad_type == ALPS_STICKPOINTER_AND_GLIDEPOINT) || (touchpad_type == ALPS_GLIDEPAD))
267
alps_functions(c,fd,argv);
271
fprintf(stderr, "Extra options: ");
272
while (optind < argc)
273
fprintf(stderr, "%s ", argv[optind++]);
274
fprintf(stderr, "\n");