Commit 60ea7b51 authored by Daniel Stone's avatar Daniel Stone Committed by Daniel Stone

xorg ddx: move to new input API, remove old keyboard driver

Remove most of the rest of the old keyboard driver.
Move to the new Get{Keyboard,Pointer}Events API, which is mostly
complete at this stage: just missing the proximity events.
parent d32dc8bf
......@@ -1136,7 +1136,6 @@ configInputKbd(IDevPtr inputp)
xf86Info.kbdDelay = 500;
xf86Info.kbdRate = 30;
xf86Info.kbdProc = NULL;
xf86Info.vtinit = NULL;
xf86Info.vtSysreq = VT_SYSREQ_DEFAULT;
#if defined(SVR4) && defined(i386)
......@@ -1172,8 +1171,6 @@ configInputKbd(IDevPtr inputp)
s = xf86SetStrOption(inputp->commonOptions, "Protocol", kbdproto);
if (xf86NameCmp(s, "standard") == 0) {
xf86Info.kbdProc = xf86KbdProc;
xf86Info.kbdEvents = xf86KbdEvents;
xfree(s);
} else if (xf86NameCmp(s, "xqueue") == 0) {
#ifdef __UNIXWARE__
......@@ -1181,20 +1178,14 @@ configInputKbd(IDevPtr inputp)
* To retain compatibility with older config files, on UnixWare, we
* accept the xqueue protocol but use the normal keyboard procs.
*/
xf86Info.kbdProc = xf86KbdProc;
xf86Info.kbdEvents = xf86KbdEvents;
#else
#ifdef XQUEUE
xf86Info.kbdProc = xf86XqueKbdProc;
xf86Info.kbdEvents = xf86XqueEvents;
xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
#endif
#endif
xfree(s);
#ifdef WSCONS_SUPPORT
} else if (xf86NameCmp(s, "wskbd") == 0) {
xf86Info.kbdProc = xf86KbdProc;
xf86Info.kbdEvents = xf86WSKbdEvents;
xfree(s);
s = xf86SetStrOption(inputp->commonOptions, "Device", NULL);
xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n");
......
......@@ -78,14 +78,9 @@ static miPointerScreenFuncRec xf86PointerScreenFuncs = {
xf86CursorOffScreen,
xf86CrossScreen,
xf86WarpCursor,
#ifdef XINPUT
xf86eqEnqueue,
xf86eqSwitchScreen
#else
/* let miPointerInitialize take care of these */
NULL,
NULL
#endif
};
static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
......
......@@ -923,7 +923,7 @@ DGAStealKeyEvent(int index, xEvent *e)
de.u.u.type = e->u.u.type + *XDGAEventBase;
de.u.u.detail = e->u.u.detail;
de.u.event.time = e->u.keyButtonPointer.time;
xf86eqEnqueue ((xEvent *) &de);
mieqEnqueue ((xEvent *) &de);
return TRUE;
}
......@@ -960,7 +960,7 @@ DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
de.u.event.dy = dy;
de.u.event.pad1 = DGAMouseX;
de.u.event.pad2 = DGAMouseY;
xf86eqEnqueue ((xEvent *) &de);
mieqEnqueue ((xEvent *) &de);
return TRUE;
}
......
......@@ -164,6 +164,7 @@ void xf86PokeMmio32(pointer Base, unsigned long Offset, CARD32 v)
}
#if 0
_X_EXPORT void
xf86STimestamp(xf86TsPtr* timestamp)
{
......@@ -195,3 +196,4 @@ xf86SPTimestamp(xf86TsPtr* timestamp, char *str)
gettimeofday((struct timeval*)*timestamp,NULL);
}
}
#endif
This diff is collapsed.
......@@ -94,9 +94,6 @@ InputInfoPtr xf86InputDevs = NULL;
/* Globals that video drivers may not access */
xf86InfoRec xf86Info = {
NULL, /* pKeyboard */
NULL, /* kbdProc */
NULL, /* kbdEvents */
-1, /* consoleFd */
-1, /* kbdFd */
-1, /* vtno */
......
......@@ -155,6 +155,19 @@ xf86LookupInputDriver(const char *name)
return NULL;
}
InputInfoPtr
xf86LookupInput(const char *name)
{
InputInfoPtr p;
for (p = xf86InputDevs; p != NULL; p = p->next) {
if (strcmp(name, p->name) == 0)
return p;
}
return NULL;
}
_X_EXPORT void
xf86AddModuleInfo(ModuleInfoPtr info, pointer module)
{
......
......@@ -1006,18 +1006,6 @@ InitInput(argc, argv)
if (serverGeneration == 1) {
/* Call the PreInit function for each input device instance. */
for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
/* XXX The keyboard driver is a special case for now. */
if (!xf86NameCmp(pDev->driver, "keyboard")) {
xf86MsgVerb(X_WARNING, 0, "*** WARNING the legacy keyboard driver \"keyboard\" is deprecated\n");
xf86MsgVerb(X_WARNING, 0, "*** and will be removed in the next release of the Xorg server.\n");
xf86MsgVerb(X_WARNING, 0, "*** Please consider using the the new \"kbd\" driver for \"%s\".\n",
pDev->identifier);
continue;
}
#endif
if ((pDrv = xf86LookupInputDriver(pDev->driver)) == NULL) {
xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
/* XXX For now, just continue. */
......@@ -1040,80 +1028,18 @@ InitInput(argc, argv)
xf86DeleteInput(pInfo, 0);
continue;
}
if (pInfo->flags & XI86_CORE_KEYBOARD) {
if (coreKeyboard) {
xf86Msg(X_ERROR,
"Attempt to register more than one core keyboard (%s)\n",
pInfo->name);
pInfo->flags &= ~XI86_CORE_KEYBOARD;
} else {
if (!(pInfo->flags & XI86_KEYBOARD_CAPABLE)) {
/* XXX just a warning for now */
xf86Msg(X_WARNING,
"%s: does not have core keyboard capabilities\n",
pInfo->name);
}
coreKeyboard = pInfo;
}
}
if (pInfo->flags & XI86_CORE_POINTER) {
if (corePointer) {
xf86Msg(X_ERROR,
"Attempt to register more than one core pointer (%s)\n",
pInfo->name);
pInfo->flags &= ~XI86_CORE_POINTER;
} else {
if (!(pInfo->flags & XI86_POINTER_CAPABLE)) {
/* XXX just a warning for now */
xf86Msg(X_WARNING,
"%s: does not have core pointer capabilities\n",
pInfo->name);
}
corePointer = pInfo;
}
}
}
if (!corePointer) {
xf86Msg(X_WARNING, "No core pointer registered\n");
/* XXX register a dummy core pointer */
}
#ifdef NEW_KBD
if (!coreKeyboard) {
xf86Msg(X_WARNING, "No core keyboard registered\n");
/* XXX register a dummy core keyboard */
}
#endif
}
/* Initialise all input devices. */
pInfo = xf86InputDevs;
while (pInfo) {
xf86Msg(X_INFO, "evaluating device (%s)\n", pInfo->name);
xf86ActivateDevice(pInfo);
pInfo = pInfo->next;
}
if (coreKeyboard) {
xf86Info.pKeyboard = coreKeyboard->dev;
xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/
}
else {
#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
/* Only set this if we're allowing the old driver. */
if (xf86Info.kbdProc != NULL)
xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
#endif
}
if (corePointer)
xf86Info.pMouse = corePointer->dev;
if (xf86Info.pKeyboard)
RegisterKeyboardDevice(xf86Info.pKeyboard);
miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
#ifdef XINPUT
xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
#else
mieqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
#endif
mieqInit();
}
#ifndef SET_STDERR_NONBLOCKING
......@@ -1232,12 +1158,6 @@ AbortDDX()
{
int i;
/*
* try to deinitialize all input devices
*/
if (xf86Info.kbdProc && xf86Info.pKeyboard)
(xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
/*
* try to restore the original video state
*/
......
......@@ -160,313 +160,3 @@ xf86KbdLeds ()
xf86SetKbdLeds(real_leds);
(void)leds;
}
/*
* xf86KbdCtrl --
* Alter some of the keyboard control parameters. All special protocol
* values are handled by dix (ProgChangeKeyboardControl)
*/
void
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.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 according to ours leds.
* Depress all other keys.
*/
void
xf86InitKBD(init)
Bool init;
{
char leds = 0, rad;
unsigned int i;
xEvent kevent;
DeviceIntPtr pKeyboard = xf86Info.pKeyboard;
KeyClassRec *keyc = xf86Info.pKeyboard->key;
KeySym *map = keyc->curKeySyms.map;
kevent.u.keyButtonPointer.time = GetTimeInMillis();
kevent.u.keyButtonPointer.rootX = 0;
kevent.u.keyButtonPointer.rootY = 0;
/*
* Hmm... here is the biggest hack of every time !
* It may be possible that a switch-vt procedure has finished BEFORE
* you released all keys neccessary to do this. That peculiar behavior
* can fool the X-server pretty much, cause it assumes that some keys
* were not released. TWM may stuck alsmost completly....
* OK, what we are doing here is after returning from the vt-switch
* exeplicitely unrelease all keyboard keys before the input-devices
* are reenabled.
*/
for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
i < keyc->curKeySyms.maxKeyCode;
i++, map += keyc->curKeySyms.mapWidth)
if (KeyPressed(i))
{
switch (*map) {
/* Don't release the lock keys */
case XK_Caps_Lock:
case XK_Shift_Lock:
case XK_Num_Lock:
case XK_Scroll_Lock:
case XK_Kana_Lock:
break;
default:
kevent.u.u.detail = i;
kevent.u.u.type = KeyRelease;
(* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
}
}
xf86Info.scanPrefix = 0;
if (init)
{
/*
* we must deal here with the fact, that on some cases the numlock or
* capslock key are enabled BEFORE the server is started up. So look
* here at the state on the according LEDS to determine whether a
* lock-key is already set.
*/
xf86Info.capsLock = FALSE;
xf86Info.numLock = FALSE;
xf86Info.scrollLock = FALSE;
xf86Info.modeSwitchLock = FALSE;
xf86Info.composeLock = FALSE;
#ifdef LED_CAP
#ifdef INHERIT_LOCK_STATE
leds = xf86Info.leds;
for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
i < keyc->curKeySyms.maxKeyCode;
i++, map += keyc->curKeySyms.mapWidth)
switch(*map) {
case XK_Caps_Lock:
case XK_Shift_Lock:
if (leds & LED_CAP)
{
xf86InitialCaps = i;
xf86Info.capsLock = TRUE;
}
break;
case XK_Num_Lock:
if (leds & LED_NUM)
{
xf86InitialNum = i;
xf86Info.numLock = TRUE;
}
break;
case XK_Scroll_Lock:
case XK_Kana_Lock:
if (leds & LED_SCR)
{
xf86InitialScroll = i;
xf86Info.scrollLock = TRUE;
}
break;
}
#endif /* INHERIT_LOCK_STATE */
xf86SetKbdLeds(leds);
#endif /* LED_CAP */
(void)leds;
if (xf86Info.kbdDelay <= 375) rad = 0x00;
else if (xf86Info.kbdDelay <= 625) rad = 0x20;
else if (xf86Info.kbdDelay <= 875) rad = 0x40;
else rad = 0x60;
if (xf86Info.kbdRate <= 2) rad |= 0x1F;
else if (xf86Info.kbdRate >= 30) rad |= 0x00;
else rad |= ((58 / xf86Info.kbdRate) - 2);
xf86SetKbdRepeat(rad);
}
}
/*
* xf86KbdProc --
* Handle the initialization, etc. of a keyboard.
*/
int
xf86KbdProc (pKeyboard, what)
DeviceIntPtr pKeyboard; /* Keyboard to manipulate */
int what; /* What to do to it */
{
KeySymsRec keySyms;
CARD8 modMap[MAP_LENGTH];
int kbdFd;
switch (what) {
case DEVICE_INIT:
/*
* First open and find the current state of the keyboard.
*/
xf86KbdInit();
xf86KbdGetMapping(&keySyms, modMap);
#ifndef XKB
defaultKeyboardControl.leds = xf86GetKbdLeds();
#else
defaultKeyboardControl.leds = 0;
#endif
/*
* Perform final initialization of the system private keyboard
* structure and fill in various slots in the device record
* itself which couldn't be filled in before.
*/
pKeyboard->public.on = FALSE;
#ifdef XKB
if (noXkbExtension) {
#endif
InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
&keySyms,
modMap,
xf86KbdBell,
(KbdCtrlProcPtr)xf86KbdCtrl);
#ifdef XKB
} else {
XkbComponentNamesRec names;
XkbDescPtr desc;
Bool foundTerminate = FALSE;
int keyc;
if (xf86Info.xkbkeymap) {
names.keymap = xf86Info.xkbkeymap;
names.keycodes = NULL;
names.types = NULL;
names.compat = NULL;
names.symbols = NULL;
names.geometry = NULL;
} else {
names.keymap = NULL;
names.keycodes = xf86Info.xkbkeycodes;
names.types = xf86Info.xkbtypes;
names.compat = xf86Info.xkbcompat;
names.symbols = xf86Info.xkbsymbols;
names.geometry = xf86Info.xkbgeometry;
}
if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
&& (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
xf86Info.xkbrules = NULL;
}
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
xf86InitKBD(TRUE);
break;
case DEVICE_ON:
/*
* Set the keyboard into "direct" mode and turn on
* event translation.
*/
kbdFd = xf86KbdOn();
/*
* Discard any pending input after a VT switch to prevent the server
* passing on parts of the VT switch sequence.
*/
sleep(1);
#if defined(WSCONS_SUPPORT)
if (xf86Info.consType != WSCONS) {
#endif
if (kbdFd != -1) {
char buf[16];
read(kbdFd, buf, 16);
}
#if defined(WSCONS_SUPPORT)
}
#endif
#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */
if (kbdFd != -1)
AddEnabledDevice(kbdFd);
#endif /* __UNIXOS2__ */
pKeyboard->public.on = TRUE;
xf86InitKBD(FALSE);
break;
case DEVICE_CLOSE:
case DEVICE_OFF:
/*
* Restore original keyboard directness and translation.
*/
kbdFd = xf86KbdOff();
if (kbdFd != -1)
RemoveEnabledDevice(kbdFd);
pKeyboard->public.on = FALSE;
break;
}
return (Success);
}
......@@ -366,7 +366,7 @@ MiscExtCreateStruct(MiscExtStructType mse_or_kbd)
InputInfoPtr pInfo = xf86InputDevs;
while (pInfo) {
if (xf86IsCorePointer(pInfo->dev))
if (pInfo->dev == inputInfo.pointer)
break;
pInfo = pInfo->next;
}
......
......@@ -200,9 +200,6 @@ void xf86KbdBell(int percent, DeviceIntPtr pKeyboard, pointer ctrl,
int unused);
void xf86KbdLeds(void);
void xf86UpdateKbdLeds(void);
void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl);
void xf86InitKBD(Bool init);
int xf86KbdProc(DeviceIntPtr pKeyboard, int what);
/* xf86Kbd.c */
......
......@@ -68,11 +68,6 @@ typedef enum {
*/
typedef struct {
/* keyboard part */
DeviceIntPtr pKeyboard;
DeviceProc kbdProc; /* procedure for initializing */
void (* kbdEvents)(void); /* proc for processing events */
int consoleFd;
int kbdFd;
int vtno;
......
This diff is collapsed.
......@@ -147,8 +147,6 @@ typedef struct _LocalDeviceRec {
unsigned int last;
int old_x;
int old_y;
float dxremaind;
float dyremaind;
char * type_name;
IntegerFeedbackPtr always_core_feedback;
IDevPtr conf_idev;
......@@ -167,16 +165,7 @@ typedef struct _DeviceAssocRec
extern InputInfoPtr xf86InputDevs;
/* xf86Xinput.c */
int xf86IsCorePointer(DeviceIntPtr dev);
int xf86IsCoreKeyboard(DeviceIntPtr dev);
void xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always);
#define xf86AlwaysCore(a,b) xf86XInputSetSendCoreEvents(a,b)
void InitExtInput(void);
Bool xf86eqInit(DevicePtr pKbd, DevicePtr pPtr);
void xf86eqEnqueue(struct _xEvent *event);
void xf86eqProcessInputEvents (void);
void xf86eqSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
int first_valuator, int num_valuators, ...);
void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
......@@ -212,10 +201,16 @@ void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
void xf86DeleteInputDriver(int drvIndex);
InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags);
InputDriverPtr xf86LookupInputDriver(const char *name);
InputInfoPtr xf86LookupInput(const char *name);
void xf86DeleteInput(InputInfoPtr pInp, int flags);
/* xf86Option.c */
void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
pointer extraOpts);
/* Legacy hatred */
#define SendCoreEvents 59
#define DontSendCoreEvents 60
#endif /* _xf86Xinput_h */
......@@ -293,7 +293,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
SYMFUNC(xf86SoundKbdBell)
SYMFUNC(xf86GARTCloseScreen)
#ifdef XINPUT
/* XISB routines (Merged from Metrolink tree) */
SYMFUNC(XisbNew)
SYMFUNC(XisbFree)
SYMFUNC(XisbRead)
......@@ -695,7 +694,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
/* xf86Xinput.c */
#ifdef XINPUT
SYMFUNC(xf86ProcessCommonOptions)
SYMFUNC(xf86IsCorePointer)
SYMFUNC(xf86PostMotionEvent)