Commit 02d09105 authored by Daniel Stone's avatar Daniel Stone Committed by Daniel Stone

new KDrive input world order

Convert KDrive to GPE/GKE interface.
Add first-class drivers and enumerate every device separately through
Xi, instead of lamely attempting to aggregate them.
Add XKB support to the Linux keyboard driver.
Add 'thumb button' support to the tslib driver.
Rejig InitInput, so each DDX has to add a list of drivers it supports.
Support NewInputDeviceRequest, et al.
parent a274e729
This diff is collapsed.
......@@ -3,10 +3,14 @@ VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
smi via
endif
if KDRIVEFBDEV
if BUILD_KDRIVEFBDEVLIB
FBDEV_SUBDIRS = fbdev
endif
if XFAKESERVER
XFAKE_SUBDIRS = fake
endif
if XSDLSERVER
XSDL_SUBDIRS = sdl
endif
......@@ -22,7 +26,7 @@ SUBDIRS = \
$(FBDEV_SUBDIRS) \
$(VESA_SUBDIRS) \
$(XEPHYR_SUBDIRS) \
fake
$(XFAKE_SUBDIRS)
DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
smi via fbdev sdl ephyr src linux fake sis300
......@@ -53,7 +53,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput(int argc, char **argv)
{
KdInitInput(&LinuxMouseFuncs, &LinuxKeyboardFuncs);
KdKeyboardInfo *ki = NULL;
KdAddPointerDriver(&LinuxMouseDriver);
ki = KdNewKeyboard();
if (ki) {
ki->driver = &LinuxKeyboardDriver;
KdAddKeyboard(ki);
}
KdInitInput();
}
void
......
......@@ -33,7 +33,6 @@ Xephyr_LDADD = \
libxephyr-hostx.a \
../../../exa/libexa.la \
@KDRIVE_LIBS@ \
@KDRIVE_LIBS@ \
$(TSLIB_LIBS) \
@XEPHYR_LIBS@
......
......@@ -36,10 +36,16 @@
#include "inputstr.h"
extern int KdTsPhyScreen;
extern DeviceIntPtr pKdKeyboard;
KdKeyboardInfo *ephyrKbd;
KdPointerInfo *ephyrMouse;
EphyrKeySyms ephyrKeySyms;
static int mouseState = 0;
typedef struct _EphyrInputPrivate {
Bool enabled;
} EphyrKbdPrivate, EphyrPointerPrivate;
Bool EphyrWantGrayScale = 0;
Bool
......@@ -206,15 +212,14 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
{
EphyrScrPriv *scrpriv = screen->driver;
EphyrPriv *priv = screen->card->driver;
KdMouseMatrix m;
KdPointerMatrix m;
int buffer_height;
EPHYR_DBG(" screen->width: %d, screen->height: %d",
screen->width, screen->height);
KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdSetMouseMatrix (&m);
KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdSetPointerMatrix (&m);
priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
......@@ -719,8 +724,9 @@ ephyrUpdateModifierState(unsigned int state)
kptr = &keyc->down[key >> 3];
bit = 1 << (key & 7);
if (*kptr & bit)
KdEnqueueKeyboardEvent(key, TRUE); /* release */
if (*kptr & bit && ephyrKbd &&
((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */
if (--count == 0)
break;
......@@ -732,7 +738,9 @@ ephyrUpdateModifierState(unsigned int state)
for (key = 0; key < MAP_LENGTH; key++)
if (keyc->modifierMap[key] & mask)
{
KdEnqueueKeyboardEvent(key, FALSE); /* press */
if (keyc->modifierMap[key] & mask && ephyrKbd &&
((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */
break;
}
}
......@@ -748,31 +756,47 @@ ephyrPoll(void)
switch (ev.type)
{
case EPHYR_EV_MOUSE_MOTION:
KdEnqueueMouseEvent(kdMouseInfo, mouseState,
ev.data.mouse_motion.x,
ev.data.mouse_motion.y);
if (!ephyrMouse ||
!((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
continue;
KdEnqueuePointerEvent(ephyrMouse, mouseState,
ev.data.mouse_motion.x,
ev.data.mouse_motion.y,
0);
break;
case EPHYR_EV_MOUSE_PRESS:
if (!ephyrMouse ||
!((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
continue;
ephyrUpdateModifierState(ev.key_state);
mouseState |= ev.data.mouse_down.button_num;
KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0);
KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
break;
case EPHYR_EV_MOUSE_RELEASE:
if (!ephyrMouse ||
!((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
continue;
ephyrUpdateModifierState(ev.key_state);
mouseState &= ~ev.data.mouse_up.button_num;
KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0);
KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
break;
case EPHYR_EV_KEY_PRESS:
if (!ephyrKbd ||
!((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
continue;
ephyrUpdateModifierState(ev.key_state);
KdEnqueueKeyboardEvent (ev.data.key_down.scancode, FALSE);
KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE);
break;
case EPHYR_EV_KEY_RELEASE:
if (!ephyrKbd ||
!((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
continue;
ephyrUpdateModifierState(ev.key_state);
KdEnqueueKeyboardEvent (ev.data.key_up.scancode, TRUE);
KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
break;
default:
......@@ -833,59 +857,115 @@ ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
/* Mouse calls */
static Bool
MouseInit (void)
static Status
MouseInit (KdPointerInfo *pi)
{
pi->driverPrivate = (EphyrPointerPrivate *)
xcalloc(sizeof(EphyrPointerPrivate), 1);
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
ephyrMouse = pi;
/* FIXME DO NOT COMMIT */
KdAddPointerDriver(&EphyrMouseDriver);
ErrorF("SUCCESS!\n");
return Success;
}
static Status
MouseEnable (KdPointerInfo *pi)
{
return TRUE;
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
ErrorF("SUCCESS ENABLE!\n");
return Success;
}
static void
MouseFini (void)
MouseDisable (KdPointerInfo *pi)
{
;
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
return;
}
KdMouseFuncs EphyrMouseFuncs = {
static void
MouseFini (KdPointerInfo *pi)
{
ephyrMouse = NULL;
return;
}
KdPointerDriver EphyrMouseDriver = {
"ephyr",
MouseInit,
MouseEnable,
MouseDisable,
MouseFini,
NULL,
};
/* Keyboard */
static void
EphyrKeyboardLoad (void)
static Status
EphyrKeyboardInit (KdKeyboardInfo *ki)
{
EPHYR_DBG("mark");
ki->driverPrivate = (EphyrKbdPrivate *)
xcalloc(sizeof(EphyrKbdPrivate), 1);
/* FIXME blah blah overrunning memory blah blah */
ki->minScanCode = ki->keySyms.minKeyCode = 0;
ki->maxScanCode = ki->keySyms.maxKeyCode = 255;
ephyrKbd = ki;
return Success;
}
hostx_load_keymap();
static Status
EphyrKeyboardEnable (KdKeyboardInfo *ki)
{
hostx_load_keymap();
if (!ephyrKeySyms.map) {
ErrorF("Couldn't load keymap from host\n");
return BadAlloc;
}
ki->keySyms.minKeyCode = ephyrKeySyms.minKeyCode;
ki->keySyms.maxKeyCode = ephyrKeySyms.maxKeyCode;
ki->minScanCode = ki->keySyms.minKeyCode;
ki->maxScanCode = ki->keySyms.maxKeyCode;
ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
ki->keySyms.map = ephyrKeySyms.map;
((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
return Success;
}
static int
EphyrKeyboardInit (void)
static void
EphyrKeyboardDisable (KdKeyboardInfo *ki)
{
return 0;
((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE;
}
static void
EphyrKeyboardFini (void)
EphyrKeyboardFini (KdKeyboardInfo *ki)
{
/* not xfree: we call malloc from hostx.c. */
free(ki->keySyms.map);
ephyrKbd = NULL;
return;
}
static void
EphyrKeyboardLeds (int leds)
EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds)
{
}
static void
EphyrKeyboardBell (int volume, int frequency, int duration)
EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
{
}
KdKeyboardFuncs EphyrKeyboardFuncs = {
EphyrKeyboardLoad,
KdKeyboardDriver EphyrKeyboardDriver = {
"ephyr",
EphyrKeyboardInit,
EphyrKeyboardEnable,
EphyrKeyboardLeds,
EphyrKeyboardBell,
EphyrKeyboardDisable,
EphyrKeyboardFini,
0,
NULL,
};
......@@ -31,7 +31,6 @@
#include "os.h" /* for OsSignal() */
#include "kdrive.h"
#include "kkeymap.h"
#include "hostx.h"
#include "exa.h"
......@@ -68,7 +67,9 @@ typedef struct _ephyrScrPriv {
EphyrFakexaPriv *fakexa;
} EphyrScrPriv;
extern KdCardFuncs ephyrFuncs;
extern KdCardFuncs ephyrFuncs;
extern KdKeyboardInfo *ephyrKbd;
extern KdPointerInfo *ephyrMouse;
Bool
ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
......@@ -167,9 +168,9 @@ ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
void
ephyrUpdateModifierState(unsigned int state);
extern KdMouseFuncs EphyrMouseFuncs;
extern KdPointerDriver EphyrMouseDriver;
extern KdKeyboardFuncs EphyrKeyboardFuncs;
extern KdKeyboardDriver EphyrKeyboardDriver;
extern KdOsFuncs EphyrOsFuncs;
......
......@@ -51,7 +51,24 @@ InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput (int argc, char **argv)
{
KdInitInput (&EphyrMouseFuncs, &EphyrKeyboardFuncs);
KdKeyboardInfo *ki;
KdPointerInfo *pi;
ki = KdNewKeyboard();
if (!ki)
FatalError("Couldn't create Xephyr keyboard\n");
ki->driver = &EphyrKeyboardDriver;
ki->name = KdSaveString("Xephyr virtual keyboard");
KdAddKeyboard(ki);
pi = KdNewPointer();
if (!pi)
FatalError("Couldn't create Xephyr pointer\n");
pi->driver = &EphyrMouseDriver;
pi->name = KdSaveString("Xephyr virtual mouse");
KdAddPointer(pi);
KdInitInput();
}
void
......
......@@ -77,14 +77,8 @@ static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static int HostXWantDamageDebug = 0;
extern KeySym EphyrKeymap[];
extern KeySym kdKeymap[];
extern int kdMinScanCode;
extern int kdMaxScanCode;
extern int kdMinKeyCode;
extern int kdMaxKeyCode;
extern int kdKeymapWidth;
extern EphyrKeySyms ephyrKeySyms;
extern int monitorResolution;
static void
......@@ -403,9 +397,9 @@ hostx_get_bpp(void)
}
void
hostx_get_visual_masks (unsigned long *rmsk,
unsigned long *gmsk,
unsigned long *bmsk)
hostx_get_visual_masks (CARD32 *rmsk,
CARD32 *gmsk,
CARD32 *bmsk)
{
if (host_depth_matches_server())
{
......@@ -681,6 +675,13 @@ hostx_load_keymap(void)
max_keycode - min_keycode + 1,
&host_width);
ephyrKeySyms.map = (KeySym *)calloc(sizeof(KeySym),
(max_keycode - min_keycode + 1) *
width);
if (!ephyrKeySyms.map)
return;
/* Try and copy the hosts keymap into our keymap to avoid loads
* of messing around.
*
......@@ -695,13 +696,9 @@ hostx_load_keymap(void)
EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
/* all kdrive vars - see kkeymap.c */
kdMinScanCode = min_keycode;
kdMaxScanCode = max_keycode;
kdMinKeyCode = min_keycode;
kdMaxKeyCode = max_keycode;
kdKeymapWidth = width;
ephyrKeySyms.minKeyCode = min_keycode;
ephyrKeySyms.maxKeyCode = max_keycode;
ephyrKeySyms.mapWidth = (width > 4) ? 4 : width;
XFree(keymap);
}
......
......@@ -26,6 +26,9 @@
#ifndef _XLIBS_STUFF_H_
#define _XLIBS_STUFF_H_
#include <X11/X.h>
#include <X11/Xmd.h>
#define EPHYR_WANT_DEBUG 0
#if (EPHYR_WANT_DEBUG)
......@@ -48,6 +51,14 @@ typedef enum EphyrHostXEventType
}
EphyrHostXEventType;
/* I can't believe it's not a KeySymsRec. */
typedef struct {
int minKeyCode;
int maxKeyCode;
int mapWidth;
KeySym *map;
} EphyrKeySyms;
struct EphyrHostXEvent
{
EphyrHostXEventType type;
......@@ -126,9 +137,9 @@ int
hostx_get_bpp(void);
void
hostx_get_visual_masks (unsigned long *rmsk,
unsigned long *gmsk,
unsigned long *bmsk);
hostx_get_visual_masks (CARD32 *rmsk,
CARD32 *gmsk,
CARD32 *bmsk);
void
hostx_set_cmap_entry(unsigned char idx,
unsigned char r,
......
......@@ -158,7 +158,7 @@ Bool
fakeMapFramebuffer (KdScreenInfo *screen)
{
FakeScrPriv *scrpriv = screen->driver;
KdMouseMatrix m;
KdPointerMatrix m;
FakePriv *priv = screen->card->driver;
if (scrpriv->randr != RR_Rotate_0)
......@@ -166,9 +166,9 @@ fakeMapFramebuffer (KdScreenInfo *screen)
else
scrpriv->shadow = FALSE;
KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdSetMouseMatrix (&m);
KdSetPointerMatrix (&m);
priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
if (priv->base)
......
......@@ -130,9 +130,9 @@ fakeRandRInit (ScreenPtr pScreen);
#endif
extern KdMouseFuncs FakeMouseFuncs;
extern KdPointerDriver FakePointerDriver;
extern KdKeyboardFuncs FakeKeyboardFuncs;
extern KdKeyboardDriver FakeKeyboardDriver;
extern KdOsFuncs FakeOsFuncs;
......
......@@ -44,7 +44,22 @@ InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput (int argc, char **argv)
{
KdInitInput (&FakeMouseFuncs, &FakeKeyboardFuncs);
KdPointerInfo *pi;
KdKeyboardInfo *ki;
pi = KdNewPointer ();
if (!pi)
return;
pi->driver = &FakePointerDriver;
KdAddPointer(pi);
ki = KdNewKeyboard ();
if (!ki)
return;
ki->driver = &FakeKeyboardDriver;
KdAddKeyboard(ki);
KdInitInput ();
}
void
......
......@@ -27,7 +27,6 @@
#include <kdrive-config.h>
#endif
#include "fake.h"
#include "kkeymap.h"
#include <X11/keysym.h>
#define FAKE_WIDTH 2
......@@ -155,41 +154,58 @@ KeySym FakeKeymap[] = {
/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
};
static void
FakeKeyboardLoad (void)
static Status
FakeKeyboardInit (KdKeyboardInfo *ki)
{
ki->keySyms.minKeyCode = 1;
ki->keySyms.maxKeyCode = (sizeof (FakeKeymap) / sizeof (FakeKeymap[0])) / FAKE_WIDTH;
ki->keySyms.mapWidth = FAKE_WIDTH;
if (ki->keySyms.map)
xfree(ki->keySyms.map);
ki->keySyms.map = (KeySym *)xalloc(sizeof(FakeKeymap));
if (!ki->keySyms.map)
return BadAlloc;
memcpy (ki->keySyms.map, FakeKeymap, sizeof (FakeKeymap));
return Success;
}
static Status
FakeKeyboardEnable (KdKeyboardInfo *ki)
{
kdMinScanCode = 1;
kdKeymapWidth = FAKE_WIDTH;
kdMaxScanCode = (sizeof (FakeKeymap) / sizeof (FakeKeymap[0])) / FAKE_WIDTH;
memcpy (kdKeymap, FakeKeymap, sizeof (FakeKeymap));
return Success;
}
static int
FakeKeyboardInit (void)
static void
FakeKeyboardDisable (KdKeyboardInfo *ki)
{
return 0;
return;
}
static void
FakeKeyboardFini (void)
FakeKeyboardFini (KdKeyboardInfo *ki)
{
xfree(ki->keySyms.map);
ki->keySyms.map = NULL;
}
static void
FakeKeyboardLeds (int leds)
FakeKeyboardLeds (KdKeyboardInfo *ki, int leds)
{
}
static void
FakeKeyboardBell (int volume, int frequency, int duration)
FakeKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
{
}
KdKeyboardFuncs FakeKeyboardFuncs = {
FakeKeyboardLoad,
KdKeyboardDriver FakeKeyboardDriver = {
"fake",
FakeKeyboardInit,
FakeKeyboardEnable,
FakeKeyboardLeds,
FakeKeyboardBell,
FakeKeyboardDisable,
FakeKeyboardFini,
0,
NULL,
};
......@@ -35,19 +35,35 @@
#include "scrnintstr.h"
#include "kdrive.h"
static Bool
MouseInit (void)
static Status
MouseInit (KdPointerInfo *pi)
{
return TRUE;
return Success;
}
static Status
MouseEnable (KdPointerInfo *pi)
{
return Success;
}
static void
MouseDisable (KdPointerInfo *pi)
{
return;
}
static void
MouseFini (void)
MouseFini (KdPointerInfo *pi)
{
return;
}
KdMouseFuncs FakeMouseFuncs = {
KdPointerDriver FakePointerDriver = {
"fake",
MouseInit,
MouseEnable,
MouseDisable,
MouseFini,
};
......@@ -4,8 +4,6 @@ INCLUDES = \
noinst_LIBRARIES = libfbdev.a
bin_PROGRAMS = Xfbdev
if TSLIB
TSLIB_FLAG = -lts
endif
......@@ -14,6 +12,9 @@ libfbdev_a_SOURCES = \
fbdev.c \
fbdev.h
if KDRIVEFBDEV
bin_PROGRAMS = Xfbdev
Xfbdev_SOURCES = \
fbinit.c
......@@ -26,4 +27,4 @@ Xfbdev_LDADD = \
Xfbdev_DEPENDENCIES = \
libfbdev.a \
@KDRIVE_LIBS@
endif
......@@ -323,7 +323,7 @@ Bool
fbdevMapFramebuffer (KdScreenInfo *screen)
{
FbdevScrPriv *scrpriv = screen->driver;
KdMouseMatrix m;
KdPointerMatrix m;
FbdevPriv *priv = screen->card->driver;
if (scrpriv->randr != RR_Rotate_0)
......@@ -331,9 +331,9 @@ fbdevMapFramebuffer (KdScreenInfo *screen)
else
scrpriv->shadow = FALSE;
KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
KdSetMouseMatrix (&m);
KdSetPointerMatrix (&m);
screen->width = priv->var.xres;
screen->height = priv->var.yres;
......
......@@ -45,10 +45,18 @@ InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
void
InitInput (int argc, char **argv)
{
KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
#ifdef TOUCHSCREEN
KdAddMouseDriver (&TsFuncs);
KdKeyboardInfo *ki;
KdAddKeyboardDriver (&LinuxKeyboardDriver);
KdAddPointerDriver (&LinuxMouseDriver);
#ifdef TSLIB
KdAddPointerDriver (&TsDriver);
#endif
ki = KdParseKeyboard ("keybd");
KdAddKeyboard(ki);
KdInitInput ();
}
void
......
......@@ -27,7 +27,6 @@
#include <kdrive-config.h>
#endif
#include "itsy.h"
#include "kkeymap.h"
#include <X11/keysym.h>
#include <linux/itsy_buttons.h>
......@@ -167,28 +166,44 @@ ItsyKeyboardLoad (void)
{
KeySym *k;
itsyButtonState = 0;
kdMinScanCode = 1;
kdKeymapWidth = ITSY_WIDTH;
kdMaxScanCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH;
memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap));
}
int
ItsyKeyboardInit (void)
static Status
ItsyKeyboardInit (KdKeyboardInfo *ki)
{
int butPort;
if (!ki)
return BadImplementation;
ki->driverPrivate = open ("/dev/buttons", 0);
</