summaryrefslogtreecommitdiff
path: root/hw/xfree86/common/xf86Io.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/common/xf86Io.c')
-rw-r--r--hw/xfree86/common/xf86Io.c304
1 files changed, 116 insertions, 188 deletions
diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c
index 6fddb5e89..06819bccf 100644
--- a/hw/xfree86/common/xf86Io.c
+++ b/hw/xfree86/common/xf86Io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.28.2.5 1998/02/24 19:05:55 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.53 2003/01/15 03:29:05 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -21,8 +21,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $Xorg: xf86Io.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */
-/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */
+/* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */
#define NEED_EVENTS
#include "X.h"
@@ -32,12 +31,16 @@
#include "compiler.h"
-#include "xf86Procs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
#include "xf86_OSlib.h"
-#include "xf86_Config.h"
+#include "mipointer.h"
#ifdef XINPUT
#include "xf86Xinput.h"
+#include "XIproto.h"
+#include "exevents.h"
#endif
#ifdef XKB
@@ -46,18 +49,12 @@
#include <X11/extensions/XKBsrv.h>
#endif
-extern KeybdCtrl defaultKeyboardControl;
-
unsigned int xf86InitialCaps = 0;
unsigned int xf86InitialNum = 0;
unsigned int xf86InitialScroll = 0;
#include "atKeynames.h"
-extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
- unsigned long start, unsigned long stop,
- ScreenPtr pScreen);
-
/*
* xf86KbdBell --
* Ring the terminal/keyboard bell for an amount of time proportional to
@@ -74,50 +71,58 @@ xf86KbdBell(percent, pKeyboard, ctrl, unused)
xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration);
}
-#ifdef AMOEBA
-#define LED_CAP IOP_LED_CAP
-#define LED_NUM IOP_LED_NUM
-#define LED_SCR IOP_LED_SCROLL
-#endif
-
-#ifdef MINIX
-#define LED_CAP KBD_LEDS_CAPS
-#define LED_NUM KBD_LEDS_NUM
-#define LED_SCR KBD_LEDS_SCROLL
-#endif
+void
+xf86UpdateKbdLeds()
+{
+ int leds = 0;
+ if (xf86Info.capsLock) leds |= XLED1;
+ if (xf86Info.numLock) leds |= XLED2;
+ if (xf86Info.scrollLock || xf86Info.modeSwitchLock) leds |= XLED3;
+ if (xf86Info.composeLock) leds |= XLED4;
+ xf86Info.leds = (xf86Info.leds & xf86Info.xleds) | (leds & ~xf86Info.xleds);
+ xf86KbdLeds();
+}
void
xf86KbdLeds ()
{
- int leds = 0;
-#ifdef XKB
- if (!noXkbExtension) {
- XkbEventCauseRec cause;
- XkbSetCauseUnknown(&cause);
- XkbUpdateIndicators((DeviceIntPtr)xf86Info.pKeyboard,
- XkbAllIndicatorsMask, False, NULL, &cause);
- return;
+ int leds, real_leds = 0;
+
+#if defined (__sparc__)
+ static int kbdSun = -1;
+ if (kbdSun == -1) {
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) ||
+ (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
+ kbdSun = 1;
+ else
+ kbdSun = 0;
}
-#endif
-#ifdef LED_CAP
- if (xf86Info.capsLock && !(xf86Info.xleds & XLED1))
- leds |= LED_CAP;
-
- if (xf86Info.numLock && !(xf86Info.xleds & XLED2))
- leds |= LED_NUM;
-
- if ((xf86Info.scrollLock ||
- xf86Info.modeSwitchLock ||
- xf86Info.composeLock) &&
- !(xf86Info.xleds & XLED3))
- leds |= LED_SCR;
-
- if ((xf86Info.leds & xf86Info.xleds) & XLED1) leds |= LED_CAP;
- if ((xf86Info.leds & xf86Info.xleds) & XLED2) leds |= LED_NUM;
- if ((xf86Info.leds & xf86Info.xleds) & XLED3) leds |= LED_SCR;
+ if (kbdSun) {
+ if (xf86Info.leds & 0x08) real_leds |= XLED1;
+ if (xf86Info.leds & 0x04) real_leds |= XLED3;
+ if (xf86Info.leds & 0x02) real_leds |= XLED4;
+ if (xf86Info.leds & 0x01) real_leds |= XLED2;
+ leds = real_leds;
+ real_leds = 0;
+ } else {
+ leds = xf86Info.leds;
+ }
+#else
+ leds = xf86Info.leds;
+#endif /* defined (__sparc__) */
- xf86SetKbdLeds(leds);
-#endif /* LED_CAP */
+#ifdef LED_CAP
+ if (leds & XLED1) real_leds |= LED_CAP;
+ if (leds & XLED2) real_leds |= LED_NUM;
+ if (leds & XLED3) real_leds |= LED_SCR;
+#ifdef LED_COMP
+ if (leds & XLED4) real_leds |= LED_COMP;
+#else
+ if (leds & XLED4) real_leds |= LED_SCR;
+#endif
+#endif
+ xf86SetKbdLeds(real_leds);
+ return;
}
/*
@@ -131,19 +136,30 @@ xf86KbdCtrl (pKeyboard, ctrl)
DevicePtr pKeyboard; /* Keyboard to alter */
KeybdCtrl *ctrl;
{
+ int leds;
xf86Info.bell_pitch = ctrl->bell_pitch;
xf86Info.bell_duration = ctrl->bell_duration;
xf86Info.autoRepeat = ctrl->autoRepeat;
- xf86Info.leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
xf86Info.composeLock = (ctrl->leds & XCOMP) ? TRUE : FALSE;
+ leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ xf86Info.leds = (leds & xf86Info.xleds)|(xf86Info.leds & ~xf86Info.xleds);
+#ifdef XKB
+ } else {
+ xf86Info.leds = leds;
+ }
+#endif
+
xf86KbdLeds();
}
/*
* xf86InitKBD --
- * Reinitialize the keyboard. Only set Lockkeys accrding to ours leds.
+ * Reinitialize the keyboard. Only set Lockkeys according to ours leds.
* Depress all other keys.
*/
@@ -158,7 +174,6 @@ Bool init;
KeyClassRec *keyc = xf86Info.pKeyboard->key;
KeySym *map = keyc->curKeySyms.map;
-#ifndef MACH386
kevent.u.keyButtonPointer.time = GetTimeInMillis();
kevent.u.keyButtonPointer.rootX = 0;
kevent.u.keyButtonPointer.rootY = 0;
@@ -192,7 +207,6 @@ Bool init;
(* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
}
}
-#endif /* MACH386 */
xf86Info.scanPrefix = 0;
@@ -314,7 +328,10 @@ xf86KbdProc (pKeyboard, what)
(KbdCtrlProcPtr)xf86KbdCtrl);
#ifdef XKB
} else {
- XkbComponentNamesRec names;
+ XkbComponentNamesRec names;
+ XkbDescPtr desc;
+ Bool foundTerminate = FALSE;
+ int keyc;
if (XkbInitialMap) {
if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL)
xf86Info.xkbkeymap++;
@@ -343,12 +360,30 @@ xf86KbdProc (pKeyboard, what)
XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
xf86Info.xkblayout, xf86Info.xkbvariant,
xf86Info.xkboptions);
+
XkbInitKeyboardDeviceStruct(pKeyboard,
&names,
&keySyms,
modMap,
xf86KbdBell,
(KbdCtrlProcPtr)xf86KbdCtrl);
+
+ /* Search keymap for Terminate action */
+ desc = pKeyboard->key->xkbInfo->desc;
+ for (keyc = desc->min_key_code; keyc <= desc->max_key_code; keyc++) {
+ int i;
+ for (i = 1; i <= XkbKeyNumActions(desc, keyc); i++) {
+ if (XkbKeyAction(desc, keyc, i)
+ && XkbKeyAction(desc, keyc, i)->type == XkbSA_Terminate) {
+ foundTerminate = TRUE;
+ goto searchdone;
+ }
+ }
+ }
+searchdone:
+ xf86Info.ActionKeyBindingsSet = foundTerminate;
+ if (!foundTerminate)
+ xf86Msg(X_INFO, "Server_Terminate keybinding not found\n");
}
#endif
@@ -367,15 +402,21 @@ xf86KbdProc (pKeyboard, what)
* passing on parts of the VT switch sequence.
*/
sleep(1);
- if (kbdFd != -1) {
- char buf[16];
- read(kbdFd, buf, 16);
+#if defined(WSCONS_SUPPORT)
+ if (xf86Info.consType != WSCONS) {
+#endif
+ if (kbdFd != -1) {
+ char buf[16];
+ read(kbdFd, buf, 16);
+ }
+#if defined(WSCONS_SUPPORT)
}
+#endif
-#ifndef __EMX__ /* Under EMX, keyboard cannot be select()'ed */
+#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */
if (kbdFd != -1)
AddEnabledDevice(kbdFd);
-#endif /* __EMX__ */
+#endif /* __UNIXOS2__ */
pKeyboard->public.on = TRUE;
xf86InitKBD(FALSE);
@@ -399,144 +440,31 @@ xf86KbdProc (pKeyboard, what)
return (Success);
}
-/*
- * xf86MseCtrl --
- * Alter the control parameters for the mouse. Note that all special
- * protocol values are handled by dix.
- */
-
-void
-xf86MseCtrl(pPointer, ctrl)
- DevicePtr pPointer;
- PtrCtrl *ctrl;
-{
- MouseDevPtr mouse = MOUSE_DEV((DeviceIntPtr) pPointer);
-
- mouse->num = ctrl->num;
- mouse->den = ctrl->den;
- mouse->threshold = ctrl->threshold;
-}
-
-/*
- * xf86MseProc --
- * Handle the initialization, etc. of a mouse
- */
-
-int
-xf86MseProc(pPointer, what)
- DeviceIntPtr pPointer;
- int what;
-{
- MouseDevPtr mouse = MOUSE_DEV(pPointer);
-
- mouse->device = pPointer;
-
- return xf86MseProcAux(pPointer, what, mouse, NULL,
- (PtrCtrlProcPtr)xf86MseCtrl);
-}
-
-int
-xf86MseProcAux(pPointer, what, mouse, fd, ctrl)
- DeviceIntPtr pPointer;
- int what;
- MouseDevPtr mouse;
- int *fd;
- PtrCtrlProcPtr ctrl;
-{
- unsigned char map[MSE_MAXBUTTONS + 1];
- int nbuttons;
- int mousefd;
-
- switch (what)
- {
- case DEVICE_INIT:
- pPointer->public.on = FALSE;
-
- /*
- * [KAZU-241097] We don't know exactly how many buttons the
- * device has...
- */
- for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
- map[nbuttons + 1] = nbuttons + 1;
-
- InitPointerDeviceStruct((DevicePtr)pPointer,
- map,
- min(mouse->buttons, MSE_MAXBUTTONS),
- miPointerGetMotionEvents,
- ctrl,
- miPointerGetMotionBufferSize());
-
- xf86MouseInit(mouse);
-
- break;
-
- case DEVICE_ON:
-
- mousefd = xf86MouseOn(mouse);
-
- if (fd)
- *fd = mousefd;
-
- if (mousefd != -1) {
- if (mousefd == -2) {
- if (fd)
- *fd = -1;
- } else {
- if (mouse->mseType == P_PS2)
- write(mousefd, "\364", 1);
-
- AddEnabledDevice(mousefd);
- }
- mouse->lastButtons = 0;
- mouse->emulateState = 0;
- pPointer->public.on = TRUE;
- } else {
- return !Success;
- }
-
- break;
-
- case DEVICE_OFF:
- case DEVICE_CLOSE:
-
- mousefd = xf86MouseOff(mouse, what == DEVICE_CLOSE);
-
- if (mousefd != -1)
- RemoveEnabledDevice(mousefd);
-
- pPointer->public.on = FALSE;
- usleep(300000);
- break;
- }
- return Success;
-}
-
-/*
- * xf86MseEvents --
- * Read the new events from the device, and pass them to the eventhandler.
- * This should is not used if there is only an OS_MOUSE driver.
- */
-#ifndef OSMOUSE_ONLY
-void
-xf86MseEvents(mouse)
- MouseDevPtr mouse;
-{
- xf86MouseEvents(mouse);
-}
-#endif
-
-#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__)
+#if defined(DDXTIME) && !defined(QNX4)
/*
* These are getting tossed in here until I can think of where
* they really belong
*/
+#define HALFMONTH ((unsigned long) 1<<31)
CARD32
GetTimeInMillis()
{
struct timeval tp;
+ register CARD32 val;
+ register INT32 diff;
+ static CARD32 oldval = 0;
+ static CARD32 time = 0;
gettimeofday(&tp, 0);
- return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+ val = (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+ if (oldval) {
+ diff = val - oldval;
+ if (diff > 0)
+ time += diff;
+ }
+ oldval = val;
+
+ return time;
}
-#endif /* !AMOEBA && !(sun || SVR4) && !MINIX */
+#endif /* DDXTIME && !QNX4 */