diff options
author | marha <marha@users.sourceforge.net> | 2010-01-08 13:17:02 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-01-08 13:17:02 +0000 |
commit | 91a30d5622174febaa2107b010effcf2fb5b9a2e (patch) | |
tree | bef04beb0812925c8d343813b26be65073a53c3f /xorg-server/hw/kdrive/linux | |
parent | 20f59c125afe31a8bdb0ae6a74dd408e5fa00237 (diff) | |
download | vcxsrv-91a30d5622174febaa2107b010effcf2fb5b9a2e.tar.gz vcxsrv-91a30d5622174febaa2107b010effcf2fb5b9a2e.tar.bz2 vcxsrv-91a30d5622174febaa2107b010effcf2fb5b9a2e.zip |
Git update 8 jan 2010
Diffstat (limited to 'xorg-server/hw/kdrive/linux')
-rw-r--r-- | xorg-server/hw/kdrive/linux/Makefile.am | 31 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/linux/bus.c | 132 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/linux/evdev.c | 24 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/linux/linux.c | 44 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/linux/mouse.c | 48 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/linux/ms.c | 6 | ||||
-rw-r--r-- | xorg-server/hw/kdrive/linux/ps2.c | 4 |
7 files changed, 91 insertions, 198 deletions
diff --git a/xorg-server/hw/kdrive/linux/Makefile.am b/xorg-server/hw/kdrive/linux/Makefile.am index 13df142f7..fe4a3d183 100644 --- a/xorg-server/hw/kdrive/linux/Makefile.am +++ b/xorg-server/hw/kdrive/linux/Makefile.am @@ -6,19 +6,22 @@ AM_CFLAGS = -DHAVE_DIX_CONFIG_H noinst_LTLIBRARIES = liblinux.la -if TSLIB -TSLIB_C = tslib.c +liblinux_la_SOURCES = + +liblinux_la_SOURCES += linux.c klinux.h + +if KDRIVE_KBD +liblinux_la_SOURCES += keyboard.c +endif + +if KDRIVE_EVDEV +liblinux_la_SOURCES += evdev.c endif -KDRIVE_HW_SOURCES = \ - evdev.c \ - keyboard.c \ - linux.c - -liblinux_la_SOURCES = \ - bus.c \ - mouse.c \ - ms.c \ - ps2.c \ - $(KDRIVE_HW_SOURCES) \ - $(TSLIB_C) +if KDRIVE_MOUSE +liblinux_la_SOURCES += mouse.c ms.c ps2.c +endif + +if TSLIB +liblinux_la_SOURCES += tslib.c +endif diff --git a/xorg-server/hw/kdrive/linux/bus.c b/xorg-server/hw/kdrive/linux/bus.c deleted file mode 100644 index de9b90f5a..000000000 --- a/xorg-server/hw/kdrive/linux/bus.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright © 2000 Keith Packard - * - * 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 name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD 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. - */ - -#ifdef HAVE_CONFIG_H -#include <kdrive-config.h> -#endif -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xpoll.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "kdrive.h" - -/* /dev/adbmouse is a busmouse */ - -static void -BusRead (int adbPort, void *closure) -{ - unsigned char buf[3]; - int n; - int dx, dy; - unsigned long flags; - - n = read (adbPort, buf, 3); - if (n == 3) - { - flags = KD_MOUSE_DELTA; - dx = (char) buf[1]; - dy = -(char) buf[2]; - if ((buf[0] & 4) == 0) - flags |= KD_BUTTON_1; - if ((buf[0] & 2) == 0) - flags |= KD_BUTTON_2; - if ((buf[0] & 1) == 0) - flags |= KD_BUTTON_3; - KdEnqueuePointerEvent (closure, flags, dx, dy, 0); - } -} - -char *BusNames[] = { - "/dev/adbmouse", - "/dev/mouse", -}; - -#define NUM_BUS_NAMES (sizeof (BusNames) / sizeof (BusNames[0])) - -static int -BusInit (KdPointerInfo *pi) -{ - int i, fd = 0; - - if (!pi->path || (strcmp(pi->path, "auto") == 0)) - { - for (i = 0; i < NUM_BUS_NAMES; i++) - { - if ((fd = open (BusNames[i], 0)) >= 0) - { - close(fd); - xfree(pi->path); - pi->path = strdup(BusNames[i]); - return Success; - } - } - } - else - { - if ((fd = open(pi->path, 0)) >= 0) - { - close(fd); - return Success; - } - } - - return !Success; -} - -static int -BusEnable (KdPointerInfo *pi) -{ - int fd = open(pi->path, 0); - - if (fd >= 0) - { - KdRegisterFd(fd, BusRead, pi); - pi->driverPrivate = (void *)fd; - return Success; - } - else - { - return !Success; - } -} - -static void -BusDisable (KdPointerInfo *pi) -{ - KdUnregisterFd(pi, (int)pi->driverPrivate, TRUE); -} - -static void -BusFini (KdPointerInfo *pi) -{ - return; -} - -KdPointerDriver BusMouseDriver = { - "bus", - BusInit, - BusEnable, - BusDisable, - BusFini, - NULL -}; diff --git a/xorg-server/hw/kdrive/linux/evdev.c b/xorg-server/hw/kdrive/linux/evdev.c index 096a2ddc3..485a2b557 100644 --- a/xorg-server/hw/kdrive/linux/evdev.c +++ b/xorg-server/hw/kdrive/linux/evdev.c @@ -48,7 +48,7 @@ typedef struct _kevdev { int abs[ABS_MAX + 1]; int prevabs[ABS_MAX + 1]; long key[NBITS(KEY_MAX + 1)]; - + /* supported device info */ long relbits[NBITS(REL_MAX + 1)]; long absbits[NBITS(ABS_MAX + 1)]; @@ -106,12 +106,12 @@ EvdevPtrMotion (KdPointerInfo *pi, struct input_event *ev) int a; for (a = 0; a <= ke->max_rel; a++) { - if (ISBITSET (ke->relbits, a)) + if (ISBITSET (ke->relbits, a)) { if (a == 0) KdEnqueuePointerEvent(pi, flags, ke->rel[a], 0, 0); else if (a == 1) - KdEnqueuePointerEvent(pi, flags, 0, ke->rel[a], 0); + KdEnqueuePointerEvent(pi, flags, 0, ke->rel[a], 0); } ke->rel[a] = 0; } @@ -131,9 +131,9 @@ EvdevPtrMotion (KdPointerInfo *pi, struct input_event *ev) ErrorF ("\n"); break; } - - if (ev->code == REL_WHEEL) { - for (i = 0; i < abs (ev->value); i++) + + if (ev->code == REL_WHEEL) { + for (i = 0; i < abs (ev->value); i++) { if (ev->value > 0) flags |= KD_BUTTON_4; @@ -150,7 +150,7 @@ EvdevPtrMotion (KdPointerInfo *pi, struct input_event *ev) KdEnqueuePointerEvent (pi, flags, 0, 0, 0); } } - + } static void @@ -164,7 +164,7 @@ EvdevPtrRead (int evdevPort, void *closure) n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event)); if (n <= 0) { - if (errno == ENODEV) + if (errno == ENODEV) DeleteInputDeviceRequest(pi->dixdev); return; } @@ -231,7 +231,7 @@ EvdevPtrInit (KdPointerInfo *pi) static Status EvdevPtrEnable (KdPointerInfo *pi) -{ +{ int fd; unsigned long ev[NBITS(EV_MAX)]; Kevdev *ke; @@ -352,7 +352,7 @@ EvdevPtrFini (KdPointerInfo *pi) /* - * Evdev keyboard functions + * Evdev keyboard functions */ static void @@ -374,7 +374,7 @@ EvdevKbdRead (int evdevPort, void *closure) n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event)); if (n <= 0) { - if (errno == ENODEV) + if (errno == ENODEV) DeleteInputDeviceRequest(ki->dixdev); return; } @@ -395,7 +395,7 @@ static Status EvdevKbdInit (KdKeyboardInfo *ki) { int fd; - + if (!ki->path) { ErrorF("Couldn't find evdev device path\n"); return BadValue; diff --git a/xorg-server/hw/kdrive/linux/linux.c b/xorg-server/hw/kdrive/linux/linux.c index f76c2cbd9..9863c1424 100644 --- a/xorg-server/hw/kdrive/linux/linux.c +++ b/xorg-server/hw/kdrive/linux/linux.c @@ -33,6 +33,22 @@ #include <X11/keysym.h> #include <linux/apm_bios.h> +#ifdef KDRIVE_MOUSE +extern KdPointerDriver LinuxMouseDriver; +extern KdPointerDriver Ps2MouseDriver; +extern KdPointerDriver MsMouseDriver; +#endif +#ifdef TSLIB +extern KdPointerDriver TsDriver; +#endif +#ifdef KDRIVE_EVDEV +extern KdPointerDriver LinuxEvdevMouseDriver; +extern KdKeyboardDriver LinuxEvdevKeyboardDriver; +#endif +#ifdef KDRIVE_KBD +extern KdKeyboardDriver LinuxKeyboardDriver; +#endif + static int vtno; int LinuxConsoleFd; int LinuxApmFd = -1; @@ -79,7 +95,7 @@ LinuxInit (void) vtno = kdVirtualTerminal; else { - if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) + if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) { FatalError( "LinuxInit: Cannot open /dev/tty0 (%s)\n", @@ -129,8 +145,8 @@ LinuxSetSwitchMode (int mode) { struct sigaction act; struct vt_mode VT; - - if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) + + if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0) { FatalError ("LinuxInit: VT_GETMODE failed\n"); } @@ -141,7 +157,7 @@ LinuxSetSwitchMode (int mode) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGUSR1, &act, 0); - + VT.mode = mode; VT.relsig = SIGUSR1; VT.acqsig = SIGUSR1; @@ -152,12 +168,12 @@ LinuxSetSwitchMode (int mode) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGUSR1, &act, 0); - + VT.mode = mode; VT.relsig = 0; VT.acqsig = 0; } - if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) + if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0) { FatalError("LinuxInit: VT_SETMODE failed\n"); } @@ -237,7 +253,7 @@ LinuxEnable (void) */ LinuxApmFd = open ("/dev/apm_bios", 2); if (LinuxApmFd < 0 && errno == ENOENT) - LinuxApmFd = open ("/dev/misc/apm_bios", 2); + LinuxApmFd = open ("/dev/misc/apm_bios", 2); if (LinuxApmFd >= 0) { LinuxApmRunning = TRUE; @@ -245,7 +261,7 @@ LinuxEnable (void) RegisterBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0); AddEnabledDevice (LinuxApmFd); } - + /* * now get the VT */ @@ -308,8 +324,8 @@ LinuxFini (void) * Find a legal VT to switch to, either the one we started from * or the lowest active one that isn't ours */ - if (activeVT < 0 || - activeVT == vts.v_active || + if (activeVT < 0 || + activeVT == vts.v_active || !(vts.v_state & (1 << activeVT))) { for (activeVT = 1; activeVT < 16; activeVT++) @@ -345,15 +361,21 @@ LinuxFini (void) void KdOsAddInputDrivers (void) { +#ifdef KDRIVE_MOUSE KdAddPointerDriver(&LinuxMouseDriver); KdAddPointerDriver(&MsMouseDriver); KdAddPointerDriver(&Ps2MouseDriver); +#endif #ifdef TSLIB KdAddPointerDriver(&TsDriver); #endif +#ifdef KDRIVE_EVDEV KdAddPointerDriver(&LinuxEvdevMouseDriver); - KdAddKeyboardDriver(&LinuxKeyboardDriver); KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver); +#endif +#ifdef KDRIVE_KBD + KdAddKeyboardDriver(&LinuxKeyboardDriver); +#endif } static void diff --git a/xorg-server/hw/kdrive/linux/mouse.c b/xorg-server/hw/kdrive/linux/mouse.c index 6f399b586..007263e4b 100644 --- a/xorg-server/hw/kdrive/linux/mouse.c +++ b/xorg-server/hw/kdrive/linux/mouse.c @@ -112,7 +112,7 @@ MouseFlush (Kbufio *b, char *buf, int size) CARD32 done = now + 100; int c; int n = 0; - + while ((c = MouseReadByte (b, done - now)) != -1) { if (buf) @@ -170,7 +170,7 @@ static Bool MouseWriteByte (int fd, unsigned char c, int timeout) { int ret; - + #ifdef DEBUG_BYTES ErrorF ("\tput %02x\n", c); #endif @@ -234,7 +234,7 @@ typedef struct _kmouse { int invalid;/* total invalid bytes for this protocol */ unsigned long state; /* private per protocol, init to prot->state */ } Kmouse; - + static int mouseValid (KdPointerInfo *pi, unsigned char *ev, int ne) { Kmouse *km = pi->driverPrivate; @@ -271,16 +271,16 @@ static Bool MouseReasonable (KdPointerInfo *pi, unsigned long flags, int dx, int { Kmouse *km = pi->driverPrivate; - if (km->stage == MouseWorking) + if (km->stage == MouseWorking) return TRUE; - if (dx < -50 || dx > 50) + if (dx < -50 || dx > 50) { #ifdef DEBUG ErrorF ("Large X %d\n", dx); #endif return FALSE; } - if (dy < -50 || dy > 50) + if (dy < -50 || dy > 50) { #ifdef DEBUG ErrorF ("Large Y %d\n", dy); @@ -299,7 +299,7 @@ static Bool ps2Parse (KdPointerInfo *pi, unsigned char *ev, int ne) int dx, dy, dz; unsigned long flags; unsigned long flagsrelease = 0; - + flags = KD_MOUSE_DELTA; if (ev[0] & 4) flags |= KD_BUTTON_2; @@ -307,7 +307,7 @@ static Bool ps2Parse (KdPointerInfo *pi, unsigned char *ev, int ne) flags |= KD_BUTTON_3; if (ev[0] & 1) flags |= KD_BUTTON_1; - + if (ne > 3) { dz = (int) (signed char) ev[3]; @@ -322,7 +322,7 @@ static Bool ps2Parse (KdPointerInfo *pi, unsigned char *ev, int ne) flagsrelease = KD_BUTTON_5; } } - + dx = ev[1]; if (ev[0] & 0x10) dx -= 256; @@ -407,14 +407,14 @@ static const KmouseProt exps2Prot = { #define PSM_4DMOUSE_ID 6 #define PSM_4DPLUS_ID 8 -static unsigned char ps2_init[] = { +static unsigned char ps2_init[] = { PSMC_ENABLE_DEV, 0, }; #define NINIT_PS2 1 -static unsigned char wheel_3button_init[] = { +static unsigned char wheel_3button_init[] = { PSMC_SET_SAMPLING_RATE, 200, PSMC_SET_SAMPLING_RATE, 100, PSMC_SET_SAMPLING_RATE, 80, @@ -431,7 +431,7 @@ static unsigned char wheel_5button_init[] = { PSMC_SET_SAMPLING_RATE, 200, PSMC_SET_SAMPLING_RATE, 200, PSMC_SET_SAMPLING_RATE, 80, - PSMC_SEND_DEV_ID, + PSMC_SEND_DEV_ID, 0 }; @@ -439,8 +439,8 @@ static unsigned char wheel_5button_init[] = { static unsigned char intelli_init[] = { PSMC_SET_SAMPLING_RATE, 200, - PSMC_SET_SAMPLING_RATE, 100, - PSMC_SET_SAMPLING_RATE, 80, + PSMC_SET_SAMPLING_RATE, 100, + PSMC_SET_SAMPLING_RATE, 80, 0 }; @@ -453,7 +453,7 @@ ps2SkipInit (KdPointerInfo *pi, int ninit, Bool ret_next) int c = -1; int skipping; Bool waiting; - + skipping = 0; waiting = FALSE; while (ninit || ret_next) @@ -486,7 +486,7 @@ ps2Init (KdPointerInfo *pi) int id; unsigned char *init; int ninit; - + /* Send Intellimouse initialization sequence */ MouseWriteBytes (km->iob.fd, intelli_init, strlen ((char *) intelli_init), 100); /* @@ -530,7 +530,7 @@ static Bool busParse (KdPointerInfo *pi, unsigned char *ev, int ne) Kmouse *km = pi->driverPrivate; int dx, dy; unsigned long flags; - + flags = KD_MOUSE_DELTA; dx = (signed char) ev[1]; dy = -(signed char) ev[2]; @@ -636,14 +636,14 @@ static Bool logiParse (KdPointerInfo *pi, unsigned char *ev, int ne) unsigned long flags; flags = KD_MOUSE_DELTA; - + if (ne == 3) { if (ev[0] & 0x20) flags |= KD_BUTTON_1; if (ev[0] & 0x10) flags |= KD_BUTTON_3; - + dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F)); dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F)); flags |= km->state & KD_BUTTON_2; @@ -686,7 +686,7 @@ static Bool mscParse (KdPointerInfo *pi, unsigned char *ev, int ne) unsigned long flags; flags = KD_MOUSE_DELTA; - + if (!(ev[0] & 0x4)) flags |= KD_BUTTON_1; if (!(ev[0] & 0x2)) @@ -871,7 +871,7 @@ MouseRead (int mousePort, void *closure) switch (km->stage) { case MouseBroken: -#ifdef DEBUG +#ifdef DEBUG ErrorF ("Mouse protocol %s seems OK\n", km->prot->name); #endif @@ -939,7 +939,7 @@ MouseInit (KdPointerInfo *pi) if (!pi) return BadImplementation; - + if (!pi->path || strcmp(pi->path, "auto") == 0) { for (i = 0; i < NUM_DEFAULT_MOUSE; i++) { fd = open (kdefaultMouse[i], 2); @@ -952,7 +952,7 @@ MouseInit (KdPointerInfo *pi) else { fd = open (pi->path, 2); } - + if (fd < 0) return BadMatch; @@ -1008,7 +1008,7 @@ MouseDisable (KdPointerInfo *pi) Kmouse *km; if (!pi || !pi->driverPrivate) return; - + km = pi->driverPrivate; KdUnregisterFd (pi, km->iob.fd, TRUE); } diff --git a/xorg-server/hw/kdrive/linux/ms.c b/xorg-server/hw/kdrive/linux/ms.c index 5786ed170..b6151cd90 100644 --- a/xorg-server/hw/kdrive/linux/ms.c +++ b/xorg-server/hw/kdrive/linux/ms.c @@ -83,7 +83,7 @@ MsRead (int port, void *closure) flags |= KD_BUTTON_1; if (b[0] & 0x10) flags |= KD_BUTTON_3; - + dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3F)); dy = (char)(((b[0] & 0x0C) << 4) | (b[2] & 0x3F)); n -= 3; @@ -103,8 +103,8 @@ MsInit (KdPointerInfo *pi) pi->path = strdup("/dev/mouse"); if (!pi->name) pi->name = strdup("Microsoft protocol mouse"); - - return Success; + + return Success; } static Status diff --git a/xorg-server/hw/kdrive/linux/ps2.c b/xorg-server/hw/kdrive/linux/ps2.c index 396758481..552a3c7cb 100644 --- a/xorg-server/hw/kdrive/linux/ps2.c +++ b/xorg-server/hw/kdrive/linux/ps2.c @@ -99,7 +99,7 @@ Ps2Read (int ps2Port, void *closure) flags |= right_button; if (b[0] & 1) flags |= left_button; - + dx = b[1]; if (b[0] & 0x10) dx -= 256; @@ -146,7 +146,7 @@ static Status Ps2Enable (KdPointerInfo *pi) { int fd; - + if (!pi) return BadImplementation; |