Commit 88e90dde authored by Alan Coopersmith's avatar Alan Coopersmith

Expand tabs to spaces

Existing code had a mix of places tab & space characters were used.
Make them all spaces for consistency, since that's the new style
chosen for xorg-server.

"git diff -w" shows no changes - this is pure whitespace adjustment.
Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 580e739d
This diff is collapsed.
......@@ -46,36 +46,36 @@
#include <mach.h>
#include <sys/ioctl.h>
#define DEFAULT_MOUSE_DEV "/dev/mouse"
#define DEFAULT_MOUSE_DEV "/dev/mouse"
typedef unsigned short kev_type; /* kd event type */
typedef unsigned short kev_type; /* kd event type */
typedef unsigned char Scancode;
struct mouse_motion {
short mm_deltaX; /* units? */
short mm_deltaX; /* units? */
short mm_deltaY;
};
typedef struct {
kev_type type; /* see below */
struct timeval time; /* timestamp */
union { /* value associated with event */
boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
Scancode sc; /* KEYBD_EVENT */
struct mouse_motion mmotion; /* MOUSE_MOTION */
kev_type type; /* see below */
struct timeval time; /* timestamp */
union { /* value associated with event */
boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
Scancode sc; /* KEYBD_EVENT */
struct mouse_motion mmotion; /* MOUSE_MOTION */
} value;
} kd_event;
/*
* kd_event ID's.
*/
#define MOUSE_LEFT 1 /* mouse left button up/down */
#define MOUSE_MIDDLE 2
#define MOUSE_RIGHT 3
#define MOUSE_MOTION 4 /* mouse motion */
#define KEYBD_EVENT 5 /* key up/down */
#define MOUSE_LEFT 1 /* mouse left button up/down */
#define MOUSE_MIDDLE 2
#define MOUSE_RIGHT 3
#define MOUSE_MOTION 4 /* mouse motion */
#define KEYBD_EVENT 5 /* key up/down */
#define NUMEVENTS 64
#define NUMEVENTS 64
/*
* OsMouseReadInput --
......@@ -97,36 +97,36 @@ OsMouseReadInput(InputInfoPtr pInfo)
pBuf = (unsigned char *)eventList;
n = remainder;
while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0)
pBuf[n++] = (unsigned char)c;
pBuf[n++] = (unsigned char)c;
if (n == remainder)
return;
return;
remainder = n % sizeof(kd_event);
n /= sizeof(kd_event);
while( n-- ) {
int buttons = pMse->lastButtons;
int dx = 0, dy = 0;
switch (event->type) {
case MOUSE_RIGHT:
buttons = (buttons & 6) |(event->value.up ? 0 : 1);
break;
case MOUSE_MIDDLE:
buttons = (buttons & 5) |(event->value.up ? 0 : 2);
break;
case MOUSE_LEFT:
buttons = (buttons & 3) |(event->value.up ? 0 : 4) ;
break;
case MOUSE_MOTION:
dx = event->value.mmotion.mm_deltaX;
dy = - event->value.mmotion.mm_deltaY;
break;
default:
ErrorF("Bad mouse event (%d)\n",event->type);
continue;
}
pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
++event;
int buttons = pMse->lastButtons;
int dx = 0, dy = 0;
switch (event->type) {
case MOUSE_RIGHT:
buttons = (buttons & 6) |(event->value.up ? 0 : 1);
break;
case MOUSE_MIDDLE:
buttons = (buttons & 5) |(event->value.up ? 0 : 2);
break;
case MOUSE_LEFT:
buttons = (buttons & 3) |(event->value.up ? 0 : 4) ;
break;
case MOUSE_MOTION:
dx = event->value.mmotion.mm_deltaX;
dy = - event->value.mmotion.mm_deltaY;
break;
default:
ErrorF("Bad mouse event (%d)\n",event->type);
continue;
}
pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
++event;
}
memcpy(eventList, event, remainder);
return;
......@@ -158,13 +158,13 @@ OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
/* Check if the device can be opened. */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
if (xf86GetAllowMouseOpenFail())
xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
else {
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
free(pMse);
return FALSE;
}
if (xf86GetAllowMouseOpenFail())
xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
else {
xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
free(pMse);
return FALSE;
}
}
xf86CloseSerial(pInfo->fd);
pInfo->fd = -1;
......@@ -190,13 +190,13 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
SYSCALL (fd = open(path, O_RDWR | O_NONBLOCK | O_EXCL));
if (fd == -1)
return NULL;
return NULL;
close(fd);
pInfo->options =
xf86AddNewOption(pInfo->options, "Device", path);
xf86AddNewOption(pInfo->options, "Device", path);
xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", pInfo->name,
path);
path);
return path;
}
......@@ -209,8 +209,8 @@ SupportedInterfaces(void)
}
static const char *internalNames[] = {
"OSMouse",
NULL
"OSMouse",
NULL
};
static const char **
......@@ -225,8 +225,8 @@ CheckProtocol(const char *protocol)
int i;
for (i = 0; internalNames[i]; i++)
if (xf86NameCmp(protocol, internalNames[i]) == 0)
return TRUE;
if (xf86NameCmp(protocol, internalNames[i]) == 0)
return TRUE;
return FALSE;
}
......@@ -243,7 +243,7 @@ OSMouseInit(int flags)
p = calloc(sizeof(OSMouseInfoRec), 1);
if (!p)
return NULL;
return NULL;
p->SupportedInterfaces = SupportedInterfaces;
p->BuiltinNames = BuiltinNames;
p->FindDevice = FindDevice;
......
......@@ -29,36 +29,36 @@ DefaultProtocol(void)
return "Auto";
}
#define DEFAULT_MOUSE_DEV "/dev/input/mice"
#define DEFAULT_PS2_DEV "/dev/psaux"
#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata"
#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata"
#define DEFAULT_MOUSE_DEV "/dev/input/mice"
#define DEFAULT_PS2_DEV "/dev/psaux"
#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata"
#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata"
static const char *mouseDevs[] = {
DEFAULT_MOUSE_DEV,
DEFAULT_PS2_DEV,
DEFAULT_GPM_DATA_DEV,
NULL
DEFAULT_MOUSE_DEV,
DEFAULT_PS2_DEV,
DEFAULT_GPM_DATA_DEV,
NULL
};
typedef enum {
MOUSE_PROTO_UNKNOWN = 0,
MOUSE_PROTO_SERIAL,
MOUSE_PROTO_PS2,
MOUSE_PROTO_MSC,
MOUSE_PROTO_GPM,
MOUSE_PROTO_EXPPS2,
MOUSE_PROTO_UNKNOWN = 0,
MOUSE_PROTO_SERIAL,
MOUSE_PROTO_PS2,
MOUSE_PROTO_MSC,
MOUSE_PROTO_GPM,
MOUSE_PROTO_EXPPS2,
} protocolTypes;
static struct {
protocolTypes proto;
const char *name;
protocolTypes proto;
const char *name;
} devproto[] = {
{ MOUSE_PROTO_UNKNOWN, NULL },
{ MOUSE_PROTO_PS2, "PS/2" },
{ MOUSE_PROTO_MSC, "MouseSystems" },
{ MOUSE_PROTO_GPM, "GPM" },
{ MOUSE_PROTO_EXPPS2, "ExplorerPS/2" },
{ MOUSE_PROTO_UNKNOWN, NULL },
{ MOUSE_PROTO_PS2, "PS/2" },
{ MOUSE_PROTO_MSC, "MouseSystems" },
{ MOUSE_PROTO_GPM, "GPM" },
{ MOUSE_PROTO_EXPPS2, "ExplorerPS/2" },
};
static const char *
......@@ -68,22 +68,22 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
const char **pdev;
for (pdev = mouseDevs; *pdev; pdev++) {
SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL));
if (fd == -1) {
SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL));
if (fd == -1) {
#ifdef DEBUG
ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
#endif
} else
break;
} else
break;
}
if (*pdev) {
close(fd);
/* Set the Device option. */
pInfo->options =
xf86AddNewOption(pInfo->options, "Device", *pdev);
xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
pInfo->name, *pdev);
close(fd);
/* Set the Device option. */
pInfo->options =
xf86AddNewOption(pInfo->options, "Device", *pdev);
xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
pInfo->name, *pdev);
}
return *pdev;
......@@ -102,92 +102,92 @@ lnxMouseMagic(InputInfoPtr pInfo)
dev = xf86SetStrOption(pInfo->options, "Device", NULL);
if (!dev) {
#ifdef DEBUG
ErrorF("xf86SetStrOption failed to return the device name\n");
ErrorF("xf86SetStrOption failed to return the device name\n");
#endif
return NULL;
return NULL;
}
/* Look at the device name to guess the protocol. */
realdev = NULL;
if (strcmp(dev, DEFAULT_MOUSE_DEV) == 0) {
if (lstat(dev, &sbuf) != 0) {
if (lstat(dev, &sbuf) != 0) {
#ifdef DEBUG
ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno));
ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno));
#endif
return NULL;
}
if (S_ISLNK(sbuf.st_mode)) {
realdev = xnfalloc(PATH_MAX + 1);
i = readlink(dev, realdev, PATH_MAX);
if (i <= 0) {
return NULL;
}
if (S_ISLNK(sbuf.st_mode)) {
realdev = xnfalloc(PATH_MAX + 1);
i = readlink(dev, realdev, PATH_MAX);
if (i <= 0) {
#ifdef DEBUG
ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno));
ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno));
#endif
free(realdev);
return NULL;
}
realdev[i] = '\0';
}
free(realdev);
return NULL;
}
realdev[i] = '\0';
}
}
if (!realdev)
realdev = xnfstrdup(dev);
realdev = xnfstrdup(dev);
else {
/* If realdev doesn't contain a '/' then prepend "/dev/" */
if (!strchr(realdev, '/')) {
char *tmp = xnfalloc(strlen(realdev) + 5 + 1);
sprintf(tmp, "/dev/%s", realdev);
free(realdev);
realdev = tmp;
}
/* If realdev doesn't contain a '/' then prepend "/dev/" */
if (!strchr(realdev, '/')) {
char *tmp = xnfalloc(strlen(realdev) + 5 + 1);
sprintf(tmp, "/dev/%s", realdev);
free(realdev);
realdev = tmp;
}
}
if (strcmp(realdev, DEFAULT_MOUSE_DEV) == 0)
proto = MOUSE_PROTO_EXPPS2;
proto = MOUSE_PROTO_EXPPS2;
else if (strcmp(realdev, DEFAULT_PS2_DEV) == 0)
proto = MOUSE_PROTO_EXPPS2;
proto = MOUSE_PROTO_EXPPS2;
else if (strcmp(realdev, DEFAULT_GPM_DATA_DEV) == 0)
proto = MOUSE_PROTO_MSC;
proto = MOUSE_PROTO_MSC;
else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0)
proto = MOUSE_PROTO_GPM;
proto = MOUSE_PROTO_GPM;
free(realdev);
/*
* If the protocol can't be guessed from the device name,
* try to characterise it.
*/
if (proto == MOUSE_PROTO_UNKNOWN) {
SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL));
if (isatty(fd)) {
/* Serial PnP has already failed, so give up. */
} else {
if (fstat(fd, &sbuf) != 0) {
SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL));
if (isatty(fd)) {
/* Serial PnP has already failed, so give up. */
} else {
if (fstat(fd, &sbuf) != 0) {
#ifdef DEBUG
ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno));
ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno));
#endif
close(fd);
return NULL;
}
if (S_ISFIFO(sbuf.st_mode)) {
/* Assume GPM data in MSC format. */
proto = MOUSE_PROTO_MSC;
} else {
/* Default to PS/2 */
proto = MOUSE_PROTO_PS2;
}
}
close(fd);
close(fd);
return NULL;
}
if (S_ISFIFO(sbuf.st_mode)) {
/* Assume GPM data in MSC format. */
proto = MOUSE_PROTO_MSC;
} else {
/* Default to PS/2 */
proto = MOUSE_PROTO_PS2;
}
}
close(fd);
}
if (proto == MOUSE_PROTO_UNKNOWN) {
xf86Msg(X_ERROR, "%s: Cannot find mouse protocol.\n",
pInfo->name);
return NULL;
xf86Msg(X_ERROR, "%s: Cannot find mouse protocol.\n",
pInfo->name);
return NULL;
} else {
for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) {
if (devproto[i].proto == proto) {
xf86Msg(X_INFO,
"%s: Setting mouse protocol to \"%s\"\n",
pInfo->name, devproto[i].name);
return devproto[i].name;
}
}
for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) {
if (devproto[i].proto == proto) {
xf86Msg(X_INFO,
"%s: Setting mouse protocol to \"%s\"\n",
pInfo->name, devproto[i].name);
return devproto[i].name;
}
}
}
return NULL;
}
......@@ -211,7 +211,7 @@ OSMouseInit(int flags)
p = calloc(sizeof(OSMouseInfoRec), 1);
if (!p)
return NULL;
return NULL;
p->SupportedInterfaces = SupportedInterfaces;
p->DefaultProtocol = DefaultProtocol;
p->FindDevice = FindDevice;
......
This diff is collapsed.
......@@ -40,20 +40,20 @@
/* Mouse interface classes */
#define MSE_NONE 0x00
#define MSE_SERIAL 0x01 /* serial port */
#define MSE_BUS 0x02 /* old bus mouse */
#define MSE_PS2 0x04 /* standard read-only PS/2 */
#define MSE_XPS2 0x08 /* extended PS/2 */
#define MSE_AUTO 0x10 /* auto-detect (PnP) */
#define MSE_MISC 0x20 /* The OS layer will identify the
* specific protocol names that are
* supported for this class. */
#define MSE_NONE 0x00
#define MSE_SERIAL 0x01 /* serial port */
#define MSE_BUS 0x02 /* old bus mouse */
#define MSE_PS2 0x04 /* standard read-only PS/2 */
#define MSE_XPS2 0x08 /* extended PS/2 */
#define MSE_AUTO 0x10 /* auto-detect (PnP) */
#define MSE_MISC 0x20 /* The OS layer will identify the
* specific protocol names that are
* supported for this class. */
/* Mouse Protocol IDs. */
typedef enum {
PROT_UNKNOWN = -2,
PROT_UNSUP = -1, /* protocol is not supported */
PROT_UNSUP = -1, /* protocol is not supported */
PROT_MS = 0,
PROT_MSC,
PROT_MM,
......@@ -79,7 +79,7 @@ typedef enum {
PROT_SYSMOUSE,
PROT_WSMOUSE,
PROT_VUID,
PROT_NUMPROTOS /* This must always be last. */
PROT_NUMPROTOS /* This must always be last. */
} MouseProtocolID;
struct _MouseDevRec;
......@@ -88,13 +88,13 @@ typedef int (*GetInterfaceTypesProc)(void);
typedef const char **(*BuiltinNamesProc)(void);
typedef Bool (*CheckProtocolProc)(const char *protocol);
typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol,
int flags);
int flags);
typedef const char *(*DefaultProtocolProc)(void);
typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara);
typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate,
int res);
int res);
typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol,
int flags);
int flags);
typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
/*
......@@ -102,86 +102,86 @@ typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
* OS-independent mouse driver.
*/
typedef struct {
GetInterfaceTypesProc SupportedInterfaces;
BuiltinNamesProc BuiltinNames;
CheckProtocolProc CheckProtocol;
BuiltinPreInitProc PreInit;
DefaultProtocolProc DefaultProtocol;
SetupAutoProc SetupAuto;
SetResProc SetPS2Res;
SetResProc SetBMRes;
SetResProc SetMiscRes;
FindDeviceProc FindDevice;
GuessProtocolProc GuessProtocol;
GetInterfaceTypesProc SupportedInterfaces;
BuiltinNamesProc BuiltinNames;
CheckProtocolProc CheckProtocol;
BuiltinPreInitProc PreInit;
DefaultProtocolProc DefaultProtocol;
SetupAutoProc SetupAuto;
SetResProc SetPS2Res;
SetResProc SetBMRes;
SetResProc SetMiscRes;
FindDeviceProc FindDevice;
GuessProtocolProc GuessProtocol;
} OSMouseInfoRec, *OSMouseInfoPtr;
/*
* SupportedInterfaces: Returns the mouse interface types that the OS support.
* If MSE_MISC is returned, then the BuiltinNames and
* CheckProtocol should be set.
* If MSE_MISC is returned, then the BuiltinNames and
* CheckProtocol should be set.
*
* BuiltinNames: Returns the names of the protocols that are fully handled
* in the OS-specific code. These are names that don't appear
* directly in the main "mouse" driver.
* in the OS-specific code. These are names that don't appear
* directly in the main "mouse" driver.
*
* CheckProtocol: Checks if the protocol name given is supported by the
* OS. It should return TRUE for both "builtin" protocols and
* protocols of type MSE_MISC that are supported by the OS.
* OS. It should return TRUE for both "builtin" protocols and
* protocols of type MSE_MISC that are supported by the OS.
*
* PreInit: The PreInit function for protocols that are builtin. This
* function is passed the protocol name.
* PreInit: The PreInit function for protocols that are builtin. This
* function is passed the protocol name.
*
* DefaultProtocol: Returns the name of a default protocol that should be used
* for the OS when none has been supplied in the config file.
* This should only be set when there is a reasonable default.
* for the OS when none has been supplied in the config file.
* This should only be set when there is a reasonable default.
*
* SetupAuto: This function can be used to do OS-specific protocol
* auto-detection. It returns the name of the detected protocol,
* or NULL when detection fails. It may also adjust one or more
* of the "protoPara" values for the detected protocol by setting
* then to something other than -1. SetupAuto gets called in two
* ways. The first is before any devices have been opened. This
* can be used when the protocol "Auto" always maps to a single
* protocol type. The second is with the device open, allowing
* OS-specific probing to be done.
* SetupAuto: This function can be used to do OS-specific protocol
* auto-detection. It returns the name of the detected protocol,
* or NULL when detection fails. It may also adjust one or more
* of the "protoPara" values for the detected protocol by setting
* then to something other than -1. SetupAuto gets called in two
* ways. The first is before any devices have been opened. This
* can be used when the protocol "Auto" always maps to a single
* protocol type. The second is with the device open, allowing
* OS-specific probing to be done.
*
* SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
* protocol types.
* SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
* protocol types.
*
* SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
* SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
*
* SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
* SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
*
* FindDevice: This function gets called when no Device has been specified
* in the config file. OS-specific methods may be used to guess
* which input device to use. This function is called after the
* pre-open attempts at protocol discovery are done, but before
* the device is open. I.e., after the first SetupAuto() call,
* after the DefaultProtocol() call, but before the PreInit()
* call. Available protocol information may be used in locating
* the default input device.
* FindDevice: This function gets called when no Device has been specified
* in the config file. OS-specific methods may be used to guess
* which input device to use. This function is called after the
* pre-open attempts at protocol discovery are done, but before
* the device is open. I.e., after the first SetupAuto() call,
* after the DefaultProtocol() call, but before the PreInit()
* call. Available protocol information may be used in locating
* the default input device.
*
* GuessProtocol: A last resort attempt at guessing the mouse protocol by
* whatever OS-specific means might be available. OS-independent
* things should be in the mouse driver. This function gets
* called after the mouse driver's OS-independent methods have
* failed.
* whatever OS-specific means might be available. OS-independent
* things should be in the mouse driver. This function gets
* called after the mouse driver's OS-independent methods have
* failed.
*/
extern OSMouseInfoPtr OSMouseInit(int flags);
/* Z axis mapping */
#define MSE_NOZMAP 0
#define MSE_MAPTOX -1
#define MSE_MAPTOY -2
#define MSE_MAPTOZ -3
#define MSE_MAPTOW -4
#define MSE_NOZMAP 0
#define MSE_MAPTOX -1
#define MSE_MAPTOY -2
#define MSE_MAPTOZ -3
#define MSE_MAPTOW -4
/* Generalize for other axes. */
#define MSE_NOAXISMAP MSE_NOZMAP
#define MSE_NOAXISMAP MSE_NOZMAP
#define MSE_MAXBUTTONS 24
#define MSE_DFLTBUTTONS 3
#define MSE_MAXBUTTONS 24
#define MSE_DFLTBUTTONS 3
/*
* Mouse device record. This is shared by the mouse driver and the OSMouse
......@@ -194,71 +194,71 @@ typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char);
typedef Bool (*dataGoodProc)(struct _MouseDevRec *);
typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
int dx, int dy, int dz, int dw);
int dx, int dy, int dz, int dw);
typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
typedef struct _MouseDevRec {
PtrCtrlProcPtr Ctrl;
PostMseEventProc PostEvent;
MouseCommonOptProc CommonOptions;
DeviceIntPtr device;
const char * protocol;
MouseProtocolID protocolID;
MouseProtocolID oldProtocolID; /* hack */