Wed Jun 10 08:58:44 2009 UTC ()
merge xf86-input-mouse 1.4.0.


(mrg)
diff -r1.2 -r1.3 xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c

cvs diff -r1.2 -r1.3 xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c 2009/02/02 03:05:35 1.2
+++ xsrc/external/mit/xf86-input-mouse/dist/src/mouse.c 2009/06/10 08:58:43 1.3
@@ -1,15 +1,13 @@ @@ -1,15 +1,13 @@
1/* $XdotOrg: driver/xf86-input-mouse/src/mouse.c,v 1.29 2006/04/21 11:15:23 mhopf Exp $ */ 
2/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c,v 1.79 2003/11/03 05:11:48 tsi Exp $ */ 
3/* 1/*
4 * 2 *
5 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. 3 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
6 * Copyright 1993 by David Dawes <dawes@xfree86.org> 4 * Copyright 1993 by David Dawes <dawes@xfree86.org>
7 * Copyright 2002 by SuSE Linux AG, Author: Egbert Eich 5 * Copyright 2002 by SuSE Linux AG, Author: Egbert Eich
8 * Copyright 1994-2002 by The XFree86 Project, Inc. 6 * Copyright 1994-2002 by The XFree86 Project, Inc.
9 * Copyright 2002 by Paul Elliott 7 * Copyright 2002 by Paul Elliott
10 * 8 *
11 * Permission to use, copy, modify, distribute, and sell this software and its 9 * Permission to use, copy, modify, distribute, and sell this software and its
12 * documentation for any purpose is hereby granted without fee, provided that 10 * documentation for any purpose is hereby granted without fee, provided that
13 * the above copyright notice appear in all copies and that both that 11 * the above copyright notice appear in all copies and that both that
14 * copyright notice and this permission notice appear in supporting 12 * copyright notice and this permission notice appear in supporting
15 * documentation, and that the names of copyright holders not be 13 * documentation, and that the names of copyright holders not be
@@ -116,29 +114,27 @@ typedef struct _DragLockRec { @@ -116,29 +114,27 @@ typedef struct _DragLockRec {
116 /* simulate these buttons being down although they are not */ 114 /* simulate these buttons being down although they are not */
117 int simulatedDown; 115 int simulatedDown;
118 116
119 /* 117 /*
120 * data to map bits for drag lock buttons to corresponding 118 * data to map bits for drag lock buttons to corresponding
121 * bits for the target buttons 119 * bits for the target buttons
122 */ 120 */
123 int nib_table[NIB_COUNT][NIB_SIZE]; 121 int nib_table[NIB_COUNT][NIB_SIZE];
124 122
125} DragLockRec, *DragLockPtr; 123} DragLockRec, *DragLockPtr;
126 124
127 125
128 126
129#ifdef XFree86LOADER 
130static const OptionInfoRec *MouseAvailableOptions(void *unused); 127static const OptionInfoRec *MouseAvailableOptions(void *unused);
131#endif 
132static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags); 128static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags);
133#if 0 129#if 0
134static void MouseUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); 130static void MouseUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
135#endif 131#endif
136 132
137static int MouseProc(DeviceIntPtr device, int what); 133static int MouseProc(DeviceIntPtr device, int what);
138static Bool MouseConvert(LocalDevicePtr local, int first, int num, int v0, 134static Bool MouseConvert(LocalDevicePtr local, int first, int num, int v0,
139 int v1, int v2, int v3, int v4, int v5, int *x, 135 int v1, int v2, int v3, int v4, int v5, int *x,
140 int *y); 136 int *y);
141 137
142static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl); 138static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl);
143static void MousePostEvent(InputInfoPtr pInfo, int buttons, 139static void MousePostEvent(InputInfoPtr pInfo, int buttons,
144 int dx, int dy, int dz, int dw); 140 int dx, int dy, int dz, int dw);
@@ -207,27 +203,26 @@ typedef enum { @@ -207,27 +203,26 @@ typedef enum {
207 OPTION_BAUD_RATE, 203 OPTION_BAUD_RATE,
208 OPTION_DATA_BITS, 204 OPTION_DATA_BITS,
209 OPTION_STOP_BITS, 205 OPTION_STOP_BITS,
210 OPTION_PARITY, 206 OPTION_PARITY,
211 OPTION_FLOW_CONTROL, 207 OPTION_FLOW_CONTROL,
212 OPTION_VTIME, 208 OPTION_VTIME,
213 OPTION_VMIN, 209 OPTION_VMIN,
214 OPTION_DRAGLOCKBUTTONS, 210 OPTION_DRAGLOCKBUTTONS,
215 OPTION_DOUBLECLICK_BUTTONS, 211 OPTION_DOUBLECLICK_BUTTONS,
216 OPTION_BUTTON_MAPPING, 212 OPTION_BUTTON_MAPPING,
217 OPTION_SENSITIVITY 213 OPTION_SENSITIVITY
218} MouseOpts; 214} MouseOpts;
219 215
220#ifdef XFree86LOADER 
221static const OptionInfoRec mouseOptions[] = { 216static const OptionInfoRec mouseOptions[] = {
222 { OPTION_ALWAYS_CORE, "AlwaysCore", OPTV_BOOLEAN, {0}, FALSE }, 217 { OPTION_ALWAYS_CORE, "AlwaysCore", OPTV_BOOLEAN, {0}, FALSE },
223 { OPTION_SEND_CORE_EVENTS, "SendCoreEvents", OPTV_BOOLEAN, {0}, FALSE }, 218 { OPTION_SEND_CORE_EVENTS, "SendCoreEvents", OPTV_BOOLEAN, {0}, FALSE },
224 { OPTION_CORE_POINTER, "CorePointer", OPTV_BOOLEAN, {0}, FALSE }, 219 { OPTION_CORE_POINTER, "CorePointer", OPTV_BOOLEAN, {0}, FALSE },
225 { OPTION_SEND_DRAG_EVENTS, "SendDragEvents", OPTV_BOOLEAN, {0}, FALSE }, 220 { OPTION_SEND_DRAG_EVENTS, "SendDragEvents", OPTV_BOOLEAN, {0}, FALSE },
226 { OPTION_HISTORY_SIZE, "HistorySize", OPTV_INTEGER, {0}, FALSE }, 221 { OPTION_HISTORY_SIZE, "HistorySize", OPTV_INTEGER, {0}, FALSE },
227 { OPTION_DEVICE, "Device", OPTV_STRING, {0}, FALSE }, 222 { OPTION_DEVICE, "Device", OPTV_STRING, {0}, FALSE },
228 { OPTION_PROTOCOL, "Protocol", OPTV_STRING, {0}, FALSE }, 223 { OPTION_PROTOCOL, "Protocol", OPTV_STRING, {0}, FALSE },
229 { OPTION_BUTTONS, "Buttons", OPTV_INTEGER, {0}, FALSE }, 224 { OPTION_BUTTONS, "Buttons", OPTV_INTEGER, {0}, FALSE },
230 { OPTION_EMULATE_3_BUTTONS, "Emulate3Buttons",OPTV_BOOLEAN, {0}, FALSE }, 225 { OPTION_EMULATE_3_BUTTONS, "Emulate3Buttons",OPTV_BOOLEAN, {0}, FALSE },
231 { OPTION_EMULATE_3_TIMEOUT, "Emulate3Timeout",OPTV_INTEGER, {0}, FALSE }, 226 { OPTION_EMULATE_3_TIMEOUT, "Emulate3Timeout",OPTV_INTEGER, {0}, FALSE },
232 { OPTION_CHORD_MIDDLE, "ChordMiddle", OPTV_BOOLEAN, {0}, FALSE }, 227 { OPTION_CHORD_MIDDLE, "ChordMiddle", OPTV_BOOLEAN, {0}, FALSE },
233 { OPTION_FLIP_XY, "FlipXY", OPTV_BOOLEAN, {0}, FALSE }, 228 { OPTION_FLIP_XY, "FlipXY", OPTV_BOOLEAN, {0}, FALSE },
@@ -251,27 +246,26 @@ static const OptionInfoRec mouseOptions[ @@ -251,27 +246,26 @@ static const OptionInfoRec mouseOptions[
251 { OPTION_DATA_BITS, "DataBits", OPTV_INTEGER, {0}, FALSE }, 246 { OPTION_DATA_BITS, "DataBits", OPTV_INTEGER, {0}, FALSE },
252 { OPTION_STOP_BITS, "StopBits", OPTV_INTEGER, {0}, FALSE }, 247 { OPTION_STOP_BITS, "StopBits", OPTV_INTEGER, {0}, FALSE },
253 { OPTION_PARITY, "Parity", OPTV_STRING, {0}, FALSE }, 248 { OPTION_PARITY, "Parity", OPTV_STRING, {0}, FALSE },
254 { OPTION_FLOW_CONTROL, "FlowControl", OPTV_STRING, {0}, FALSE }, 249 { OPTION_FLOW_CONTROL, "FlowControl", OPTV_STRING, {0}, FALSE },
255 { OPTION_VTIME, "VTime", OPTV_INTEGER, {0}, FALSE }, 250 { OPTION_VTIME, "VTime", OPTV_INTEGER, {0}, FALSE },
256 { OPTION_VMIN, "VMin", OPTV_INTEGER, {0}, FALSE }, 251 { OPTION_VMIN, "VMin", OPTV_INTEGER, {0}, FALSE },
257 /* end serial options */ 252 /* end serial options */
258 { OPTION_DRAGLOCKBUTTONS, "DragLockButtons",OPTV_STRING, {0}, FALSE }, 253 { OPTION_DRAGLOCKBUTTONS, "DragLockButtons",OPTV_STRING, {0}, FALSE },
259 { OPTION_DOUBLECLICK_BUTTONS,"DoubleClickButtons", OPTV_STRING, {0}, FALSE }, 254 { OPTION_DOUBLECLICK_BUTTONS,"DoubleClickButtons", OPTV_STRING, {0}, FALSE },
260 { OPTION_BUTTON_MAPPING, "ButtonMapping", OPTV_STRING, {0}, FALSE }, 255 { OPTION_BUTTON_MAPPING, "ButtonMapping", OPTV_STRING, {0}, FALSE },
261 { OPTION_SENSITIVITY, "Sensitivity", OPTV_REAL, {0}, FALSE }, 256 { OPTION_SENSITIVITY, "Sensitivity", OPTV_REAL, {0}, FALSE },
262 { -1, NULL, OPTV_NONE, {0}, FALSE } 257 { -1, NULL, OPTV_NONE, {0}, FALSE }
263}; 258};
264#endif 
265 259
266#define RETRY_COUNT 4 260#define RETRY_COUNT 4
267 261
268/* 262/*
269 * Microsoft (all serial models), Logitech MouseMan, First Mouse, etc, 263 * Microsoft (all serial models), Logitech MouseMan, First Mouse, etc,
270 * ALPS GlidePoint, Thinking Mouse. 264 * ALPS GlidePoint, Thinking Mouse.
271 */ 265 */
272static const char *msDefaults[] = { 266static const char *msDefaults[] = {
273 "BaudRate", "1200", 267 "BaudRate", "1200",
274 "DataBits", "7", 268 "DataBits", "7",
275 "StopBits", "1", 269 "StopBits", "1",
276 "Parity", "None", 270 "Parity", "None",
277 "FlowControl", "None", 271 "FlowControl", "None",
@@ -368,34 +362,32 @@ static MouseProtocolRec mouseProtocols[] @@ -368,34 +362,32 @@ static MouseProtocolRec mouseProtocols[]
368 /* Bus Mouse */ 362 /* Bus Mouse */
369 { "BusMouse", MSE_BUS, NULL, PROT_BM }, 363 { "BusMouse", MSE_BUS, NULL, PROT_BM },
370 364
371 /* Auto-detect (PnP) */ 365 /* Auto-detect (PnP) */
372 { "Auto", MSE_AUTO, NULL, PROT_AUTO }, 366 { "Auto", MSE_AUTO, NULL, PROT_AUTO },
373 367
374 /* Misc (usually OS-specific) */ 368 /* Misc (usually OS-specific) */
375 { "SysMouse", MSE_MISC, mlDefaults, PROT_SYSMOUSE }, 369 { "SysMouse", MSE_MISC, mlDefaults, PROT_SYSMOUSE },
376 370
377 /* end of list */ 371 /* end of list */
378 { NULL, MSE_NONE, NULL, PROT_UNKNOWN } 372 { NULL, MSE_NONE, NULL, PROT_UNKNOWN }
379}; 373};
380 374
381#ifdef XFree86LOADER 
382/*ARGSUSED*/ 375/*ARGSUSED*/
383static const OptionInfoRec * 376static const OptionInfoRec *
384MouseAvailableOptions(void *unused) 377MouseAvailableOptions(void *unused)
385{ 378{
386 return (mouseOptions); 379 return (mouseOptions);
387} 380}
388#endif 
389 381
390/* Process options common to all mouse types. */ 382/* Process options common to all mouse types. */
391static void 383static void
392MouseCommonOptions(InputInfoPtr pInfo) 384MouseCommonOptions(InputInfoPtr pInfo)
393{ 385{
394 MouseDevPtr pMse; 386 MouseDevPtr pMse;
395 MessageType buttons_from = X_CONFIG; 387 MessageType buttons_from = X_CONFIG;
396 char *s; 388 char *s;
397 int origButtons; 389 int origButtons;
398 int i; 390 int i;
399 391
400 pMse = pInfo->private; 392 pMse = pInfo->private;
401 393
@@ -792,28 +784,28 @@ MouseHWOptions(InputInfoPtr pInfo) @@ -792,28 +784,28 @@ MouseHWOptions(InputInfoPtr pInfo)
792 xf86Msg(X_CONFIG, "Don't initialize mouse when auto-probing\n"); 784 xf86Msg(X_CONFIG, "Don't initialize mouse when auto-probing\n");
793 } 785 }
794 pMse->sampleRate = xf86SetIntOption(pInfo->options, "SampleRate", 0); 786 pMse->sampleRate = xf86SetIntOption(pInfo->options, "SampleRate", 0);
795 if (pMse->sampleRate) { 787 if (pMse->sampleRate) {
796 xf86Msg(X_CONFIG, "%s: SampleRate: %d\n", pInfo->name, 788 xf86Msg(X_CONFIG, "%s: SampleRate: %d\n", pInfo->name,
797 pMse->sampleRate); 789 pMse->sampleRate);
798 } 790 }
799 pMse->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0); 791 pMse->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0);
800 if (pMse->resolution) { 792 if (pMse->resolution) {
801 xf86Msg(X_CONFIG, "%s: Resolution: %d\n", pInfo->name, 793 xf86Msg(X_CONFIG, "%s: Resolution: %d\n", pInfo->name,
802 pMse->resolution); 794 pMse->resolution);
803 } 795 }
804 796
805 if (mPriv->sensitivity  797 if ((mPriv->sensitivity
806 = xf86SetRealOption(pInfo->options, "Sensitivity", 1.0)) { 798 = xf86SetRealOption(pInfo->options, "Sensitivity", 1.0))) {
807 xf86Msg(X_CONFIG, "%s: Sensitivity: %g\n", pInfo->name, 799 xf86Msg(X_CONFIG, "%s: Sensitivity: %g\n", pInfo->name,
808 mPriv->sensitivity); 800 mPriv->sensitivity);
809 } 801 }
810} 802}
811 803
812static void 804static void
813MouseSerialOptions(InputInfoPtr pInfo) 805MouseSerialOptions(InputInfoPtr pInfo)
814{ 806{
815 MouseDevPtr pMse = pInfo->private; 807 MouseDevPtr pMse = pInfo->private;
816 Bool clearDTR, clearRTS; 808 Bool clearDTR, clearRTS;
817  809
818  810
819 pMse->baudRate = xf86SetIntOption(pInfo->options, "BaudRate", 0); 811 pMse->baudRate = xf86SetIntOption(pInfo->options, "BaudRate", 0);
@@ -864,27 +856,27 @@ ProtocolIDToName(MouseProtocolID id) @@ -864,27 +856,27 @@ ProtocolIDToName(MouseProtocolID id)
864 return "Unknown"; 856 return "Unknown";
865 break; 857 break;
866 case PROT_UNSUP: 858 case PROT_UNSUP:
867 return "Unsupported"; 859 return "Unsupported";
868 break; 860 break;
869 default: 861 default:
870 for (i = 0; mouseProtocols[i].name; i++) 862 for (i = 0; mouseProtocols[i].name; i++)
871 if (id == mouseProtocols[i].id) 863 if (id == mouseProtocols[i].id)
872 return mouseProtocols[i].name; 864 return mouseProtocols[i].name;
873 return "Invalid"; 865 return "Invalid";
874 } 866 }
875} 867}
876 868
877const char * 869_X_EXPORT const char *
878xf86MouseProtocolIDToName(MouseProtocolID id) 870xf86MouseProtocolIDToName(MouseProtocolID id)
879{ 871{
880 return ProtocolIDToName(id); 872 return ProtocolIDToName(id);
881} 873}
882 874
883MouseProtocolID 875MouseProtocolID
884xf86MouseProtocolNameToID(const char *name) 876xf86MouseProtocolNameToID(const char *name)
885{ 877{
886 return ProtocolNameToID(name); 878 return ProtocolNameToID(name);
887} 879}
888 880
889static int 881static int
890ProtocolIDToClass(MouseProtocolID id) 882ProtocolIDToClass(MouseProtocolID id)
@@ -993,27 +985,27 @@ MousePreInit(InputDriverPtr drv, IDevPtr @@ -993,27 +985,27 @@ MousePreInit(InputDriverPtr drv, IDevPtr
993 pInfo->read_input = MouseReadInput; 985 pInfo->read_input = MouseReadInput;
994#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0 986#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
995 pInfo->motion_history_proc = xf86GetMotionEvents; 987 pInfo->motion_history_proc = xf86GetMotionEvents;
996 pInfo->history_size = 0; 988 pInfo->history_size = 0;
997#endif 989#endif
998 pInfo->control_proc = NULL; 990 pInfo->control_proc = NULL;
999 pInfo->close_proc = NULL; 991 pInfo->close_proc = NULL;
1000 pInfo->switch_mode = NULL; 992 pInfo->switch_mode = NULL;
1001 pInfo->conversion_proc = MouseConvert; 993 pInfo->conversion_proc = MouseConvert;
1002 pInfo->reverse_conversion_proc = NULL; 994 pInfo->reverse_conversion_proc = NULL;
1003 pInfo->fd = -1; 995 pInfo->fd = -1;
1004 pInfo->dev = NULL; 996 pInfo->dev = NULL;
1005 pInfo->private_flags = 0; 997 pInfo->private_flags = 0;
1006 pInfo->always_core_feedback = 0; 998 pInfo->always_core_feedback = NULL;
1007 pInfo->conf_idev = dev; 999 pInfo->conf_idev = dev;
1008 1000
1009 /* Check if SendDragEvents has been disabled. */ 1001 /* Check if SendDragEvents has been disabled. */
1010 if (!xf86SetBoolOption(dev->commonOptions, "SendDragEvents", TRUE)) { 1002 if (!xf86SetBoolOption(dev->commonOptions, "SendDragEvents", TRUE)) {
1011 pInfo->flags &= ~XI86_SEND_DRAG_EVENTS; 1003 pInfo->flags &= ~XI86_SEND_DRAG_EVENTS;
1012 } 1004 }
1013 1005
1014 /* Allocate the MouseDevRec and initialise it. */ 1006 /* Allocate the MouseDevRec and initialise it. */
1015 /* 1007 /*
1016 * XXX This should be done by a function in the core server since the 1008 * XXX This should be done by a function in the core server since the
1017 * MouseDevRec is defined in the os-support layer. 1009 * MouseDevRec is defined in the os-support layer.
1018 */ 1010 */
1019 if (!(pMse = xcalloc(sizeof(MouseDevRec), 1))) 1011 if (!(pMse = xcalloc(sizeof(MouseDevRec), 1)))
@@ -1052,27 +1044,27 @@ MousePreInit(InputDriverPtr drv, IDevPtr @@ -1052,27 +1044,27 @@ MousePreInit(InputDriverPtr drv, IDevPtr
1052 protocolID = id; 1044 protocolID = id;
1053 protocol = osProt; 1045 protocol = osProt;
1054 detected = FALSE; 1046 detected = FALSE;
1055 } 1047 }
1056 } 1048 }
1057 } 1049 }
1058 break; 1050 break;
1059 case PROT_UNKNOWN: 1051 case PROT_UNKNOWN:
1060 /* Check for a builtin OS-specific protocol, 1052 /* Check for a builtin OS-specific protocol,
1061 * and call its PreInit. */ 1053 * and call its PreInit. */
1062 if (osInfo->CheckProtocol 1054 if (osInfo->CheckProtocol
1063 && osInfo->CheckProtocol(protocol)) { 1055 && osInfo->CheckProtocol(protocol)) {
1064 if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) && 1056 if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) &&
1065 HAVE_FIND_DEVICE && osInfo->FindDevice) { 1057 osInfo->FindDevice) {
1066 xf86Msg(X_WARNING, "%s: No Device specified, " 1058 xf86Msg(X_WARNING, "%s: No Device specified, "
1067 "looking for one...\n", pInfo->name); 1059 "looking for one...\n", pInfo->name);
1068 if (!osInfo->FindDevice(pInfo, protocol, 0)) { 1060 if (!osInfo->FindDevice(pInfo, protocol, 0)) {
1069 xf86Msg(X_ERROR, "%s: Cannot find which device " 1061 xf86Msg(X_ERROR, "%s: Cannot find which device "
1070 "to use.\n", pInfo->name); 1062 "to use.\n", pInfo->name);
1071 } else 1063 } else
1072 deviceFrom = X_PROBED; 1064 deviceFrom = X_PROBED;
1073 } 1065 }
1074 if (osInfo->PreInit) { 1066 if (osInfo->PreInit) {
1075 osInfo->PreInit(pInfo, protocol, 0); 1067 osInfo->PreInit(pInfo, protocol, 0);
1076 } 1068 }
1077 return pInfo; 1069 return pInfo;
1078 } 1070 }
@@ -1083,27 +1075,27 @@ MousePreInit(InputDriverPtr drv, IDevPtr @@ -1083,27 +1075,27 @@ MousePreInit(InputDriverPtr drv, IDevPtr
1083 case PROT_UNSUP: 1075 case PROT_UNSUP:
1084 xf86Msg(X_ERROR, 1076 xf86Msg(X_ERROR,
1085 "%s: Protocol \"%s\" is not supported on this " 1077 "%s: Protocol \"%s\" is not supported on this "
1086 "platform\n", pInfo->name, protocol); 1078 "platform\n", pInfo->name, protocol);
1087 return pInfo; 1079 return pInfo;
1088 break; 1080 break;
1089 default: 1081 default:
1090 break; 1082 break;
1091  1083
1092 } 1084 }
1093 } while (!detected); 1085 } while (!detected);
1094  1086
1095 if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) && 1087 if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) &&
1096 HAVE_FIND_DEVICE && osInfo->FindDevice) { 1088 osInfo->FindDevice) {
1097 xf86Msg(X_WARNING, "%s: No Device specified, looking for one...\n", 1089 xf86Msg(X_WARNING, "%s: No Device specified, looking for one...\n",
1098 pInfo->name); 1090 pInfo->name);
1099 if (!osInfo->FindDevice(pInfo, protocol, 0)) { 1091 if (!osInfo->FindDevice(pInfo, protocol, 0)) {
1100 xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n", 1092 xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n",
1101 pInfo->name); 1093 pInfo->name);
1102 } else { 1094 } else {
1103 deviceFrom = X_PROBED; 1095 deviceFrom = X_PROBED;
1104 xf86MarkOptionUsedByName(dev->commonOptions, "Device"); 1096 xf86MarkOptionUsedByName(dev->commonOptions, "Device");
1105 } 1097 }
1106 } 1098 }
1107 1099
1108 device = xf86CheckStrOption(dev->commonOptions, "Device", NULL); 1100 device = xf86CheckStrOption(dev->commonOptions, "Device", NULL);
1109 if (device) 1101 if (device)
@@ -1182,32 +1174,31 @@ MouseReadInput(InputInfoPtr pInfo) @@ -1182,32 +1174,31 @@ MouseReadInput(InputInfoPtr pInfo)
1182 * read. Xisb automatically clears it after one successful read so that 1174 * read. Xisb automatically clears it after one successful read so that
1183 * succeeding reads are preceeded by a select with a 0 timeout to prevent 1175 * succeeding reads are preceeded by a select with a 0 timeout to prevent
1184 * read from blocking indefinitely. 1176 * read from blocking indefinitely.
1185 */ 1177 */
1186 XisbBlockDuration(pMse->buffer, -1); 1178 XisbBlockDuration(pMse->buffer, -1);
1187 1179
1188 while ((c = XisbRead(pMse->buffer)) >= 0) { 1180 while ((c = XisbRead(pMse->buffer)) >= 0) {
1189 u = (unsigned char)c; 1181 u = (unsigned char)c;
1190 1182
1191#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG) 1183#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG)
1192 ErrorF("mouse byte: %2.2x\n",u); 1184 ErrorF("mouse byte: %2.2x\n",u);
1193#endif 1185#endif
1194 1186
1195#if 1 
1196 /* if we do autoprobing collect the data */ 1187 /* if we do autoprobing collect the data */
1197 if (pMse->collectData && pMse->autoProbe) 1188 if (pMse->collectData && pMse->autoProbe)
1198 if (pMse->collectData(pMse,u)) 1189 if (pMse->collectData(pMse,u))
1199 continue; 1190 continue;
1200#endif 1191
1201#ifdef SUPPORT_MOUSE_RESET 1192#ifdef SUPPORT_MOUSE_RESET
1202 if (mouseReset(pInfo,u)) { 1193 if (mouseReset(pInfo,u)) {
1203 pBufP = 0; 1194 pBufP = 0;
1204 continue; 1195 continue;
1205 } 1196 }
1206#endif 1197#endif
1207 if (pBufP >= pMse->protoPara[4]) { 1198 if (pBufP >= pMse->protoPara[4]) {
1208 /* 1199 /*
1209 * Buffer contains a full packet, which has already been processed: 1200 * Buffer contains a full packet, which has already been processed:
1210 * Empty the buffer and check for optional 4th byte, which will be 1201 * Empty the buffer and check for optional 4th byte, which will be
1211 * processed directly, without being put into the buffer first. 1202 * processed directly, without being put into the buffer first.
1212 */ 1203 */
1213 pBufP = 0; 1204 pBufP = 0;
@@ -1718,27 +1709,27 @@ MouseProc(DeviceIntPtr device, int what) @@ -1718,27 +1709,27 @@ MouseProc(DeviceIntPtr device, int what)
1718 case DEVICE_INIT: 1709 case DEVICE_INIT:
1719 device->public.on = FALSE; 1710 device->public.on = FALSE;
1720 /* 1711 /*
1721 * [KAZU-241097] We don't know exactly how many buttons the 1712 * [KAZU-241097] We don't know exactly how many buttons the
1722 * device has, so setup the map with the maximum number. 1713 * device has, so setup the map with the maximum number.
1723 */ 1714 */
1724 for (i = 0; i < MSE_MAXBUTTONS; i++) 1715 for (i = 0; i < MSE_MAXBUTTONS; i++)
1725 map[i + 1] = i + 1; 1716 map[i + 1] = i + 1;
1726 1717
1727 InitPointerDeviceStruct((DevicePtr)device, map, 1718 InitPointerDeviceStruct((DevicePtr)device, map,
1728 min(pMse->buttons, MSE_MAXBUTTONS), 1719 min(pMse->buttons, MSE_MAXBUTTONS),
1729#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0 1720#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
1730 miPointerGetMotionEvents, 1721 miPointerGetMotionEvents,
1731#else 1722#elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
1732 GetMotionHistory, 1723 GetMotionHistory,
1733#endif 1724#endif
1734 pMse->Ctrl, 1725 pMse->Ctrl,
1735#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0 1726#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
1736 miPointerGetMotionBufferSize() 1727 miPointerGetMotionBufferSize()
1737#else 1728#else
1738 GetMotionHistorySize(), 2 1729 GetMotionHistorySize(), 2
1739#endif 1730#endif
1740 ); 1731 );
1741 1732
1742 /* X valuator */ 1733 /* X valuator */
1743 xf86InitValuatorAxisStruct(device, 0, -1, -1, 1, 0, 1); 1734 xf86InitValuatorAxisStruct(device, 0, -1, -1, 1, 0, 1);
1744 xf86InitValuatorDefaults(device, 0); 1735 xf86InitValuatorDefaults(device, 0);
@@ -1850,28 +1841,26 @@ MouseConvert(InputInfoPtr pInfo, int fir @@ -1850,28 +1841,26 @@ MouseConvert(InputInfoPtr pInfo, int fir
1850 1841
1851 return TRUE; 1842 return TRUE;
1852} 1843}
1853 1844
1854/********************************************************************** 1845/**********************************************************************
1855 * 1846 *
1856 * FlushButtons -- reset button states. 1847 * FlushButtons -- reset button states.
1857 * 1848 *
1858 **********************************************************************/ 1849 **********************************************************************/
1859 1850
1860static void 1851static void
1861FlushButtons(MouseDevPtr pMse) 1852FlushButtons(MouseDevPtr pMse)
1862{ 1853{
1863 int i, blocked; 
1864 
1865 pMse->lastButtons = 0; 1854 pMse->lastButtons = 0;
1866 pMse->lastMappedButtons = 0; 1855 pMse->lastMappedButtons = 0;
1867} 1856}
1868 1857
1869/********************************************************************** 1858/**********************************************************************
1870 * 1859 *
1871 * Emulate3Button support code 1860 * Emulate3Button support code
1872 * 1861 *
1873 **********************************************************************/ 1862 **********************************************************************/
1874 1863
1875 1864
1876/* 1865/*
1877 * Lets create a simple finite-state machine for 3 button emulation: 1866 * Lets create a simple finite-state machine for 3 button emulation:
@@ -3048,27 +3037,27 @@ mouseReset(InputInfoPtr pInfo, unsigned  @@ -3048,27 +3037,27 @@ mouseReset(InputInfoPtr pInfo, unsigned
3048 && (mousepriv->lastEvent - prevEvent) >= 1000) { 3037 && (mousepriv->lastEvent - prevEvent) >= 1000) {
3049 mousepriv->inReset = FALSE; 3038 mousepriv->inReset = FALSE;
3050 mousepriv->current = 0; 3039 mousepriv->current = 0;
3051 return FALSE; 3040 return FALSE;
3052 } 3041 }
3053 3042
3054 if (mousepriv->inReset) 3043 if (mousepriv->inReset)
3055 mousepriv->inReset = FALSE; 3044 mousepriv->inReset = FALSE;
3056 3045
3057#ifdef EXTMOUSEDEBUG 3046#ifdef EXTMOUSEDEBUG
3058 ErrorF("Mouse Current: %i 0x%x\n",mousepriv->current, val); 3047 ErrorF("Mouse Current: %i 0x%x\n",mousepriv->current, val);
3059#endif 3048#endif
3060  3049
3061 /* here we put the mouse specific reset detction */ 3050 /* here we put the mouse specific reset detection */
3062 /* They need to do three things: */ 3051 /* They need to do three things: */
3063 /* Check if byte may be a reset byte */ 3052 /* Check if byte may be a reset byte */
3064 /* If so: Set expectReset TRUE */ 3053 /* If so: Set expectReset TRUE */
3065 /* If convinced: Set inReset TRUE */ 3054 /* If convinced: Set inReset TRUE */
3066 /* Register BlockAndWakeupHandler */ 3055 /* Register BlockAndWakeupHandler */
3067 3056
3068 /* PS/2 */ 3057 /* PS/2 */
3069 { 3058 {
3070 unsigned char seq[] = { 0xaa, 0x00 }; 3059 unsigned char seq[] = { 0xaa, 0x00 };
3071 int len = sizeof(seq); 3060 int len = sizeof(seq);
3072 3061
3073 if (seq[mousepriv->current] == val) 3062 if (seq[mousepriv->current] == val)
3074 expectReset = TRUE; 3063 expectReset = TRUE;
@@ -3146,38 +3135,40 @@ ps2WakeupHandler(pointer data, int i, po @@ -3146,38 +3135,40 @@ ps2WakeupHandler(pointer data, int i, po
3146/************************************************************ 3135/************************************************************
3147 * 3136 *
3148 * Autoprobe stuff 3137 * Autoprobe stuff
3149 * 3138 *
3150 ************************************************************/ 3139 ************************************************************/
3151#ifdef EXTMOUSEDEBUG 3140#ifdef EXTMOUSEDEBUG
3152# define AP_DBG(x) { ErrorF("Autoprobe: "); ErrorF x; } 3141# define AP_DBG(x) { ErrorF("Autoprobe: "); ErrorF x; }
3153# define AP_DBGC(x) ErrorF x ; 3142# define AP_DBGC(x) ErrorF x ;
3154# else 3143# else
3155# define AP_DBG(x) 3144# define AP_DBG(x)
3156# define AP_DBGC(x) 3145# define AP_DBGC(x)
3157#endif 3146#endif
3158 3147
 3148static
3159MouseProtocolID hardProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,  3149MouseProtocolID hardProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,
3160 PROT_LOGIMAN, PROT_MMHIT, 3150 PROT_LOGIMAN, PROT_MMHIT,
3161 PROT_GLIDE, PROT_IMSERIAL, 3151 PROT_GLIDE, PROT_IMSERIAL,
3162 PROT_THINKING, PROT_ACECAD, 3152 PROT_THINKING, PROT_ACECAD,
3163 PROT_THINKPS2, PROT_MMPS2, 3153 PROT_THINKPS2, PROT_MMPS2,
3164 PROT_GLIDEPS2,  3154 PROT_GLIDEPS2,
3165 PROT_NETSCPS2, PROT_EXPPS2,PROT_IMPS2, 3155 PROT_NETSCPS2, PROT_EXPPS2,PROT_IMPS2,
3166 PROT_GENPS2, PROT_NETPS2, 3156 PROT_GENPS2, PROT_NETPS2,
3167 PROT_MS, 3157 PROT_MS,
3168 PROT_UNKNOWN 3158 PROT_UNKNOWN
3169}; 3159};
3170 3160
 3161static
3171MouseProtocolID softProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,  3162MouseProtocolID softProtocolList[] = { PROT_MSC, PROT_MM, PROT_LOGI,
3172 PROT_LOGIMAN, PROT_MMHIT, 3163 PROT_LOGIMAN, PROT_MMHIT,
3173 PROT_GLIDE, PROT_IMSERIAL, 3164 PROT_GLIDE, PROT_IMSERIAL,
3174 PROT_THINKING, PROT_ACECAD, 3165 PROT_THINKING, PROT_ACECAD,
3175 PROT_THINKPS2, PROT_MMPS2, 3166 PROT_THINKPS2, PROT_MMPS2,
3176 PROT_GLIDEPS2,  3167 PROT_GLIDEPS2,
3177 PROT_NETSCPS2 ,PROT_IMPS2, 3168 PROT_NETSCPS2 ,PROT_IMPS2,
3178 PROT_GENPS2, 3169 PROT_GENPS2,
3179 PROT_MS, 3170 PROT_MS,
3180 PROT_UNKNOWN 3171 PROT_UNKNOWN
3181}; 3172};
3182 3173
3183static const char * 3174static const char *
@@ -3211,27 +3202,27 @@ autoOSProtocol(InputInfoPtr pInfo, int * @@ -3211,27 +3202,27 @@ autoOSProtocol(InputInfoPtr pInfo, int *
3211 break; 3202 break;
3212 } 3203 }
3213 } 3204 }
3214 } 3205 }
3215 if (!name) { 3206 if (!name) {
3216 /* A PnP serial mouse? */ 3207 /* A PnP serial mouse? */
3217 protocolID = MouseGetPnpProtocol(pInfo); 3208 protocolID = MouseGetPnpProtocol(pInfo);
3218 if (protocolID >= 0 && protocolID < PROT_NUMPROTOS) { 3209 if (protocolID >= 0 && protocolID < PROT_NUMPROTOS) {
3219 name = ProtocolIDToName(protocolID); 3210 name = ProtocolIDToName(protocolID);
3220 xf86Msg(X_PROBED, "%s: PnP-detected protocol: \"%s\"\n", 3211 xf86Msg(X_PROBED, "%s: PnP-detected protocol: \"%s\"\n",
3221 pInfo->name, name); 3212 pInfo->name, name);
3222 } 3213 }
3223 } 3214 }
3224 if (!name && HAVE_GUESS_PROTOCOL && osInfo->GuessProtocol) { 3215 if (!name && osInfo->GuessProtocol) {
3225 name = osInfo->GuessProtocol(pInfo, 0); 3216 name = osInfo->GuessProtocol(pInfo, 0);
3226 if (name) 3217 if (name)
3227 protocolID = ProtocolNameToID(name); 3218 protocolID = ProtocolNameToID(name);
3228 } 3219 }
3229 3220
3230 if (name) { 3221 if (name) {
3231 pMse->protocolID = protocolID; 3222 pMse->protocolID = protocolID;
3232 } 3223 }
3233  3224
3234 return name; 3225 return name;
3235} 3226}
3236 3227
3237/* 3228/*
@@ -3285,27 +3276,27 @@ createProtoList(MouseDevPtr pMse, MouseP @@ -3285,27 +3276,27 @@ createProtoList(MouseDevPtr pMse, MouseP
3285 AP_DBGC(("\n")); 3276 AP_DBGC(("\n"));
3286#endif  3277#endif
3287 j = 0; 3278 j = 0;
3288 while (1) { 3279 while (1) {
3289 /* look for header */ 3280 /* look for header */
3290 while (j < mPriv->count) { 3281 while (j < mPriv->count) {
3291 if (((byte = mPriv->data[j++]) & para[0]) == para[1]){ 3282 if (((byte = mPriv->data[j++]) & para[0]) == para[1]){
3292 AP_DBG(("found header %2.2x\n",byte)); 3283 AP_DBG(("found header %2.2x\n",byte));
3293 next_header_candidate = j; 3284 next_header_candidate = j;
3294 count = 1; 3285 count = 1;
3295 break; 3286 break;
3296 } else { 3287 } else {
3297 /*  3288 /*
3298 * Bail ot if number of bytes per package have 3289 * Bail out if number of bytes per package have
3299 * been tested for header. 3290 * been tested for header.
3300 * Take bytes per package of leading garbage into 3291 * Take bytes per package of leading garbage into
3301 * account. 3292 * account.
3302 */ 3293 */
3303 if (j > para[4] && ++header_count > para[4]) { 3294 if (j > para[4] && ++header_count > para[4]) {
3304 j = mPriv->count; 3295 j = mPriv->count;
3305 break; 3296 break;
3306 } 3297 }
3307 } 3298 }
3308 } 3299 }
3309 /* check if remaining data matches protocol */ 3300 /* check if remaining data matches protocol */
3310 while (j < mPriv->count) { 3301 while (j < mPriv->count) {
3311 byte = mPriv->data[j++]; 3302 byte = mPriv->data[j++];
@@ -3361,27 +3352,27 @@ createProtoList(MouseDevPtr pMse, MouseP @@ -3361,27 +3352,27 @@ createProtoList(MouseDevPtr pMse, MouseP
3361 AP_DBG(("Looking for new header\n")); 3352 AP_DBG(("Looking for new header\n"));
3362 } 3353 }
3363 } 3354 }
3364 3355
3365 xf86UnblockSIGIO(blocked); 3356 xf86UnblockSIGIO(blocked);
3366  3357
3367 mPriv->protoList[k] = PROT_UNKNOWN; 3358 mPriv->protoList[k] = PROT_UNKNOWN;
3368 3359
3369 xfree(tmplist); 3360 xfree(tmplist);
3370} 3361}
3371 3362
3372 3363
3373/* This only needs to be done once */ 3364/* This only needs to be done once */
3374void **serialDefaultsList = NULL; 3365static void **serialDefaultsList = NULL;
3375 3366
3376/* 3367/*
3377 * createSerialDefaultsLists() - create a list of the different default 3368 * createSerialDefaultsLists() - create a list of the different default
3378 * settings for the serial interface of the known protocols. 3369 * settings for the serial interface of the known protocols.
3379 */ 3370 */
3380static void 3371static void
3381createSerialDefaultsList(void) 3372createSerialDefaultsList(void)
3382{ 3373{
3383 int i = 0, j, k; 3374 int i = 0, j, k;
3384 3375
3385 serialDefaultsList = (void **)xnfalloc(sizeof(void*)); 3376 serialDefaultsList = (void **)xnfalloc(sizeof(void*));
3386 serialDefaultsList[0] = NULL; 3377 serialDefaultsList[0] = NULL;
3387 3378
@@ -3671,30 +3662,30 @@ autoGood(MouseDevPtr pMse) @@ -3671,30 +3662,30 @@ autoGood(MouseDevPtr pMse)
3671 3662
3672 3663
3673#define TOT_THRESHOLD 3000 3664#define TOT_THRESHOLD 3000
3674#define VAL_THRESHOLD 40 3665#define VAL_THRESHOLD 40
3675 3666
3676/* 3667/*
3677 * checkForErraticMovements() -- check if mouse 'jumps around'. 3668 * checkForErraticMovements() -- check if mouse 'jumps around'.
3678 */ 3669 */
3679static void 3670static void
3680checkForErraticMovements(InputInfoPtr pInfo, int dx, int dy) 3671checkForErraticMovements(InputInfoPtr pInfo, int dx, int dy)
3681{ 3672{
3682 MouseDevPtr pMse = pInfo->private; 3673 MouseDevPtr pMse = pInfo->private;
3683 mousePrivPtr mPriv = (mousePrivPtr)pMse->mousePriv; 3674 mousePrivPtr mPriv = (mousePrivPtr)pMse->mousePriv;
3684#if 1 3675
3685 if (!mPriv->goodCount) 3676 if (!mPriv->goodCount)
3686 return; 3677 return;
3687#endif 3678
3688#if 0 3679#if 0
3689 if (abs(dx - mPriv->prevDx) > 300  3680 if (abs(dx - mPriv->prevDx) > 300
3690 || abs(dy - mPriv->prevDy) > 300) 3681 || abs(dy - mPriv->prevDy) > 300)
3691 AP_DBG(("erratic1 behaviour\n")); 3682 AP_DBG(("erratic1 behaviour\n"));
3692#endif 3683#endif
3693 if (abs(dx) > VAL_THRESHOLD) { 3684 if (abs(dx) > VAL_THRESHOLD) {
3694 if (sign(dx) == sign(mPriv->prevDx)) { 3685 if (sign(dx) == sign(mPriv->prevDx)) {
3695 mPriv->accDx += dx; 3686 mPriv->accDx += dx;
3696 if (abs(mPriv->accDx) > mPriv->acc) { 3687 if (abs(mPriv->accDx) > mPriv->acc) {
3697 mPriv->acc = abs(mPriv->accDx); 3688 mPriv->acc = abs(mPriv->accDx);
3698 AP_DBG(("acc=%i\n",mPriv->acc)); 3689 AP_DBG(("acc=%i\n",mPriv->acc));
3699 }  3690 }
3700 else 3691 else
@@ -3754,54 +3745,48 @@ collectData(MouseDevPtr pMse, unsigned c @@ -3754,54 +3745,48 @@ collectData(MouseDevPtr pMse, unsigned c
3754 if (mPriv->count < NUM_MSE_AUTOPROBE_TOTAL) { 3745 if (mPriv->count < NUM_MSE_AUTOPROBE_TOTAL) {
3755 mPriv->data[mPriv->count++] = u; 3746 mPriv->data[mPriv->count++] = u;
3756 if (mPriv->count <= NUM_MSE_AUTOPROBE_BYTES) { 3747 if (mPriv->count <= NUM_MSE_AUTOPROBE_BYTES) {
3757 return TRUE; 3748 return TRUE;
3758 }  3749 }
3759 } 3750 }
3760 return FALSE; 3751 return FALSE;
3761} 3752}
3762 3753
3763/**************** end of autoprobe stuff *****************/ 3754/**************** end of autoprobe stuff *****************/
3764 3755
3765 3756
3766 3757
3767#ifdef XFree86LOADER 
3768ModuleInfoRec MouseInfo = { 3758ModuleInfoRec MouseInfo = {
3769 1, 3759 1,
3770 "MOUSE", 3760 "MOUSE",
3771 NULL, 3761 NULL,
3772 0, 3762 0,
3773 MouseAvailableOptions, 3763 MouseAvailableOptions,
3774}; 3764};
3775 3765
3776static void 3766static void
3777xf86MouseUnplug(pointer p) 3767xf86MouseUnplug(pointer p)
3778{ 3768{
3779} 3769}
3780static pointer 3770static pointer
3781xf86MousePlug(pointer module, 3771xf86MousePlug(pointer module,
3782 pointer options, 3772 pointer options,
3783 int *errmaj, 3773 int *errmaj,
3784 int *errmin) 3774 int *errmin)
3785{ 3775{
3786 static Bool Initialised = FALSE; 3776 static Bool Initialised = FALSE;
3787 3777
3788 if (!Initialised) { 3778 if (!Initialised)
3789 Initialised = TRUE; 3779 Initialised = TRUE;
3790#ifndef REMOVE_LOADER_CHECK_MODULE_INFO 
3791 if (xf86LoaderCheckSymbol("xf86AddModuleInfo")) 
3792#endif 
3793 xf86AddModuleInfo(&MouseInfo, module); 
3794 } 
3795 3780
3796 xf86AddInputDriver(&MOUSE, module, 0); 3781 xf86AddInputDriver(&MOUSE, module, 0);
3797 3782
3798 return module; 3783 return module;
3799} 3784}
3800 3785
3801static XF86ModuleVersionInfo xf86MouseVersionRec = 3786static XF86ModuleVersionInfo xf86MouseVersionRec =
3802{ 3787{
3803 "mouse", 3788 "mouse",
3804 MODULEVENDORSTRING, 3789 MODULEVENDORSTRING,
3805 MODINFOSTRING1, 3790 MODINFOSTRING1,
3806 MODINFOSTRING2, 3791 MODINFOSTRING2,
3807 XORG_VERSION_CURRENT, 3792 XORG_VERSION_CURRENT,
@@ -3812,16 +3797,13 @@ static XF86ModuleVersionInfo xf86MouseVe @@ -3812,16 +3797,13 @@ static XF86ModuleVersionInfo xf86MouseVe
3812 {0, 0, 0, 0} /* signature, to be patched into the file by */ 3797 {0, 0, 0, 0} /* signature, to be patched into the file by */
3813 /* a tool */ 3798 /* a tool */
3814}; 3799};
3815 3800
3816_X_EXPORT XF86ModuleData mouseModuleData = { 3801_X_EXPORT XF86ModuleData mouseModuleData = {
3817 &xf86MouseVersionRec, 3802 &xf86MouseVersionRec,
3818 xf86MousePlug, 3803 xf86MousePlug,
3819 xf86MouseUnplug 3804 xf86MouseUnplug
3820}; 3805};
3821 3806
3822/* 3807/*
3823 Look at hitachi device stuff. 3808 Look at hitachi device stuff.
3824*/ 3809*/
3825#endif /* XFree86LOADER */ 
3826 
3827