~ubuntu-branches/ubuntu/natty/tpconfig/natty

« back to all changes in this revision

Viewing changes to .pc/debian-changes-3.1.3-13/tpconfig.c

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Bernat
  • Date: 2010-08-24 20:34:17 UTC
  • Revision ID: james.westby@ubuntu.com-20100824203417-ybeznkh0acagino8
Tags: 3.1.3-14
* Fix postinst to correctly set RESET_P option in
  /etc/default/tpconfig. Closes: #589555.
* Update Italian debconf translation, thanks to Luca Monducci.
  Closes: #593713.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)                       *
5
 
* Language: C                                                           *
6
 
* Purpose: This programs configures synaptics touchpads and is compati- *
7
 
*   ble with version 3.2+ firmware supporting a single mode byte.       *
8
 
************************************************************************/
9
 
 
10
 
 
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.
14
 
 *
15
 
 *Revision 2.12  2000/11/15 15:37:50  bruce
16
 
 *Added back in copyright call().
17
 
 *
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.
20
 
 *
21
 
 *Revision 2.10  2000/10/31 19:29:45  cph
22
 
 *Unpatched kernel signals ENOTTY for ioctl.
23
 
 *
24
 
 *Revision 2.9  2000/10/31 18:57:53  cph
25
 
 *Use symbolic value for DEBUG_LEVEL.
26
 
 *
27
 
 *Revision 2.8  2000/10/31 18:38:12  cph
28
 
 *Implement --sleep option to control sleep mode.
29
 
 *
30
 
 *Revision 2.7  2000/10/31 18:03:22  cph
31
 
 *Move copyright into --help screen.  Move variable declarations from .h
32
 
 *file to .c file.
33
 
 *
34
 
 *Revision 2.6  2000/10/31 15:19:49  cph
35
 
 *Add support for Linux kernel patch to grab the mouse device.
36
 
 *
37
 
 *Revision 2.5  2000/10/23 16:28:14  bruce
38
 
 *Fixed tcflush call.
39
 
 *
40
 
 *Revision 2.4  2000/09/29 20:17:39  bruce
41
 
 *Changed ALPS_GLIDEPOINT to ALPS_GLIDEPAD.
42
 
 *
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
46
 
 *
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.
50
 
 *
51
 
 *Revision 2.1  1999/02/13 22:29:52  bruce
52
 
 *Modified to work with newer 2.2.x kernel.
53
 
 *
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').
59
 
 *
60
 
 *Revision 0.1  1998/07/08 15:23:33  bruce
61
 
 *Initial revision by C. Scott Ananian
62
 
 **/
63
 
 
64
 
static char rcsid[]="$Id: tpconfig.c,v 2.13 2002/02/22 20:33:11 bruce Exp $";
65
 
 
66
 
 
67
 
 
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>
71
 
 *
72
 
 * Currently maintained by: Bruce Kall, <kall@compass.com>
73
 
 * 
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.
78
 
 *    
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.
83
 
 *    
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.
87
 
 *
88
 
 *   $Id: tpconfig.c,v 2.13 2002/02/22 20:33:11 bruce Exp $
89
 
 */
90
 
 
91
 
#include <fcntl.h>
92
 
#include <stdio.h>
93
 
#include <unistd.h>
94
 
#include <assert.h>
95
 
#include <sys/ioctl.h>
96
 
#include <sys/time.h>
97
 
#include <sys/timeb.h>
98
 
#include <getopt.h>
99
 
#include <termios.h>
100
 
 
101
 
#ifdef __linux
102
 
#include <linux/ioctl.h>
103
 
#include <errno.h>
104
 
#define AUX_GRAB _IO('M', 1)
105
 
#endif
106
 
 
107
 
#include "tpconfig.h"
108
 
 
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);
116
 
 
117
 
int DEBUG_LEVEL;
118
 
int silent;
119
 
float firmware_rev;
120
 
char single_mode_byte;
121
 
int touchpad_type;
122
 
 
123
 
/* initialize file description if hasn't already been done. */
124
 
void init_fd(int *fd)
125
 
{ /* init_fd*/
126
 
int status;
127
 
if (*fd<0)
128
 
  {
129
 
  *fd = open("/dev/psaux", O_RDWR|O_NDELAY);
130
 
  if (*fd < 0)
131
 
    fatal("Could not open PS/2 Port [/dev/psaux]");
132
 
#ifdef __linux
133
 
  /* If AUX_GRAB kernel patch present, use it. */
134
 
  while (ioctl (*fd, AUX_GRAB, 0) < 0)
135
 
    {
136
 
      if (errno == ENOTTY)
137
 
        break;
138
 
      if (errno != EAGAIN)
139
 
        {
140
 
          perror ("/dev/psaux");
141
 
          fatal ("Unable to get exclusive access to PS/2 Port.");
142
 
          exit (1);
143
 
        }
144
 
    }
145
 
#endif
146
 
  tcflush(*fd,TCIOFLUSH);
147
 
  if (!is_Synaptics(*fd))
148
 
    {
149
 
    status = is_ALPS(*fd);
150
 
    if(status == 0)
151
 
      {
152
 
      fatal("\n\nNo Synaptics or ALPS touchpad device found\n\n");
153
 
      exit(-1);
154
 
      }
155
 
    else
156
 
      {
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");
161
 
      else
162
 
        {
163
 
        fprintf (stderr, "Undefined touchpad found[%d]\n", touchpad_type);
164
 
        exit(-1);
165
 
        }
166
 
      }
167
 
    }
168
 
  else
169
 
    {
170
 
    printf ("Found Synaptics Touchpad.\n");
171
 
    touchpad_type = SYNAPTICS_TOUCHPAD;
172
 
    }
173
 
  }
174
 
} /* init_fd*/
175
 
 
176
 
 
177
 
 
178
 
 
179
 
int main(int argc, char **argv) 
180
 
{ /* main */
181
 
int fd = -1;
182
 
int c = 0;
183
 
int option_index = 0;
184
 
 
185
 
silent = 0;
186
 
firmware_rev = 0.0;
187
 
single_mode_byte = TRUE;
188
 
 
189
 
DEBUG_LEVEL = DEBUG_NONE;
190
 
#ifdef DEBUG
191
 
DEBUG_LEVEL = DEBUG_LOW;
192
 
#endif
193
 
 
194
 
copyright();
195
 
 
196
 
 
197
 
/* Open file descriptor and determine if we are connected to a touchpad */
198
 
init_fd(&fd);
199
 
 
200
 
if(touchpad_type == SYNAPTICS_TOUCHPAD)
201
 
  set_firmware_options(fd,stdout);
202
 
 
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)))
207
 
  ALPS_usage(argv[0]);
208
 
 
209
 
opterr=1;
210
 
while (1) 
211
 
  {
212
 
  static struct option synaptics_long_options[] =
213
 
    {
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 */
220
 
      /* Mode 1 options */
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 */
226
 
      /* Mode 2 options */
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 */
235
 
      /* Mode 3 options */
236
 
      {"right-margin",  optional_argument, NULL, '4'}, /* similar to -M */
237
 
      {"left-margin",   optional_argument, NULL, '5'}, /* similar to -M */
238
 
      /* Mode 4 options */
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}
242
 
    };
243
 
 
244
 
  static struct option ALPS_long_options[] = 
245
 
    {
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}
252
 
    };
253
 
 
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);
260
 
 
261
 
  if (c == -1)
262
 
    break;
263
 
  
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);
268
 
  }
269
 
if (optind < argc) 
270
 
  {
271
 
  fprintf(stderr, "Extra options: ");
272
 
  while (optind < argc)
273
 
    fprintf(stderr, "%s ", argv[optind++]);
274
 
  fprintf(stderr, "\n");
275
 
  }
276
 
if (!(fd<0)) 
277
 
  close(fd);
278
 
return 1;
279
 
} /* main */
280
 
 
281
 
 
282