Rework kdrive input fd handling, enable multiple simultaneous mice
This commit is contained in:
parent
c872ee8204
commit
67cd53abfc
|
@ -33,7 +33,7 @@
|
||||||
/* /dev/adbmouse is a busmouse */
|
/* /dev/adbmouse is a busmouse */
|
||||||
|
|
||||||
void
|
void
|
||||||
BusRead (int adbPort)
|
BusRead (int adbPort, void *closure)
|
||||||
{
|
{
|
||||||
unsigned char buf[3];
|
unsigned char buf[3];
|
||||||
unsigned char *b;
|
unsigned char *b;
|
||||||
|
@ -64,29 +64,36 @@ char *BusNames[] = {
|
||||||
|
|
||||||
#define NUM_BUS_NAMES (sizeof (BusNames) / sizeof (BusNames[0]))
|
#define NUM_BUS_NAMES (sizeof (BusNames) / sizeof (BusNames[0]))
|
||||||
|
|
||||||
|
int BusInputType;
|
||||||
|
|
||||||
int
|
int
|
||||||
BusInit (void)
|
BusInit (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int busPort;
|
int busPort;
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (!BusInputType)
|
||||||
|
BusInputType = KdAllocInputType ();
|
||||||
|
|
||||||
for (i = 0; i < NUM_BUS_NAMES; i++)
|
for (i = 0; i < NUM_BUS_NAMES; i++)
|
||||||
{
|
{
|
||||||
busPort = open (BusNames[i], 0);
|
busPort = open (BusNames[i], 0);
|
||||||
if (busPort >= 0)
|
{
|
||||||
return busPort;
|
KdRegisterFd (BusInputType, busPort, BusRead, 0);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BusFini (int busPort)
|
BusFini (void)
|
||||||
{
|
{
|
||||||
if (busPort >= 0)
|
KdUnregisterFds (BusInputType, TRUE);
|
||||||
close (busPort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KdMouseFuncs BusMouseFuncs = {
|
KdMouseFuncs BusMouseFuncs = {
|
||||||
BusInit,
|
BusInit,
|
||||||
BusRead,
|
|
||||||
BusFini
|
BusFini
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.5 2000/12/08 23:04:57 keithp Exp $
|
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.6 2001/03/30 02:15:20 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 1999 Keith Packard
|
* Copyright © 1999 Keith Packard
|
||||||
*
|
*
|
||||||
|
@ -376,14 +376,35 @@ LinuxKeyboardLoad (void)
|
||||||
readKernelMapping ();
|
readKernelMapping ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LinuxKeyboardRead (int fd, void *closure)
|
||||||
|
{
|
||||||
|
unsigned char buf[256], *b;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
while ((n = read (fd, buf, sizeof (buf))) > 0)
|
||||||
|
{
|
||||||
|
b = buf;
|
||||||
|
while (n--)
|
||||||
|
{
|
||||||
|
KdEnqueueKeyboardEvent (b[0] & 0x7f, b[0] & 0x80);
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int LinuxKbdTrans;
|
static int LinuxKbdTrans;
|
||||||
static struct termios LinuxTermios;
|
static struct termios LinuxTermios;
|
||||||
|
static int LinuxKbdType;
|
||||||
|
|
||||||
int
|
int
|
||||||
LinuxKeyboardInit (void)
|
LinuxKeyboardInit (void)
|
||||||
{
|
{
|
||||||
struct termios nTty;
|
struct termios nTty;
|
||||||
|
|
||||||
|
if (!LinuxKbdType)
|
||||||
|
LinuxKbdType = KdAllocInputType ();
|
||||||
|
|
||||||
ioctl (LinuxConsoleFd, KDGKBMODE, &LinuxKbdTrans);
|
ioctl (LinuxConsoleFd, KDGKBMODE, &LinuxKbdTrans);
|
||||||
tcgetattr (LinuxConsoleFd, &LinuxTermios);
|
tcgetattr (LinuxConsoleFd, &LinuxTermios);
|
||||||
|
|
||||||
|
@ -398,31 +419,16 @@ LinuxKeyboardInit (void)
|
||||||
cfsetispeed(&nTty, 9600);
|
cfsetispeed(&nTty, 9600);
|
||||||
cfsetospeed(&nTty, 9600);
|
cfsetospeed(&nTty, 9600);
|
||||||
tcsetattr(LinuxConsoleFd, TCSANOW, &nTty);
|
tcsetattr(LinuxConsoleFd, TCSANOW, &nTty);
|
||||||
return LinuxConsoleFd;
|
KdRegisterFd (LinuxKbdType, LinuxConsoleFd, LinuxKeyboardRead, 0);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LinuxKeyboardFini (int fd)
|
LinuxKeyboardFini (void)
|
||||||
{
|
{
|
||||||
ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
|
ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
|
||||||
tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
|
tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
|
||||||
}
|
KdUnregisterFds (LinuxKbdType, FALSE);
|
||||||
|
|
||||||
void
|
|
||||||
LinuxKeyboardRead (int fd)
|
|
||||||
{
|
|
||||||
unsigned char buf[256], *b;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
while ((n = read (fd, buf, sizeof (buf))) > 0)
|
|
||||||
{
|
|
||||||
b = buf;
|
|
||||||
while (n--)
|
|
||||||
{
|
|
||||||
KdEnqueueKeyboardEvent (b[0] & 0x7f, b[0] & 0x80);
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -447,7 +453,6 @@ LinuxKeyboardBell (int volume, int pitch, int duration)
|
||||||
KdKeyboardFuncs LinuxKeyboardFuncs = {
|
KdKeyboardFuncs LinuxKeyboardFuncs = {
|
||||||
LinuxKeyboardLoad,
|
LinuxKeyboardLoad,
|
||||||
LinuxKeyboardInit,
|
LinuxKeyboardInit,
|
||||||
LinuxKeyboardRead,
|
|
||||||
LinuxKeyboardLeds,
|
LinuxKeyboardLeds,
|
||||||
LinuxKeyboardBell,
|
LinuxKeyboardBell,
|
||||||
LinuxKeyboardFini,
|
LinuxKeyboardFini,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86$
|
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/ps2.c,v 1.4 2001/04/01 14:00:04 tsi Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 1999 Keith Packard
|
* Copyright © 1999 Keith Packard
|
||||||
*
|
*
|
||||||
|
@ -60,15 +60,34 @@ Ps2ReadBytes (int fd, char *buf, int len, int min)
|
||||||
return tot;
|
return tot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *Ps2Names[] = {
|
||||||
|
"/dev/psaux",
|
||||||
|
"/dev/mouse",
|
||||||
|
"/dev/input/mice",
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NUM_PS2_NAMES (sizeof (Ps2Names) / sizeof (Ps2Names[0]))
|
||||||
|
|
||||||
void
|
void
|
||||||
Ps2Read (int ps2Port)
|
Ps2Read (int ps2Port, void *closure)
|
||||||
{
|
{
|
||||||
unsigned char buf[3 * 200];
|
unsigned char buf[3 * 200];
|
||||||
unsigned char *b;
|
unsigned char *b;
|
||||||
int n;
|
int n;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
int id = (int) closure;
|
||||||
|
unsigned long left_button = KD_BUTTON_1;
|
||||||
|
unsigned long right_button = KD_BUTTON_3;
|
||||||
|
|
||||||
|
#undef SWAP_USB
|
||||||
|
#ifdef SWAP_USB
|
||||||
|
if (id == 2)
|
||||||
|
{
|
||||||
|
left_button = KD_BUTTON_3;
|
||||||
|
right_button = KD_BUTTON_1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while ((n = Ps2ReadBytes (ps2Port, buf, sizeof (buf), 3)) > 0)
|
while ((n = Ps2ReadBytes (ps2Port, buf, sizeof (buf), 3)) > 0)
|
||||||
{
|
{
|
||||||
b = buf;
|
b = buf;
|
||||||
|
@ -78,10 +97,10 @@ Ps2Read (int ps2Port)
|
||||||
if (b[0] & 4)
|
if (b[0] & 4)
|
||||||
flags |= KD_BUTTON_2;
|
flags |= KD_BUTTON_2;
|
||||||
if (b[0] & 2)
|
if (b[0] & 2)
|
||||||
flags |= KD_BUTTON_3;
|
flags |= right_button;
|
||||||
if (b[0] & 1)
|
if (b[0] & 1)
|
||||||
flags |= KD_BUTTON_1;
|
flags |= left_button;
|
||||||
|
|
||||||
dx = b[1];
|
dx = b[1];
|
||||||
if (b[0] & 0x10)
|
if (b[0] & 0x10)
|
||||||
dx -= 256;
|
dx -= 256;
|
||||||
|
@ -96,37 +115,37 @@ Ps2Read (int ps2Port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Ps2Names[] = {
|
int Ps2InputType;
|
||||||
"/dev/psaux",
|
|
||||||
"/dev/mouse",
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NUM_PS2_NAMES (sizeof (Ps2Names) / sizeof (Ps2Names[0]))
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Ps2Init (void)
|
Ps2Init (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int ps2Port;
|
int ps2Port;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if (!Ps2InputType)
|
||||||
|
Ps2InputType = KdAllocInputType ();
|
||||||
|
n = 0;
|
||||||
for (i = 0; i < NUM_PS2_NAMES; i++)
|
for (i = 0; i < NUM_PS2_NAMES; i++)
|
||||||
{
|
{
|
||||||
ps2Port = open (Ps2Names[i], 0);
|
ps2Port = open (Ps2Names[i], 0);
|
||||||
if (ps2Port >= 0)
|
if (ps2Port >= 0)
|
||||||
return ps2Port;
|
{
|
||||||
|
if (KdRegisterFd (Ps2InputType, ps2Port, Ps2Read, (void *) i))
|
||||||
|
n++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Ps2Fini (int ps2Port)
|
Ps2Fini (void)
|
||||||
{
|
{
|
||||||
if (ps2Port >= 0)
|
KdUnregisterFds (Ps2InputType, TRUE);
|
||||||
close (ps2Port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KdMouseFuncs Ps2MouseFuncs = {
|
KdMouseFuncs Ps2MouseFuncs = {
|
||||||
Ps2Init,
|
Ps2Init,
|
||||||
Ps2Read,
|
|
||||||
Ps2Fini
|
Ps2Fini
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.2 2000/09/26 15:57:04 tsi Exp $
|
* $XFree86: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.3 2001/05/23 08:56:08 alanh Exp $
|
||||||
*
|
*
|
||||||
* Derived from ps2.c by Jim Gettys
|
* Derived from ps2.c by Jim Gettys
|
||||||
*
|
*
|
||||||
|
@ -97,31 +97,36 @@ char *TsNames[] = {
|
||||||
|
|
||||||
#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
|
#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
|
||||||
|
|
||||||
|
int TsInputType;
|
||||||
|
|
||||||
int
|
int
|
||||||
TsInit (void)
|
TsInit (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int TsPort;
|
int TsPort;
|
||||||
|
|
||||||
|
if (!TsInputType)
|
||||||
|
TsInputType = KdAllocInputType ();
|
||||||
for (i = 0; i < NUM_TS_NAMES; i++)
|
for (i = 0; i < NUM_TS_NAMES; i++)
|
||||||
{
|
{
|
||||||
TsPort = open (TsNames[i], 0);
|
TsPort = open (TsNames[i], 0);
|
||||||
if (TsPort >= 0)
|
if (TsPort >= 0)
|
||||||
return TsPort;
|
{
|
||||||
|
if (KdRegisterFd (TsInputType, TsPort, TsRead))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
perror("Touch screen not found.\n");
|
perror("Touch screen not found.\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TsFini (int tsPort)
|
TsFini (void)
|
||||||
{
|
{
|
||||||
if (tsPort >= 0)
|
KdUnregisterFds (TsInputType, TRUE);
|
||||||
close (tsPort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KdTsFuncs TsFuncs = {
|
KdTsFuncs TsFuncs = {
|
||||||
TsInit,
|
TsInit,
|
||||||
TsRead,
|
|
||||||
TsFini
|
TsFini
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.14 2001/05/29 04:54:10 keithp Exp $ */
|
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.15 2001/06/04 09:45:41 keithp Exp $ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "X.h"
|
#include "X.h"
|
||||||
|
@ -168,25 +168,15 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct _KdMouseFuncs {
|
typedef struct _KdMouseFuncs {
|
||||||
int (*Init) (void);
|
int (*Init) (void);
|
||||||
void (*Read) (int);
|
void (*Fini) (void);
|
||||||
void (*Fini) (int);
|
|
||||||
} KdMouseFuncs;
|
} KdMouseFuncs;
|
||||||
|
|
||||||
#ifdef TOUCHSCREEN
|
|
||||||
typedef struct _KdTsFuncs {
|
|
||||||
int (*Init) (void);
|
|
||||||
void (*Read) (int);
|
|
||||||
void (*Fini) (int);
|
|
||||||
} KdTsFuncs;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct _KdKeyboardFuncs {
|
typedef struct _KdKeyboardFuncs {
|
||||||
void (*Load) (void);
|
void (*Load) (void);
|
||||||
int (*Init) (void);
|
int (*Init) (void);
|
||||||
void (*Read) (int);
|
|
||||||
void (*Leds) (int);
|
void (*Leds) (int);
|
||||||
void (*Bell) (int, int, int);
|
void (*Bell) (int, int, int);
|
||||||
void (*Fini) (int);
|
void (*Fini) (void);
|
||||||
int LockLed;
|
int LockLed;
|
||||||
} KdKeyboardFuncs;
|
} KdKeyboardFuncs;
|
||||||
|
|
||||||
|
@ -542,6 +532,15 @@ KdScreenInfoDispose (KdScreenInfo *si);
|
||||||
void
|
void
|
||||||
KdInitInput(KdMouseFuncs *, KdKeyboardFuncs *);
|
KdInitInput(KdMouseFuncs *, KdKeyboardFuncs *);
|
||||||
|
|
||||||
|
int
|
||||||
|
KdAllocInputType (void);
|
||||||
|
|
||||||
|
Bool
|
||||||
|
KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *closure);
|
||||||
|
|
||||||
|
void
|
||||||
|
KdUnregisterFds (int type, Bool do_close);
|
||||||
|
|
||||||
#ifdef TOUCHSCREEN
|
#ifdef TOUCHSCREEN
|
||||||
void
|
void
|
||||||
KdInitTouchScreen(KdTsFuncs *pTsFuncs);
|
KdInitTouchScreen(KdTsFuncs *pTsFuncs);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.15 2001/05/25 07:44:29 alanh Exp $ */
|
/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.16 2001/05/25 18:40:59 dawes Exp $ */
|
||||||
|
|
||||||
#include "kdrive.h"
|
#include "kdrive.h"
|
||||||
#include "inputstr.h"
|
#include "inputstr.h"
|
||||||
|
@ -37,8 +37,6 @@ static DeviceIntPtr pKdKeyboard, pKdPointer;
|
||||||
|
|
||||||
static KdMouseFuncs *kdMouseFuncs;
|
static KdMouseFuncs *kdMouseFuncs;
|
||||||
static KdKeyboardFuncs *kdKeyboardFuncs;
|
static KdKeyboardFuncs *kdKeyboardFuncs;
|
||||||
static int kdMouseFd = -1;
|
|
||||||
static int kdKeyboardFd = -1;
|
|
||||||
static unsigned long kdEmulationTimeout;
|
static unsigned long kdEmulationTimeout;
|
||||||
static Bool kdTimeoutPending;
|
static Bool kdTimeoutPending;
|
||||||
static int kdBellPitch;
|
static int kdBellPitch;
|
||||||
|
@ -54,7 +52,6 @@ static KdMouseMatrix kdMouseMatrix = {
|
||||||
|
|
||||||
#ifdef TOUCHSCREEN
|
#ifdef TOUCHSCREEN
|
||||||
static KdTsFuncs *kdTsFuncs;
|
static KdTsFuncs *kdTsFuncs;
|
||||||
static int kdTsFd = -1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int kdMinScanCode;
|
int kdMinScanCode;
|
||||||
|
@ -78,17 +75,26 @@ CARD8 kdKeyState[KD_KEY_COUNT/8];
|
||||||
|
|
||||||
#define IsKeyDown(key) ((kdKeyState[(key) >> 3] >> ((key) & 7)) & 1)
|
#define IsKeyDown(key) ((kdKeyState[(key) >> 3] >> ((key) & 7)) & 1)
|
||||||
|
|
||||||
|
#define KD_MAX_INPUT_FDS 8
|
||||||
|
|
||||||
|
typedef struct _kdInputFd {
|
||||||
|
int type;
|
||||||
|
int fd;
|
||||||
|
void (*read) (int fd, void *closure);
|
||||||
|
void *closure;
|
||||||
|
} KdInputFd;
|
||||||
|
|
||||||
|
KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
|
||||||
|
int kdNumInputFds;
|
||||||
|
int kdInputTypeSequence;
|
||||||
|
|
||||||
void
|
void
|
||||||
KdSigio (int sig)
|
KdSigio (int sig)
|
||||||
{
|
{
|
||||||
#ifdef TOUCHSCREEN
|
int i;
|
||||||
if (kdTsFd >= 0)
|
|
||||||
(*kdTsFuncs->Read) (kdTsFd);
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
#endif
|
(*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||||
if (kdMouseFd >= 0)
|
|
||||||
(*kdMouseFuncs->Read) (kdMouseFd);
|
|
||||||
if (kdKeyboardFd >= 0)
|
|
||||||
(*kdKeyboardFuncs->Read) (kdKeyboardFd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -183,17 +189,56 @@ KdRemoveFd (int fd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
KdAllocInputType (void)
|
||||||
|
{
|
||||||
|
return ++kdInputTypeSequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool
|
||||||
|
KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *closure)
|
||||||
|
{
|
||||||
|
if (kdNumInputFds == KD_MAX_INPUT_FDS)
|
||||||
|
return FALSE;
|
||||||
|
kdInputFds[kdNumInputFds].type = type;
|
||||||
|
kdInputFds[kdNumInputFds].fd = fd;
|
||||||
|
kdInputFds[kdNumInputFds].read = read;
|
||||||
|
kdInputFds[kdNumInputFds].closure = closure;
|
||||||
|
++kdNumInputFds;
|
||||||
|
if (kdInputEnabled)
|
||||||
|
KdAddFd (fd);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
KdUnregisterFds (int type, Bool do_close)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < kdNumInputFds;)
|
||||||
|
{
|
||||||
|
if (kdInputFds[i].type == type)
|
||||||
|
{
|
||||||
|
if (kdInputEnabled)
|
||||||
|
KdRemoveFd (kdInputFds[i].fd);
|
||||||
|
if (do_close)
|
||||||
|
close (kdInputFds[i].fd);
|
||||||
|
--kdNumInputFds;
|
||||||
|
for (; i < kdNumInputFds; i++)
|
||||||
|
kdInputFds[i] = kdInputFds[i+1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
KdDisableInput (void)
|
KdDisableInput (void)
|
||||||
{
|
{
|
||||||
#ifdef TOUCHSCREEN
|
int i;
|
||||||
if (kdTsFd >= 0)
|
|
||||||
KdRemoveFd (kdTsFd);
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
#endif
|
KdRemoveFd (kdInputFds[i].fd);
|
||||||
if (kdMouseFd >= 0)
|
|
||||||
KdRemoveFd (kdMouseFd);
|
|
||||||
if (kdKeyboardFd >= 0)
|
|
||||||
KdRemoveFd (kdKeyboardFd);
|
|
||||||
kdInputEnabled = FALSE;
|
kdInputEnabled = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,16 +246,12 @@ void
|
||||||
KdEnableInput (void)
|
KdEnableInput (void)
|
||||||
{
|
{
|
||||||
xEvent xE;
|
xEvent xE;
|
||||||
|
int i;
|
||||||
|
|
||||||
kdInputEnabled = TRUE;
|
kdInputEnabled = TRUE;
|
||||||
#ifdef TOUCHSCREEN
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
if (kdTsFd >= 0)
|
KdAddFd (kdInputFds[i].fd);
|
||||||
KdAddFd (kdTsFd);
|
|
||||||
#endif
|
|
||||||
if (kdMouseFd >= 0)
|
|
||||||
KdAddFd (kdMouseFd);
|
|
||||||
if (kdKeyboardFd >= 0)
|
|
||||||
KdAddFd (kdKeyboardFd);
|
|
||||||
/* reset screen saver */
|
/* reset screen saver */
|
||||||
xE.u.keyButtonPointer.time = GetTimeInMillis ();
|
xE.u.keyButtonPointer.time = GetTimeInMillis ();
|
||||||
NoticeEventTime (&xE);
|
NoticeEventTime (&xE);
|
||||||
|
@ -241,18 +282,10 @@ KdMouseProc(DeviceIntPtr pDevice, int onoff)
|
||||||
pDev->on = TRUE;
|
pDev->on = TRUE;
|
||||||
pKdPointer = pDevice;
|
pKdPointer = pDevice;
|
||||||
if (kdMouseFuncs)
|
if (kdMouseFuncs)
|
||||||
{
|
(*kdMouseFuncs->Init) ();
|
||||||
kdMouseFd = (*kdMouseFuncs->Init) ();
|
|
||||||
if (kdMouseFd >= 0 && kdInputEnabled)
|
|
||||||
KdAddFd (kdMouseFd);
|
|
||||||
}
|
|
||||||
#ifdef TOUCHSCREEN
|
#ifdef TOUCHSCREEN
|
||||||
if (kdTsFuncs)
|
if (kdTsFuncs)
|
||||||
{
|
(*kdTsFuncs->Init) ();
|
||||||
kdTsFd = (*kdTsFuncs->Init) ();
|
|
||||||
if (kdTsFd >= 0 && kdInputEnabled)
|
|
||||||
KdAddFd (kdTsFd);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case DEVICE_OFF:
|
case DEVICE_OFF:
|
||||||
|
@ -261,21 +294,11 @@ KdMouseProc(DeviceIntPtr pDevice, int onoff)
|
||||||
{
|
{
|
||||||
pDev->on = FALSE;
|
pDev->on = FALSE;
|
||||||
pKdPointer = 0;
|
pKdPointer = 0;
|
||||||
if (kdMouseFd >= 0)
|
if (kdMouseFuncs)
|
||||||
{
|
(*kdMouseFuncs->Fini) ();
|
||||||
if (kdInputEnabled)
|
|
||||||
KdRemoveFd (kdMouseFd);
|
|
||||||
(*kdMouseFuncs->Fini) (kdMouseFd);
|
|
||||||
kdMouseFd = -1;
|
|
||||||
}
|
|
||||||
#ifdef TOUCHSCREEN
|
#ifdef TOUCHSCREEN
|
||||||
if (kdTsFd >= 0)
|
if (kdTsFuncs >= 0)
|
||||||
{
|
(*kdTsFuncs->Fini) ();
|
||||||
if (kdInputEnabled)
|
|
||||||
KdRemoveFd (kdTsFd);
|
|
||||||
(*kdTsFuncs->Fini) (kdTsFd);
|
|
||||||
kdTsFd = -1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -354,11 +377,7 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff)
|
||||||
pDev->on = TRUE;
|
pDev->on = TRUE;
|
||||||
pKdKeyboard = pDevice;
|
pKdKeyboard = pDevice;
|
||||||
if (kdKeyboardFuncs)
|
if (kdKeyboardFuncs)
|
||||||
{
|
(*kdKeyboardFuncs->Init) ();
|
||||||
kdKeyboardFd = (*kdKeyboardFuncs->Init) ();
|
|
||||||
if (kdKeyboardFd >= 0 && kdInputEnabled)
|
|
||||||
KdAddFd (kdKeyboardFd);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DEVICE_OFF:
|
case DEVICE_OFF:
|
||||||
case DEVICE_CLOSE:
|
case DEVICE_CLOSE:
|
||||||
|
@ -366,13 +385,8 @@ KdKeybdProc(DeviceIntPtr pDevice, int onoff)
|
||||||
if (pDev->on)
|
if (pDev->on)
|
||||||
{
|
{
|
||||||
pDev->on = FALSE;
|
pDev->on = FALSE;
|
||||||
if (kdKeyboardFd >= 0)
|
if (kdKeyboardFuncs)
|
||||||
{
|
(*kdKeyboardFuncs->Fini) ();
|
||||||
if (kdInputEnabled)
|
|
||||||
KdRemoveFd (kdKeyboardFd);
|
|
||||||
(*kdKeyboardFuncs->Fini) (kdKeyboardFd);
|
|
||||||
kdKeyboardFd = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1354,29 +1368,17 @@ KdWakeupHandler (int screen,
|
||||||
{
|
{
|
||||||
int result = (int) lresult;
|
int result = (int) lresult;
|
||||||
fd_set *pReadmask = (fd_set *) readmask;
|
fd_set *pReadmask = (fd_set *) readmask;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (kdInputEnabled && result > 0)
|
if (kdInputEnabled && result > 0)
|
||||||
{
|
{
|
||||||
if (kdMouseFd >= 0 && FD_ISSET (kdMouseFd, pReadmask))
|
for (i = 0; i < kdNumInputFds; i++)
|
||||||
{
|
if (FD_ISSET (kdInputFds[i].fd, pReadmask))
|
||||||
KdBlockSigio ();
|
{
|
||||||
(*kdMouseFuncs->Read) (kdMouseFd);
|
KdBlockSigio ();
|
||||||
KdUnblockSigio ();
|
(*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
|
||||||
}
|
KdUnblockSigio ();
|
||||||
#ifdef TOUCHSCREEN
|
}
|
||||||
if (kdTsFd >= 0 && FD_ISSET (kdTsFd, pReadmask))
|
|
||||||
{
|
|
||||||
KdBlockSigio ();
|
|
||||||
(*kdTsFuncs->Read) (kdTsFd);
|
|
||||||
KdUnblockSigio ();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (kdKeyboardFd >= 0 && FD_ISSET (kdKeyboardFd, pReadmask))
|
|
||||||
{
|
|
||||||
KdBlockSigio ();
|
|
||||||
(*kdKeyboardFuncs->Read) (kdKeyboardFd);
|
|
||||||
KdUnblockSigio ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (kdTimeoutPending)
|
if (kdTimeoutPending)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue