mouse.c revision e60b397fc7f34482960cc63f63db84d6a02226d1
/** @file
*
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
* Copyright 1993 by David Dawes <dawes@xfree86.org>
* Copyright 2002 by SuSE Linux AG, Author: Egbert Eich
* Copyright 1994-2002 by The XFree86 Project, Inc.
* Copyright 2002 by Paul Elliott
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of copyright holders not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. The copyright holders
* make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */
/*
* [JCH-96/01/21] Added fourth button support for PROT_GLIDEPOINT mouse
* protocol.
*/
/*
* [TVO-97/03/05] Added microsoft IntelliMouse support
*/
/*
* [PME-02/08/11] Added suport for drag lock buttons
* for use with 4 button trackballs for convenience
* and to help limited dexterity persons
*/
#ifdef VBOX
/* this is necessary to prevent redirecting sscanf to isoc99_sscanf which is
* glibc 2.7++ only */
#define _GNU_SOURCE
#endif
#ifdef XFree86LOADER
# include "xorg-server.h"
#else
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
#endif
#include <math.h>
#include <string.h>
#include <stdio.h>
#define NEED_EVENTS
#include "xf86.h"
#ifdef XINPUT
#include "extnsionst.h"
#include "extinit.h"
#else
#include "inputstr.h"
#endif
#include "xf86Xinput.h"
#include "xf86_OSproc.h"
#include "xf86OSmouse.h"
#ifndef NEED_XF86_TYPES
#define NEED_XF86_TYPES /* for xisb.h when !XFree86LOADER */
#endif
#include "compiler.h"
#include "xisb.h"
#include "mouse.h"
#include "mousePriv.h"
#include "mipointer.h"
#ifdef VBOX
#include "VBoxUtils.h"
#include "version-generated.h"
/* Xorg 7.1 does not include xf86_ansic.h anymore. Don't reinclude this
* file as it renamed ANSI C functions to xf86*. */
extern int abs(int);
extern long strtol(const char*,char**,int);
#endif
enum {
/* number of bits in mapped nibble */
NIB_BITS=4,
/* size of map of nibbles to bitmask */
/* mask for map */
/* number of maps to map all the buttons */
};
/*data to be used in implementing trackball drag locks.*/
typedef struct _DragLockRec {
/* Fields used to implement trackball drag locks. */
/* mask for those buttons that are ordinary drag lock buttons */
int lockButtonsM;
/* mask for the master drag lock button if any */
int masterLockM;
int lockLastButtons;
/*
* true if master lock state i.e. master drag lock
* button has just been pressed
*/
int masterTS;
/* simulate these buttons being down although they are not */
int simulatedDown;
/*
* data to map bits for drag lock buttons to corresponding
* bits for the target buttons
*/
} DragLockRec, *DragLockPtr;
#ifdef XFree86LOADER
#endif
#if 0
#endif
int *y);
#ifdef SUPPORT_MOUSE_RESET
#endif
/* mouse autoprobe stuff */
1,
#ifdef VBOX
"vboxmouse",
#else
"mouse",
#endif
NULL,
/*MouseUnInit,*/NULL,
NULL,
0
};
typedef enum {
} MouseOpts;
#ifdef XFree86LOADER
static const OptionInfoRec mouseOptions[] = {
/* serial options */
/* end serial options */
};
#endif
#define RETRY_COUNT 4
/*
* Microsoft (all serial models), Logitech MouseMan, First Mouse, etc,
* ALPS GlidePoint, Thinking Mouse.
*/
static const char *msDefaults[] = {
"BaudRate", "1200",
"DataBits", "7",
"StopBits", "1",
"Parity", "None",
"FlowControl", "None",
"VTime", "0",
"VMin", "1",
};
/* MouseSystems */
static const char *mlDefaults[] = {
"BaudRate", "1200",
"DataBits", "8",
"StopBits", "2",
"Parity", "None",
"FlowControl", "None",
"VTime", "0",
"VMin", "1",
};
/* MMSeries */
static const char *mmDefaults[] = {
"BaudRate", "1200",
"DataBits", "8",
"StopBits", "1",
"Parity", "Odd",
"FlowControl", "None",
"VTime", "0",
"VMin", "1",
};
#if 0
/* Logitech series 9 *//* same as msc: now mlDefaults */
static const char *logiDefaults[] = {
"BaudRate", "1200",
"DataBits", "8",
"StopBits", "2",
"Parity", "None",
"FlowControl", "None",
"VTime", "0",
"VMin", "1",
};
#endif
/* Hitachi Tablet */
static const char *mmhitDefaults[] = {
"BaudRate", "1200",
"DataBits", "8",
"StopBits", "1",
"Parity", "None",
"FlowControl", "None",
"VTime", "0",
"VMin", "1",
};
/* AceCad Tablet */
static const char *acecadDefaults[] = {
"BaudRate", "9600",
"DataBits", "8",
"StopBits", "1",
"Parity", "Odd",
"FlowControl", "None",
"VTime", "0",
"VMin", "1",
};
static MouseProtocolRec mouseProtocols[] = {
/* Serial protocols */
/* Standard PS/2 */
/* Extended PS/2 */
/* Bus Mouse */
/* Auto-detect (PnP) */
/* Misc (usually OS-specific) */
/* end of list */
};
#ifdef XFree86LOADER
/*ARGSUSED*/
static const OptionInfoRec *
MouseAvailableOptions(void *unused)
{
return (mouseOptions);
}
#endif
/* Process options common to all mouse types. */
static void
{
char *s;
int origButtons;
int i;
}
"Emulate3Buttons", FALSE);
}
"Emulate3Timeout", 50);
if (pMse->emulate3ButtonsSoft)
}
if (pMse->chordMiddle)
} else
} else
if (s) {
int lock; /* lock button */
int target; /* target button */
int i, j; /* indexes */
char *s1; /* parse input string */
/* init code */
/* initial string to be taken apart */
s1 = s;
/* keep getting numbers which are buttons */
/* check sanity for a button */
lock);
break;
};
/* turn into a button mask */
/* try to get drag lock button */
/*if no target, must be a master drag lock button */
/* save master drag lock mask */
"DragLock button %d is master drag lock",
lock);
} else {
/* have target button number*/
/* check target button number for sanity */
"DragLock: Invalid button number for target=%d\n",
target);
break;
}
/* target button mask */
"DragLock: button %d is drag lock for button %d\n",
lock--;
/* initialize table that maps drag lock mask to target mask */
/* add new drag lock to mask of drag locks */
}
}
/*
* fill out rest of map that maps sets of drag lock buttons
* to sets of target buttons, in the form of masks
*/
/* for each nibble */
for (i = 0; i < NIB_COUNT; i++) {
/* for each possible set of bits for that nibble */
for (j = 0; j < NIB_SIZE; j++) {
/* get first bit set in j*/
/* if 0 bits set nothing to do */
if (ff >= 0) {
/* form mask for fist bit set */
/* mask off first bit set to get remaining bits set*/
/*
* if otherbits =0 then only 1 bit set
* so j=fM
* nib_table[i][fM] already calculated if fM has
* only 1 bit set.
* nib_table[i][j] has already been filled in
* by previous loop. otherwise
* otherbits < j so nibtable[i][otherbits]
* has already been calculated.
*/
if (otherbits)
}
}
}
xfree(s);
}
if (s) {
if (!xf86NameCmp(s, "x")) {
} else if (!xf86NameCmp(s, "y")) {
if (msg)
if (msg)
if (msg)
}
} else {
}
if (msg) {
} else {
}
xfree(s);
}
int wheelButton;
"EmulateWheelButton", 4);
wheelButton = 4;
}
"EmulateWheelInertia", 10);
if (pMse->wheelInertia <= 0) {
}
"EmulateWheelTimeout", 200);
if (pMse->wheelButtonTimeout <= 0) {
}
if (s) {
if (msg)
} else {
}
if (msg) {
}
xfree(s);
}
if (s) {
if (msg)
yFromConfig = TRUE;
} else {
}
if (msg) {
}
xfree(s);
}
if (!yFromConfig) {
}
"EmulateWheelInertia: %d, "
"EmulateWheelTimeout: %d\n",
}
if (s) {
int b, n = 0;
char *s1 = s;
/* keep getting numbers which are buttons */
/* check sanity for a button */
if (b < 0 || b > MSE_MAXBUTTONS) {
"ButtonMapping: Invalid button number = %d\n", b);
break;
};
}
xfree(s);
}
/* get maximum of mapped buttons */
}
pMse->doubleClickTargetButton = 0;
if (s) {
if (msg)
} else {
}
if (msg) {
}
}
}
/*
* map bits corresponding to lock buttons.
* for each bit for a lock button,
* turn on bit corresponding to button button that the lock
* button services.
*/
static int
{
int result,i;
result = 0;
/*
* for each nibble group of bits, use
* map for that group to get corresponding
* bits, turn them on.
* if 4 or less buttons only first map will
* need to be used.
*/
}
return result;
}
static void
{
return;
}
if (pMse->sampleRate) {
pMse->sampleRate);
}
if (pMse->resolution) {
pMse->resolution);
}
}
static void
{
}
if (clearDTR) {
xf86ErrorF("ClearDTR");
if (clearRTS)
xf86ErrorF(", ");
}
if (clearRTS) {
xf86ErrorF("ClearRTS");
}
xf86ErrorF("\n");
}
}
static MouseProtocolID
ProtocolNameToID(const char *name)
{
int i;
for (i = 0; mouseProtocols[i].name; i++)
return mouseProtocols[i].id;
return PROT_UNKNOWN;
}
static const char *
{
int i;
switch (id) {
case PROT_UNKNOWN:
return "Unknown";
break;
case PROT_UNSUP:
return "Unsupported";
break;
default:
for (i = 0; mouseProtocols[i].name; i++)
return mouseProtocols[i].name;
return "Invalid";
}
}
const char *
{
return ProtocolIDToName(id);
}
xf86MouseProtocolNameToID(const char *name)
{
return ProtocolNameToID(name);
}
static int
{
int i;
switch (id) {
case PROT_UNKNOWN:
case PROT_UNSUP:
return MSE_NONE;
break;
default:
for (i = 0; mouseProtocols[i].name; i++)
return mouseProtocols[i].class;
return MSE_NONE;
}
}
static MouseProtocolPtr
int i;
switch (id) {
case PROT_UNKNOWN:
case PROT_UNSUP:
return NULL;
break;
default:
for (i = 0; mouseProtocols[i].name; i++)
return &mouseProtocols[i];
}
return NULL;
}
}
static Bool
InitProtocols(void)
{
int classes;
int i;
if (osInfo)
return TRUE;
osInfo = xf86OSMouseInit(0);
if (!osInfo)
return FALSE;
if (!osInfo->SupportedInterfaces)
return FALSE;
if (!classes)
return FALSE;
/* Mark unsupported interface classes. */
for (i = 0; mouseProtocols[i].name; i++)
for (i = 0; mouseProtocols[i].name; i++)
if (!osInfo->CheckProtocol ||
/* NetBSD uses PROT_BM for "PS/2". */
for (i = 0; mouseProtocols[i].name; i++)
return TRUE;
}
static InputInfoPtr
{
const char *device;
int i;
#ifdef VBOX
"VirtualBox guest additions mouse driver version "
VBOX_VERSION_STRING "\n");
#endif
if (!InitProtocols())
return NULL;
return NULL;
/* Initialise the InputInfoRec. */
pInfo->history_size = 0;
pInfo->private_flags = 0;
pInfo->always_core_feedback = 0;
/* Check if SendDragEvents has been disabled. */
}
/* Allocate the MouseDevRec and initialise it. */
/*
* XXX This should be done by a function in the core server since the
* MouseDevRec is defined in the os-support layer.
*/
return pInfo;
#ifdef VBOX
protocol = "ImPS/2";
#else
/* Find the protocol type. */
if (protocol) {
} else if (osInfo->DefaultProtocol) {
}
if (!protocol) {
return pInfo;
}
#endif
/* Default Mapping: 1 2 3 8 9 10 11 ... */
for (i = 0; i < MSE_MAXBUTTONS; i++)
do {
switch (protocolID) {
case PROT_AUTO:
protocolID = id;
}
}
}
break;
case PROT_UNKNOWN:
/* Check for a builtin OS-specific protocol,
* and call its PreInit. */
if (osInfo->CheckProtocol
} else
}
}
return pInfo;
}
return pInfo;
break;
case PROT_UNSUP:
"%s: Protocol \"%s\" is not supported on this "
return pInfo;
break;
default:
break;
}
} while (!detected);
} else {
}
}
if (device)
return pInfo;
/* Collect the options, and process the common options. */
/* XXX should handle this OS dependency elsewhere. */
#ifndef __OS2ELF__
/* OS/2 has a mouse handled by the OS - it cannot fail here */
/* Check if the device can be opened. */
if (xf86GetAllowMouseOpenFail())
else {
return pInfo;
}
}
#endif
#ifdef VBOX
#else
return pInfo;
#endif
return pInfo;
}
static void
{
int pBufP;
int c;
unsigned char *pBuf, u;
/*
* Set blocking to -1 on the first call because we know there is data to
* read. Xisb automatically clears it after one successful read so that
* succeeding reads are preceeded by a select with a 0 timeout to prevent
* read from blocking indefinitely.
*/
u = (unsigned char)c;
#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG)
ErrorF("mouse byte: %2.2x\n",u);
#endif
#if 1
/* if we do autoprobing collect the data */
continue;
#endif
#ifdef SUPPORT_MOUSE_RESET
if (mouseReset(pInfo,u)) {
pBufP = 0;
continue;
}
#endif
/*
* Buffer contains a full packet, which has already been processed:
* Empty the buffer and check for optional 4th byte, which will be
* processed directly, without being put into the buffer first.
*/
pBufP = 0;
/*
* Hack for Logitech MouseMan Mouse - Middle button
*
* Unfortunately this mouse has variable length packets: the
* standard Microsoft 3 byte packet plus an optional 4th byte
* whenever the middle button status changes.
*
* We have already processed the standard packet with the
* movement and button info. Now post an event message with
* the old status of the left and right buttons and the
* updated middle button.
*/
/*
* Even worse, different MouseMen and TrackMen differ in the
* 4th byte: some will send 0x00/0x20, others 0x01/0x21, or
* even 0x02/0x22, so I have to strip off the lower bits.
* [CHRIS-211092]
*
* [JCH-96/01/21]
* HACK for ALPS "fourth button". (It's bit 0x10 of the
* "fourth byte" and it is activated by tapping the glidepad
* with the finger! 8^) We map it to bit bit3, and the
* reverse map in xf86Events just has to be extended so that
* it is identified as Button 4. The lower half of the
* reverse-map may remain unchanged.
*/
/*
* [KAZU-030897]
* Receive the fourth byte only when preceeding three bytes
* have been detected (pBufP >= pMse->protoPara[4]). In the
* previous versions, the test was pBufP == 0; we may have
* mistakingly received a byte even if we didn't see anything
* preceeding the byte.
*/
#ifdef EXTMOUSEDEBUG
ErrorF("mouse 4th byte %02x\n",u);
#endif
buttons = 0;
switch (pMse->protocolID) {
/*
* [KAZU-221197]
* IntelliMouse, NetMouse (including NetMouse Pro) and Mie
* Mouse always send the fourth byte, whereas the fourth byte
* is optional for GlidePoint and ThinkingMouse. The fourth
* byte is also optional for MouseMan+ and FirstMouse+ in
* their native mode. It is always sent if they are in the
* IntelliMouse compatible mode.
*/
case PROT_IMSERIAL: /* IntelliMouse, NetMouse, Mie Mouse,
MouseMan+ */
dz = (u & 0x08) ?
(u & 0x0f) - 16 : (u & 0x0f);
dz = 0;
| ((int)(u & 0x20) >> 2)
break;
case PROT_GLIDE:
case PROT_THINKING:
/* fall through */
default:
break;
}
goto post_event;
}
}
/* End of packet buffer flush and 4th byte hack. */
/*
* Append next byte to buffer (which is empty or contains an
* incomplete packet); iterate if packet (still) not complete.
*/
#ifdef EXTMOUSEDEBUG2
{
int i;
for ( i=0; i < pBufP; i++)
ErrorF("\n");
}
#endif
/*
* Hack for resyncing: We check here for a package that is:
* a) illegal (detected by wrong data-package header)
* b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
* c) bad header-package
*
* NOTE: b) is a violation of the MouseSystems-Protocol, since values
* of -128 are allowed, but since they are very seldom we can
* easily use them as package-header with no button pressed.
* NOTE/2: On a PS/2 mouse any byte is valid as a data byte.
* Furthermore, 0x80 is not valid as a header byte. For a PS/2
* mouse we skip checking data bytes. For resyncing a PS/2
* mouse we require the two most significant bits in the header
* byte to be 0. These are the overflow bits, and in case of
* an overflow we actually lose sync. Overflows are very rare,
* however, and we quickly gain sync again after an overflow
* condition. This is the best we can do. (Actually, we could
* use bit 0x08 in the header byte for resyncing, since that
* bit is supposed to be always on, but nobody told Microsoft...)
*/
/*
* [KAZU,OYVIND-120398]
* The above hack is wrong! Because of b) above, we shall see
* erroneous mouse events so often when the MouseSystem mouse is
* moved quickly. As for the PS/2 and its variants, we don't need
* to treat them as special cases, because protoPara[2] and
* protoPara[3] are both 0x00 for them, thus, any data bytes will
* never be discarded. 0x80 is rejected for MMSeries, Logitech
* and MMHittab protocols, because protoPara[2] and protoPara[3]
* are 0x80 and 0x00 respectively. The other protocols are 7-bit
* protocols; there is no use checking 0x80.
*
* All in all we should check the condition a) only.
*/
/*
* [OYVIND-120498]
* Check packet for valid data:
* If driver is in sync with datastream, the packet is considered
*
* If packet is bad, we discard the first byte and shift the buffer.
* Next iteration will then check the new situation for validity.
*
* If flag MF_SAFE is set in proto[7] and the driver
* is out of sync, the packet is also considered bad if
* any of the data bytes contains a valid header byte value.
* This situation could occur if the buffer contains
* the tail of one packet and the header of the next.
*
* Note: The driver starts in out-of-sync mode (pMse->inSync = 0).
*/
baddata = 0;
/* All databytes must be valid. */
for (j = 1; j < pBufP; j++ )
baddata = 1;
/* If out of sync, don't mistake a header byte for data. */
for (j = 1; j < pBufP; j++ )
baddata = 1;
/* Accept or reject the packet ? */
#ifdef EXTMOUSEDEBUG
ErrorF("mouse driver lost sync\n");
#endif
}
#ifdef EXTMOUSEDEBUG
#endif
/* Tell auto probe that we are out of sync */
for (j = 0; j < pBufP; j++)
continue;
}
/* Tell auto probe that we were successful */
#ifdef EXTMOUSEDEBUG
ErrorF("mouse driver back in sync\n");
#endif
}
continue;
/*
* Packet complete and verified, now process it ...
*/
switch (pMse->protocolID) {
case PROT_LOGIMAN: /* MouseMan / TrackMan [CHRIS-211092] */
case PROT_MS: /* Microsoft */
if (pMse->chordMiddle)
else
break;
case PROT_GLIDE: /* ALPS GlidePoint */
case PROT_THINKING: /* ThinkingMouse */
case PROT_IMSERIAL: /* IntelliMouse, NetMouse, Mie Mouse, MouseMan+ */
break;
case PROT_MSC: /* Mouse Systems Corp */
break;
case PROT_MMHIT: /* MM_HitTablet */
if (buttons != 0)
break;
case PROT_ACECAD: /* ACECAD */
/* ACECAD is almost exactly like MM but the buttons are different */
break;
case PROT_MM: /* MM Series */
case PROT_LOGI: /* Logitech Mice */
break;
case PROT_BM: /* BusMouse */
break;
case PROT_PS2: /* PS/2 mouse */
case PROT_GENPS2: /* generic PS/2 mouse */
break;
/* PS/2 mouse variants */
case PROT_IMPS2: /* IntelliMouse PS/2 */
case PROT_NETPS2: /* NetMouse PS/2 */
/*
* The next cast must be 'signed char' for platforms (like PPC)
* where char defaults to unsigned.
*/
"Mouse autoprobe: Changing protocol to %s\n",
goto REDO_INTERPRET;
} else
dz = 0;
}
break;
case PROT_EXPPS2: /* IntelliMouse Explorer PS/2 */
goto REDO_INTERPRET;
}
break;
case PROT_MMPS2: /* MouseMan+ PS/2 */
/* extended data packet */
case 1: /* wheel data packet */
break;
case 2: /* Logitech reserves this packet type */
/*
* IBM ScrollPoint uses this packet to encode its
* stick movement.
*/
break;
case 0: /* device type packet - shouldn't happen */
default:
dz = 0;
break;
}
} else {
}
break;
case PROT_GLIDEPS2: /* GlidePoint PS/2 */
break;
case PROT_NETSCPS2: /* NetScroll PS/2 */
break;
case PROT_THINKPS2: /* ThinkingMouse PS/2 */
break;
case PROT_SYSMOUSE: /* sysmouse */
/* FreeBSD sysmouse sends additional data bytes */
/*
* These casts must be 'signed char' for platforms (like PPC)
* where char defaults to unsigned.
*/
}
break;
case PROT_VALUMOUSESCROLL: /* Kensington ValuMouseScroll */
break;
default: /* There's a table error */
#ifdef EXTMOUSEDEBUG
ErrorF("mouse table error\n");
#endif
continue;
}
#ifdef EXTMOUSEDEBUG
ErrorF("packet");
for ( j=0; j < pBufP; j++)
ErrorF("\n");
#endif
#ifdef EXTMOUSEDEBUG
#endif
/* When auto-probing check if data makes sense */
/* post an event */
/*
* We don't reset pBufP here yet, as there may be an additional data
* byte in some protocols. See above.
*/
}
}
/*
* MouseCtrl --
* Alter the control parameters for the mouse. Note that all special
* protocol values are handled by dix.
*/
static void
{
#ifdef EXTMOUSEDEBUG
#endif
}
/*
***************************************************************************
*
* MouseProc --
*
***************************************************************************
*/
static int
{
int i;
#ifdef VBOX
#endif
#ifdef VBOX
#endif
switch (what)
{
case DEVICE_INIT:
/*
* [KAZU-241097] We don't know exactly how many buttons the
* device has, so setup the map with the maximum number.
*/
for (i = 0; i < MSE_MAXBUTTONS; i++)
/* X valuator */
/* Y valuator */
#ifdef EXTMOUSEDEBUG
#endif
break;
case DEVICE_ON:
#ifdef VBOX
if (!pPriv)
{
if (pPriv)
{
}
}
if (pPriv)
{
{
}
}
#endif
else {
else
} else {
if (!SetupMouse(pInfo)) {
} else {
else
} else {
else
}
}
}
}
}
pMse->lastButtons = 0;
pMse->lastMappedButtons = 0;
pMse->emulateState = 0;
{
}
break;
case DEVICE_OFF:
case DEVICE_CLOSE:
#ifdef VBOX
if (VBoxMouseFini())
{
/** @todo what to do? */
}
#endif
}
{
}
}
usleep(300000);
break;
}
return Success;
}
/*
***************************************************************************
*
* MouseConvert --
* Convert valuators to X and Y.
*
***************************************************************************
*/
static Bool
{
return FALSE;
*x = v0;
*y = v1;
return TRUE;
}
/**********************************************************************
*
* FlushButtons -- send button up events for sanity.
*
**********************************************************************/
static void
{
/* If no button down is pending xf86PostButtonEvent()
* will discard them. So we are on the safe side. */
int i, blocked;
pMse->lastButtons = 0;
pMse->lastMappedButtons = 0;
blocked = xf86BlockSIGIO ();
for (i = 1; i <= 5; i++)
}
/**********************************************************************
*
* Emulate3Button support code
*
**********************************************************************/
/*
* Lets create a simple finite-state machine for 3 button emulation:
*
* We track buttons 1 and 3 (left and right). There are 11 states:
* 0 ground - initial state
* 1 delayed left - left pressed, waiting for right
* 2 delayed right - right pressed, waiting for left
* 3 pressed middle - right and left pressed, emulated middle sent
* 4 pressed left - left pressed and sent
* 5 pressed right - right pressed and sent
* 6 released left - left released after emulated middle
* 7 released right - right released after emulated middle
* 8 repressed left - left pressed after released left
* 9 repressed right - right pressed after released right
* 10 pressed both - both pressed, not emulating middle
*
* At each state, we need handlers for the following events
* 0: no buttons down
* 1: left button down
* 2: right button down
* 3: both buttons down
* 4: emulate3Timeout passed without a button change
* Note that button events are not deltas, they are the set of buttons being
* pressed now. It's possible (ie, mouse hardware does it) to go from (eg)
* left down to right down without anything in between, so all cases must be
* handled.
*
* a handler consists of three values:
* 0: action1
* 1: action2
* 2: new emulation state
*
* action > 0: ButtonPress
* action = 0: nothing
* action < 0: ButtonRelease
*
* The comment preceeding each section is the current emulation state.
* The comments to the right are of the form
* <button state> (<events>) -> <new emulation state>
* which should be read as
* If the buttons are in <button state>, generate <events> then go to
* <new emulation state>.
*/
/* 0 ground */
{
{ 0, 0, 0 }, /* nothing -> ground (no change) */
{ 0, 0, 1 }, /* left -> delayed left */
{ 0, 0, 2 }, /* right -> delayed right */
{ 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
{ 0, 0, -1 } /* timeout N/A */
},
/* 1 delayed left */
{
{ 1, -1, 0 }, /* nothing (left event) -> ground */
{ 0, 0, 1 }, /* left -> delayed left (no change) */
{ 1, -1, 2 }, /* right (left event) -> delayed right */
{ 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
{ 1, 0, 4 }, /* timeout (left press) -> pressed left */
},
/* 2 delayed right */
{
{ 3, -3, 0 }, /* nothing (right event) -> ground */
{ 3, -3, 1 }, /* left (right event) -> delayed left (no change) */
{ 0, 0, 2 }, /* right -> delayed right (no change) */
{ 2, 0, 3 }, /* left & right (middle press) -> pressed middle */
{ 3, 0, 5 }, /* timeout (right press) -> pressed right */
},
/* 3 pressed middle */
{
{ -2, 0, 0 }, /* nothing (middle release) -> ground */
{ 0, 0, 7 }, /* left -> released right */
{ 0, 0, 6 }, /* right -> released left */
{ 0, 0, 3 }, /* left & right -> pressed middle (no change) */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 4 pressed left */
{
{ -1, 0, 0 }, /* nothing (left release) -> ground */
{ 0, 0, 4 }, /* left -> pressed left (no change) */
{ -1, 0, 2 }, /* right (left release) -> delayed right */
{ 3, 0, 10 }, /* left & right (right press) -> pressed both */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 5 pressed right */
{
{ -3, 0, 0 }, /* nothing (right release) -> ground */
{ -3, 0, 1 }, /* left (right release) -> delayed left */
{ 0, 0, 5 }, /* right -> pressed right (no change) */
{ 1, 0, 10 }, /* left & right (left press) -> pressed both */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 6 released left */
{
{ -2, 0, 0 }, /* nothing (middle release) -> ground */
{ -2, 0, 1 }, /* left (middle release) -> delayed left */
{ 0, 0, 6 }, /* right -> released left (no change) */
{ 1, 0, 8 }, /* left & right (left press) -> repressed left */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 7 released right */
{
{ -2, 0, 0 }, /* nothing (middle release) -> ground */
{ 0, 0, 7 }, /* left -> released right (no change) */
{ -2, 0, 2 }, /* right (middle release) -> delayed right */
{ 3, 0, 9 }, /* left & right (right press) -> repressed right */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 8 repressed left */
{
{ -2, -1, 0 }, /* nothing (middle release, left release) -> ground */
{ -2, 0, 4 }, /* left (middle release) -> pressed left */
{ -1, 0, 6 }, /* right (left release) -> released left */
{ 0, 0, 8 }, /* left & right -> repressed left (no change) */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 9 repressed right */
{
{ -2, -3, 0 }, /* nothing (middle release, right release) -> ground */
{ -3, 0, 7 }, /* left (right release) -> released right */
{ -2, 0, 5 }, /* right (middle release) -> pressed right */
{ 0, 0, 9 }, /* left & right -> repressed right (no change) */
{ 0, 0, -1 }, /* timeout N/A */
},
/* 10 pressed both */
{
{ -1, -3, 0 }, /* nothing (left release, right release) -> ground */
{ -3, 0, 4 }, /* left (right release) -> pressed left */
{ -1, 0, 5 }, /* right (left release) -> pressed right */
{ 0, 0, 10 }, /* left & right -> pressed both (no change) */
{ 0, 0, -1 }, /* timeout N/A */
},
};
/*
* Table to allow quick reversal of natural button mapping to correct mapping
*/
/*
* [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol
* with a fourth button activated by tapping the PAD.
* The 2nd line corresponds to 4th button on; the drv sends
* the buttons in the following map (MSBit described first) :
* 0 | 4th | 1st | 2nd | 3rd
* And we remap them (MSBit described first) :
* 0 | 4th | 3rd | 2nd | 1st
*/
1, 5, 3, 7,
8, 12, 10, 14,
9, 13, 11, 15 };
8, 10, 9, 11,
4, 6, 5, 7,
12, 14, 13, 15 };
static CARD32
{
int sigstate;
int id;
sigstate = xf86BlockSIGIO ();
} else {
}
return 0;
}
static Bool
{
if (!pMse->emulate3ButtonsSoft)
return TRUE;
if (pMse->emulate3Pending)
return FALSE;
}
{
int ms;
if (pMse->emulate3Pending)
{
if (ms <= 0)
ms = 0;
}
}
int i,
{
int ms;
if (pMse->emulate3Pending)
{
if (ms <= 0)
buttonTimer (pInfo);
}
}
/*******************************************************************
*
* Post mouse events
*
*******************************************************************/
static void
{
int emulateButtons;
int wheelButtonMask;
int ms;
/* Do single button double click */
if (pMse->doubleClickSourceButtonMask) {
if (!(pMse->doubleClickOldSourceState)) {
/* double-click button has just been pressed. Ignore it if target button
* is already down.
*/
/* Target button isn't down, so send a double-click */
}
}
}
else
/* Whatever happened, mask the double-click button so it doesn't get
* processed as a normal button as well.
*/
}
if (pMse->emulateWheel) {
/* Emulate wheel button handling */
if (change & wheelButtonMask) {
if (buttons & wheelButtonMask) {
/* Start timeout handling */
} else {
if (0 < ms) {
/*
* If the button is released early enough emit the button
*/
}
}
} else
/* Intercept wheel emulation. */
if (buttons & wheelButtonMask) {
if (ms <= 0) {
/* Y axis movement */
if (pMse->wheelYDistance < 0) {
} else {
}
/*
* Synthesize the press and release, but not when
* the button to be synthesized is already pressed
* "for real".
*/
if (!(emuWheelButtonMask & buttons) ||
}
}
}
/* X axis movement */
if (pMse->wheelXDistance < 0) {
} else {
}
/*
* Synthesize the press and release, but not when
* the button to be synthesized is already pressed
* "for real".
*/
if (!(emuWheelButtonMask & buttons) ||
}
}
}
}
/* Absorb the mouse movement while the wheel button is pressed. */
dx = 0;
dy = 0;
}
/*
* Button events for the wheel button are only emitted through
* the timeout code.
*/
buttons &= ~wheelButtonMask;
change &= ~wheelButtonMask;
}
#ifdef VBOX
{
{
unsigned int abs_x;
unsigned int abs_y;
{
/* convert to screen resolution */
int x, y;
/* send absolute movement */
}
else
{
/* send relative event */
}
}
else
{
/* send relative event */
}
}
#else
#endif
if (change) {
/*
* adjust buttons state for drag locks!
* if there is drag locks
*/
int tarOfGoingDown, tarOfDown;
int realbuttons;
/* get drag lock block */
/* save real buttons */
/* if drag lock used */
/* state of drag lock buttons not seen always up */
/*
* if lock buttons being depressed changes state of
* targets simulatedDown.
*/
/* targets of drag locks down */
/*
* when simulatedDown set and target pressed,
* simulatedDown goes false
*/
/*
* if master drag lock released
* then master drag lock state on
*/
/* if master state, buttons going down are simulatedDown */
/* if any button pressed, no longer in master drag lock state */
if (realbuttons & change)
/* if simulatedDown or drag lock down, simulate down */
/* master button not seen */
/* buttons changed since last time */
/* save this time for next last time. */
}
if (pMse->emulate3Buttons
/* handle all but buttons 1 & 3 normally */
change &= ~05;
/* emulate the third button by the other two */
pMse->emulateState =
} else {
}
}
while (change) {
}
}
}
static void
{
int zbutton = 0;
int i, b, buttons = 0;
else
/* Remap mouse buttons */
for (i = 0; b; i++) {
if (b & 1)
b >>= 1;
}
/* Map the Z axis movement. */
/* XXX Could this go in the conversion_proc? */
case MSE_NOZMAP: /* do nothing */
break;
case MSE_MAPTOX:
if (dz != 0) {
dz = 0;
}
break;
case MSE_MAPTOY:
if (dz != 0) {
dz = 0;
}
break;
default: /* buttons */
else if (dz < 0)
else if (dz > 0)
dz = 0;
break;
}
/* Apply angle offset */
if (pMse->angleOffset != 0) {
}
}
/*
* If dz has been mapped to a button `down' event, we need to cook up
* a corresponding button `up' event.
*/
if (zbutton) {
}
}
/******************************************************************
*
* Mouse Setup Code
*
******************************************************************/
/*
* This array is indexed by the MouseProtocolID values, so the order of the
* entries must match that of the MouseProtocolID enum in xf86OSmouse.h.
*/
/* --header-- ---data--- packet -4th-byte- mouse */
/* mask id mask id bytes mask id flags */
/* Serial mice */
/* PS/2 variants */
/* Bus Mouse */
};
/*
* SetupMouse --
* Sets up the mouse parameters
*/
static Bool
{
int i;
/* Handle the "Auto" protocol. */
/*
* We come here when user specifies protocol "auto" in
* the configuration file or thru the xf86misc extensions.
* So we initialize autoprobing here.
* try to guess protocol from incoming data.
*/
if (name) {
#ifdef EXTMOUSEDEBUG
#endif
}
}
if (automatic) {
if (name) {
/* Possible protoPara overrides from SetupAuto. */
if (protoPara[i] != -1)
} else {
#if 1
#else
return FALSE;
#endif
}
}
/*
* If protocol has changed fetch the default options
* for the new protocol.
*/
if ((pMse->protocolID >= 0)
/*
* If baudrate is set write it back to the option
* list so that the serial interface code can access
* the new value. Not set means default.
*/
}
/* Set the port parameters. */
if (!automatic)
if (!initMouseHW(pInfo))
return FALSE;
pMse->protoBufTail = 0;
return TRUE;
}
/********************************************************************
*
* Mouse HW setup code
*
********************************************************************/
/*
** The following lines take care of the Logitech MouseMan protocols.
** The "Logitech" protocol is for the old "series 9" Logitech products.
** All products since then use the "MouseMan" protocol. Some models
** were programmable, but most (all?) of the current models are not.
**
** NOTE: There are different versions of both MouseMan and TrackMan!
** Hence I add another protocol PROT_LOGIMAN, which the user can
** specify as MouseMan in his XF86Config file. This entry was
** formerly handled as a special case of PROT_MS. However, people
** who don't have the middle button problem, can still specify
** Microsoft and use PROT_MS.
**
** By default, these mice should use a 3 byte Microsoft protocol
** plus a 4th byte for the middle button. However, the mouse might
** have switched to a different protocol before we use it, so I send
** the proper sequence just in case.
**
** NOTE: - all commands to (at least the European) MouseMan have to
** be sent at 1200 Baud.
** - each command starts with a '*'.
** - whenever the MouseMan receives a '*', it will switch back
** to 1200 Baud. Hence I have to select the desired protocol
** first, then select the baud rate.
**
** The protocols supported by the (European) MouseMan are:
** - 5 byte packed binary protocol, as with the Mouse Systems
** mouse. Selected by sequence "*U".
** - 2 button 3 byte MicroSoft compatible protocol. Selected
** by sequence "*V".
** - 3 button 3+1 byte MicroSoft compatible protocol (default).
** Selected by sequence "*X".
**
** The following baud rates are supported:
** - 1200 Baud (default). Selected by sequence "*n".
** - 9600 Baud. Selected by sequence "*q".
**
** Selecting a sample rate is no longer supported with the MouseMan!
** [CHRIS-211092]
*/
/*
* Do a reset wrap mode before reset.
*/
#define do_ps2Reset(x) { \
int i = RETRY_COUNT;\
while (i-- > 0) { \
xf86FlushInput(x->fd); \
if (ps2Reset(x)) break; \
} \
}
static Bool
{
const char *s;
unsigned char c;
int speed;
int paramlen = 0;
int count = RETRY_COUNT;
switch (pMse->protocolID) {
case PROT_LOGI: /* Logitech Mice */
/*
* The baud rate selection command must be sent at the current
* baud rate; try all likely settings.
*/
switch (speed) {
case 9600:
s = "*q";
break;
case 4800:
s = "*p";
break;
case 2400:
s = "*o";
break;
case 1200:
s = "*n";
break;
default:
/* Fallback value */
speed = 1200;
s = "*n";
}
usleep(100000);
usleep(100000);
usleep(100000);
usleep(100000);
/* Select MM series data format. */
usleep(100000);
/* Set the parameters up for the MM series protocol. */
else c = 'N'; /* 150 */
break;
case PROT_LOGIMAN:
switch (speed) {
case 9600:
s = "*q";
break;
case 1200:
s = "*n";
break;
default:
/* Fallback value */
speed = 1200;
s = "*n";
}
usleep(100000);
break;
case PROT_MMHIT: /* MM_HitTablet */
/*
* Initialize Hitachi PUMA Plus - Model 1212E to desired settings.
* The tablet must be configured to be in MM mode, NO parity,
* Binary Format. pMse->sampleRate controls the sensitivity
* of the tablet. We only use this tablet for it's 4-button puck
* so we don't run in "Absolute Mode".
*/
usleep(50000);
usleep(50000);
usleep(50000);
usleep(50000);
usleep(50000);
usleep(50000);
/*
* These sample rates translate to 'lines per inch' on the Hitachi
* tablet.
*/
else c = 'd';
usleep(50000);
break;
case PROT_THINKING: /* ThinkingMouse */
/* This mouse may send a PnP ID string, ignore it. */
usleep(200000);
/* Send the command to initialize the beast. */
for (s = "E5E5"; *s; ++s) {
break;
if (c != *s)
break;
}
break;
case PROT_MSC: /* MouseSystems Corp */
usleep(100000);
break;
case PROT_ACECAD:
/* initialize */
/* A nul character resets. */
usleep(50000);
/* Stream out relative mode high resolution increments of 1. */
break;
pMse->resolution);
break;
case PROT_GENPS2:
break;
case PROT_PS2:
case PROT_GLIDEPS2:
break;
case PROT_IMPS2: /* IntelliMouse */
{
}
break;
case PROT_EXPPS2: /* IntelliMouse Explorer */
{
243, 200, 243, 200, 243, 80 };
}
break;
case PROT_NETPS2: /* NetMouse, NetMouse Pro, Mie Mouse */
case PROT_NETSCPS2: /* NetScroll */
{
}
break;
case PROT_MMPS2: /* MouseMan+, FirstMouse+ */
{
230, 232, 3, 232, 1, 232, 2, 232, 3 };
}
break;
case PROT_THINKPS2: /* ThinkingMouse */
{
243, 40, 243, 20, 243, 20, 243, 60,
243, 40, 243, 20, 243, 20 };
}
break;
case PROT_SYSMOUSE:
if (osInfo->SetMiscRes)
pMse->resolution);
break;
default:
/* Nothing to do. */
break;
}
/*
* If one part of the PS/2 mouse initialization fails
* redo complete initialization. There are mice which
* have occasional problems with initialization and
* are in an unknown state.
*/
if (ps2Init) {
REDO:
if (paramlen > 0) {
usleep(30000);
if (!count--)
return TRUE;
goto REDO;
}
usleep(30000);
}
pMse->resolution);
} else {
unsigned char c2[2];
c = 0xE6; /*230*/ /* 1:1 scaling */
if (!count--)
return TRUE;
goto REDO;
}
if (pMse->sampleRate > 0) {
else
} else {
}
if (!count--)
return TRUE;
goto REDO;
}
if (pMse->resolution > 0) {
else
c2[1] = 0;
} else {
}
if (!count--)
return TRUE;
goto REDO;
}
usleep(30000);
if (!ps2EnableDataReporting(pInfo)) {
if (!count--)
return TRUE;
goto REDO;
} else {
}
}
/*
* The PS/2 reset handling needs to be rechecked.
* We need to wait until after the 4.3 release.
*/
}
} else {
if (paramlen > 0) {
usleep(30000);
}
}
return TRUE;
}
#ifdef SUPPORT_MOUSE_RESET
static Bool
{
#ifdef EXTMOUSEDEBUG
#endif
/*
* We believe that the following is true:
* When the mouse is replugged it will send a reset package
* It takes several seconds to replug a mouse: We don't see
* events for several seconds before we see the replug event package.
* There is no significant delay between consecutive bytes
* of a replug event package.
* There are no bytes sent after the replug event package until
* the mouse is reset.
*/
return FALSE;
return FALSE;
}
#ifdef EXTMOUSEDEBUG
#endif
/* here we put the mouse specific reset detction */
/* They need to do three things: */
/* Check if byte may be a reset byte */
/* If so: Set expectReset TRUE */
/* If convinced: Set inReset TRUE */
/* Register BlockAndWakeupHandler */
/* PS/2 */
{
expectReset = TRUE;
#ifdef EXTMOUSEDEBUG
ErrorF("Found PS/2 Reset string\n");
#endif
}
}
if (!expectReset)
else
return ret;
}
static void
{
int ms;
if (ms <= 0)
ms = 0;
} else
}
static void
{
int ms;
unsigned char val;
int blocked;
if (ms > 0)
return;
blocked = xf86BlockSIGIO ();
"Got reinsert event: reinitializing PS/2 mouse\n");
val = 0xf4;
}
}
#endif /* SUPPORT_MOUSE_RESET */
/************************************************************
*
* Autoprobe stuff
*
************************************************************/
#ifdef EXTMOUSEDEBUG
# else
# define AP_DBG(x)
# define AP_DBGC(x)
#endif
};
};
static const char *
{
/* Check if the OS has a detection mechanism. */
if (name) {
switch (protocolID) {
case PROT_UNKNOWN:
/* Check for a builtin OS-specific protocol. */
/* We can only come here if the protocol has been
* changed to auto thru the xf86misc extension
* and we have detected an OS specific builtin
* protocol. Currently we cannot handle this */
} else
break;
case PROT_UNSUP:
break;
default:
break;
}
}
}
if (!name) {
/* A PnP serial mouse? */
}
}
if (name)
}
if (name) {
}
return name;
}
/*
* createProtocolList() -- create a list of protocols which may
* match on the incoming data stream.
*/
static void
{
int i, j, k = 0;
unsigned char *para;
int blocked;
AP_DBGC(("Autoprobe: "));
AP_DBGC(("\n"));
blocked = xf86BlockSIGIO ();
/* create a private copy first so we can write in the old list */
for (i = 0; protoList[i] != PROT_UNKNOWN; i++) {
}
tmplist[i] = PROT_UNKNOWN;
} else
return;
&& (k < NUM_AUTOPROBE_PROTOS - 1)) ; i++) {
unsigned char byte = 0;
int count = 0;
int next_header_candidate = 0;
int header_count = 0;
if (!GetProtocol(prot))
continue;
#ifdef EXTMOUSEDEBUG
for (j = 0; j < 7; j++)
AP_DBGC(("\n"));
#endif
j = 0;
while (1) {
/* look for header */
count = 1;
break;
} else {
/*
* Bail ot if number of bytes per package have
* been tested for header.
* Take bytes per package of leading garbage into
* account.
*/
break;
}
}
}
/* check if remaining data matches protocol */
count = 0;
/* check and eat excess byte */
AP_DBG(("excess byte found\n"));
continue;
}
}
if (count == 0) {
/* validate next header */
AP_DBG(("Complete set found\n"));
AP_DBG(("Autoprobe: header bad\n"));
break;
} else {
count++;
continue;
}
}
/* validate data */
AP_DBG(("data bad\n"));
break;
} else {
count ++;
continue;
}
}
if (!bad) {
/* this is a matching protocol */
AP_DBG(("Autoprobe: Adding protocol %s to list (entry %i)\n",
break;
}
/* we have tested number of bytes per package for header */
break;
/* we have not found anything that looks like a header */
if (!next_header_candidate)
break;
AP_DBG(("Looking for new header\n"));
}
}
}
/* This only needs to be done once */
void **serialDefaultsList = NULL;
/*
* createSerialDefaultsLists() - create a list of the different default
* settings for the serial interface of the known protocols.
*/
static void
createSerialDefaultsList(void)
{
int i = 0, j, k;
serialDefaultsList = (void **)xnfalloc(sizeof(void*));
serialDefaultsList[0] = NULL;
for (j = 0; mouseProtocols[j].name; j++) {
if (!mouseProtocols[j].defaults)
continue;
for (k = 0; k < i; k++)
continue;
i++;
sizeof(void*)*(i+1));
serialDefaultsList[i] = NULL;
}
}
typedef enum {
} validState;
/* Probing threshold values */
#define PROBE_UNCERTAINTY 50
#define BAD_CERTAINTY 6
#define BAD_INC_CERTAINTY 1
#define BAD_INC_CERTAINTY_WHEN_SYNC_LOST 2
static validState
{
if (inSync) {
/* we are sure to have found the correct protocol */
return STATE_VALID;
}
AP_DBG(("%i successful rounds to go\n",
return STATE_UNCERTAIN;
}
/* We are out of sync again */
/* We increase uncertainty of having the correct protocol */
/* We are not convinced yet to have the wrong protocol */
AP_DBG(("Changing protocol after: %i rounds\n",
return STATE_UNCERTAIN;
}
return STATE_INVALID;
}
static void
{
while (1) {
case AUTOPROBE_GOOD:
if (inSync)
return;
AP_DBG(("State GOOD\n"));
return;
case AUTOPROBE_H_GOOD:
if (inSync)
return;
AP_DBG(("State H_GOOD\n"));
return;
case AUTOPROBE_H_NOPROTO:
AP_DBG(("State H_NOPROTO\n"));
mPriv->protocolID = 0;
break;
case AUTOPROBE_H_SETPROTO:
AP_DBG(("State H_SETPROTO\n"));
== PROT_UNKNOWN) {
mPriv->protocolID = 0;
break;
AP_DBG(("Autoprobe: Trying Protocol: %s\n",
return;
}
break;
case AUTOPROBE_H_VALIDATE1:
AP_DBG(("State H_VALIDATE1\n"));
case STATE_INVALID:
break;
case STATE_VALID:
return;
case STATE_UNCERTAIN:
return;
default:
break;
}
break;
case AUTOPROBE_H_VALIDATE2:
AP_DBG(("State H_VALIDATE2\n"));
case STATE_INVALID:
break;
case STATE_VALID:
return;
case STATE_UNCERTAIN:
return;
}
break;
case AUTOPROBE_H_AUTODETECT:
AP_DBG(("State H_AUTODETECT\n"));
else
break;
case AUTOPROBE_NOPROTO:
AP_DBG(("State NOPROTO\n"));
break;
case AUTOPROBE_COLLECT:
AP_DBG(("State COLLECT\n"));
return;
break;
AP_DBG(("State CREATE_PROTOLIST\n"));
mPriv->protocolID = 0;
break;
case AUTOPROBE_AUTODETECT:
AP_DBG(("State AUTODETECT\n"));
else
break;
case AUTOPROBE_VALIDATE1:
AP_DBG(("State VALIDATE1\n"));
case STATE_INVALID:
break;
case STATE_VALID:
break;
case STATE_UNCERTAIN:
return;
}
break;
case AUTOPROBE_VALIDATE2:
AP_DBG(("State VALIDATE2\n"));
case STATE_INVALID:
break;
case STATE_VALID:
break;
case STATE_UNCERTAIN:
return;
}
break;
case AUTOPROBE_SWITCHSERIAL:
{
AP_DBG(("State SWITCHSERIAL\n"));
if (!serialDefaultsList)
AP_DBG(("Switching serial params\n"));
if ((serialDefaults =
mPriv->serialDefaultsNum = 0;
} else {
}
break;
}
{
void *defaults;
AP_DBG(("State SWITCH_PROTOCOL\n"));
if (proto == PROT_UNKNOWN)
&& (defaults == msDefaults))
== defaults)) {
AP_DBG(("Changing Protocol to %s\n",
return;
}
break;
}
}
}
}
static Bool
{
return TRUE;
case AUTOPROBE_GOOD:
case AUTOPROBE_H_GOOD:
return TRUE;
case AUTOPROBE_VALIDATE1: /* @@@ */
case AUTOPROBE_H_VALIDATE1: /* @@@ */
case AUTOPROBE_VALIDATE2:
case AUTOPROBE_H_VALIDATE2:
return TRUE;
default:
return FALSE;
}
}
#define TOT_THRESHOLD 3000
#define VAL_THRESHOLD 40
/*
* checkForErraticMovements() -- check if mouse 'jumps around'.
*/
static void
{
#if 1
return;
#endif
#if 0
AP_DBG(("erratic1 behaviour\n"));
#endif
}
else
} else {
}
}
} else
} else {
}
}
AP_DBG(("erratic2 behaviour\n"));
}
}
static void
{
if (pMse->emulate3ButtonsSoft)
}
/*
* collectData() -- collect data bytes sent by mouse.
*/
static Bool
{
return TRUE;
}
}
return FALSE;
}
/**************** end of autoprobe stuff *****************/
#ifdef XFree86LOADER
1,
"MOUSE",
NULL,
0,
};
static void
{
}
static pointer
int *errmaj,
int *errmin)
{
if (!Initialised) {
Initialised = TRUE;
#ifndef REMOVE_LOADER_CHECK_MODULE_INFO
if (xf86LoaderCheckSymbol("xf86AddModuleInfo"))
#endif
}
return module;
}
static XF86ModuleVersionInfo xf86MouseVersionRec =
{
#ifdef VBOX
"vboxmouse",
"Sun Microsystems, Inc.",
#else
"mouse",
#endif
1, 1, 0,
{0, 0, 0, 0} /* signature, to be patched into the file by */
/* a tool */
};
#ifdef VBOX
};
#else
};
#endif
/*
Look at hitachi device stuff.
*/
#endif /* XFree86LOADER */