Commit 94368c3b authored by Keith Packard's avatar Keith Packard
Browse files

kdrive: Add iPAQ and Touch screen support

parent 03e36897
......@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.6 2000/09/15 07:25:12 keithp Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.7 2000/09/22 06:25:08 keithp Exp $ */
#include "fbdev.h"
......@@ -382,7 +382,11 @@ fbdevDPMS (ScreenPtr pScreen, int mode)
FbdevPriv *priv = pScreenPriv->card->driver;
#ifdef FBIOPUT_POWERMODE
if (!ioctl (priv->fd, FBIOPUT_POWERMODE, &mode))
if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0)
return TRUE;
#endif
#ifdef FBIOBLANK
if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0)
return TRUE;
#endif
return FALSE;
......
......@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c,v 1.2 1999/12/30 03:03:08 robin Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbinit.c,v 1.4 2000/09/22 06:25:08 keithp Exp $ */
#include <fbdev.h>
......@@ -75,6 +75,9 @@ InitInput (int argc, char **argv)
#else
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
#endif
#ifdef TOUCHSCREEN
kdInitTouchScreen (&TsFuncs);
#endif
}
int
......
XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
XCOMM $XFree86: $
XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/linux/Imakefile,v 1.3 2000/09/22 06:25:09 keithp Exp $
KDRIVE=..
#include "../Kdrive.tmpl"
SRCS = keyboard.c linux.c ps2.c bus.c
#if TouchScreen
TSSRCS = ts.c
TSOBJS = ts.o
#endif
OBJS = keyboard.o linux.o ps2.o bus.o
SRCS = keyboard.c linux.c ps2.c bus.c $(TSSRCS)
OBJS = keyboard.o linux.o ps2.o bus.o $(TSOBJS)
INCLUDES = -I. $(KDINCS)
......
/*
* Id: ts.c,v 1.1 1999/11/02 03:54:46 keithp Exp $
*
* Derived from ps2.c by Jim Gettys
*
* Copyright © 1999 Keith Packard
* Copyright © 2000 Compaq Computer Corporation
*
* 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 or Compaq not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard and Compaq makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD AND COMPAQ DISCLAIM 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.
*/
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "kdrive.h"
#include "Xpoll.h"
#include <sys/ioctl.h>
#include <linux/h3600_ts.h> /* touch screen events */
void
TsRead (int tsPort)
{
TS_EVENT event;
long buf[3];
int n;
long pressure;
long x, y;
unsigned long flags;
unsigned long buttons;
n = Ps2ReadBytes (tsPort, (char *) &event,
sizeof (event), sizeof (event));
if (n == sizeof (event))
{
if (event.pressure)
{
flags = KD_BUTTON_1;
x = event.x;
y = event.y;
}
else {
flags = KD_MOUSE_DELTA;
x = 0;
y = 0;
}
KdEnqueueMouseEvent (flags, x, y);
}
}
char *TsNames[] = {
"/dev/ts",
"/dev/h3600_ts" /* temporary name; note this code can try
to open more than one device */
};
#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
int
TsInit (void)
{
int i;
int TsPort;
for (i = 0; i < NUM_TS_NAMES; i++)
{
TsPort = open (TsNames[i], 0);
if (TsPort >= 0)
return TsPort;
}
perror("Touch screen not found.\n");
exit (1);
}
void
TsFini (int tsPort)
{
if (tsPort >= 0)
close (tsPort);
}
KdTsFuncs TsFuncs = {
TsInit,
TsRead,
TsFini
};
......@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.6 2000/08/26 00:24:38 keithp Exp $ */
/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.8 2000/09/22 06:25:29 keithp Exp $ */
#include <stdio.h>
#include "X.h"
......@@ -167,6 +167,14 @@ typedef struct _KdMouseFuncs {
void (*Fini) (int);
} KdMouseFuncs;
#ifdef TOUCHSCREEN
typedef struct _KdTsFuncs {
int (*Init) (void);
void (*Read) (int);
void (*Fini) (int);
} KdTsFuncs;
#endif
typedef struct _KdKeyboardFuncs {
void (*Load) (void);
int (*Init) (void);
......@@ -491,6 +499,11 @@ KdScreenInfoDispose (KdScreenInfo *si);
void
KdInitInput(KdMouseFuncs *, KdKeyboardFuncs *);
#ifdef TOUCHSCREEN
void
KdInitTouchScreen(KdTsFuncs *pTsFuncs);
#endif
void
KdEnqueueKeyboardEvent(unsigned char scan_code,
unsigned char is_up);
......@@ -538,6 +551,9 @@ ProcessInputEvents ();
extern KdMouseFuncs Ps2MouseFuncs;
extern KdMouseFuncs BusMouseFuncs;
#ifdef TOUCHSCREEN
extern KdTsFuncs TsFuncs;
#endif
extern KdKeyboardFuncs LinuxKeyboardFuncs;
extern KdOsFuncs LinuxFuncs;
......
......@@ -26,7 +26,9 @@
#include "kdrive.h"
#include "inputstr.h"
#define XK_PUBLISHING
#include <X11/keysym.h>
#include <X11/XF86keysym.h>
#include "kkeymap.h"
#include <signal.h>
#include <stdio.h>
......@@ -48,6 +50,11 @@ static KdMouseMatrix kdMouseMatrix = {
0, 1, 0
};
#ifdef TOUCHSCREEN
static KdTsFuncs *kdTsFuncs;
static int kdTsFd = -1;
#endif
int kdMinScanCode;
int kdMaxScanCode;
int kdMinKeyCode;
......@@ -72,6 +79,10 @@ CARD8 kdKeyState[KD_KEY_COUNT/8];
void
KdSigio (int sig)
{
#ifdef TOUCHSCREEN
if (kdTsFd >= 0)
(*kdTsFuncs->Read) (kdTsFd);
#endif
if (kdMouseFd >= 0)
(*kdMouseFuncs->Read) (kdMouseFd);
if (kdKeyboardFd >= 0)
......@@ -173,6 +184,10 @@ KdRemoveFd (int fd)
void
KdDisableInput (void)
{
#ifdef TOUCHSCREEN
if (kdTsFd >= 0)
KdRemoveFd (kdTsFd);
#endif
if (kdMouseFd >= 0)
KdRemoveFd (kdMouseFd);
if (kdKeyboardFd >= 0)
......@@ -186,6 +201,10 @@ KdEnableInput (void)
xEvent xE;
kdInputEnabled = TRUE;
#ifdef TOUCHSCREEN
if (kdTsFd >= 0)
KdAddFd (kdTsFd);
#endif
if (kdMouseFd >= 0)
KdAddFd (kdMouseFd);
if (kdKeyboardFd >= 0)
......@@ -225,6 +244,14 @@ KdMouseProc(DeviceIntPtr pDevice, int onoff)
if (kdMouseFd >= 0 && kdInputEnabled)
KdAddFd (kdMouseFd);
}
#ifdef TOUCHSCREEN
if (kdTsFuncs)
{
kdTsFd = (*kdTsFuncs->Init) ();
if (kdTsFd >= 0 && kdInputEnabled)
KdAddFd (kdTsFd);
}
#endif
break;
case DEVICE_OFF:
case DEVICE_CLOSE:
......@@ -239,6 +266,15 @@ KdMouseProc(DeviceIntPtr pDevice, int onoff)
(*kdMouseFuncs->Fini) (kdMouseFd);
kdMouseFd = -1;
}
#ifdef TOUCHSCREEN
if (kdTsFd >= 0)
{
if (kdInputEnabled)
KdRemoveFd (kdTsFd);
(*kdTsFuncs->Fini) (kdTsFd);
kdTsFd = -1;
}
#endif
}
break;
}
......@@ -364,6 +400,35 @@ KdInitAutoRepeats (void)
}
}
const KdKeySymModsRec kdKeySymMods[] = {
XK_Control_L, ControlMask,
XK_Control_R, ControlMask,
XK_Shift_L, ShiftMask,
XK_Shift_R, ShiftMask,
XK_Caps_Lock, LockMask,
XK_Shift_Lock, LockMask,
XK_Alt_L, Mod1Mask,
XK_Alt_R, Mod1Mask,
XK_Meta_L, Mod1Mask,
XK_Meta_R, Mod1Mask,
XK_Num_Lock, Mod2Mask,
XK_Super_L, Mod3Mask,
XK_Super_R, Mod3Mask,
XK_Hyper_L, Mod3Mask,
XK_Hyper_R, Mod3Mask,
XK_Mode_switch, Mod4Mask,
#ifdef TOUCHSCREEN
/* iPAQ specific hacks */
XF86XK_Start, ControlMask,
XK_Menu, ShiftMask,
XF86XK_Calendar, LockMask,
XK_telephone, Mod1Mask,
XF86XK_AudioRecord, Mod2Mask,
#endif
};
#define NUM_SYM_MODS (sizeof(kdKeySymMods) / sizeof(kdKeySymMods[0]))
static void
KdInitModMap (void)
{
......@@ -371,6 +436,7 @@ KdInitModMap (void)
int row;
int width;
KeySym *syms;
int i;
width = kdKeySyms.mapWidth;
for (key_code = kdMinKeyCode; key_code <= kdMaxKeyCode; key_code++)
......@@ -379,37 +445,10 @@ KdInitModMap (void)
syms = kdKeymap + (key_code - kdMinKeyCode) * width;
for (row = 0; row < width; row++, syms++)
{
switch (*syms) {
case XK_Control_L:
case XK_Control_R:
kdModMap[key_code] |= ControlMask;
break;
case XK_Shift_L:
case XK_Shift_R:
kdModMap[key_code] |= ShiftMask;
break;
case XK_Caps_Lock:
case XK_Shift_Lock:
kdModMap[key_code] |= LockMask;
break;
case XK_Alt_L:
case XK_Alt_R:
case XK_Meta_L:
case XK_Meta_R:
kdModMap[key_code] |= Mod1Mask;
break;
case XK_Num_Lock:
kdModMap[key_code] |= Mod2Mask;
break;
case XK_Super_L:
case XK_Super_R:
case XK_Hyper_L:
case XK_Hyper_R:
kdModMap[key_code] |= Mod3Mask;
break;
case XK_Mode_switch:
kdModMap[key_code] |= Mod4Mask;
break;
for (i = 0; i < NUM_SYM_MODS; i++)
{
if (*syms == kdKeySymMods[i].modsym)
kdModMap[key_code] |= kdKeySymMods[i].modbit;
}
}
}
......@@ -454,6 +493,14 @@ KdInitInput(KdMouseFuncs *pMouseFuncs,
#endif
}
#ifdef TOUCHSCREEN
void
KdInitTouchScreen(KdTsFuncs *pTsFuncs)
{
kdTsFuncs = pTsFuncs;
}
#endif
/*
* Middle button emulation state machine
*
......@@ -1287,6 +1334,14 @@ KdWakeupHandler (int screen,
(*kdMouseFuncs->Read) (kdMouseFd);
KdUnblockSigio ();
}
#ifdef TOUCHSCREEN
if (kdTsFd >= 0 && FD_ISSET (kdTsFd, pReadmask))
{
KdBlockSigio ();
(*kdTsFuncs->Read) (kdTsFd);
KdUnblockSigio ();
}
#endif
if (kdKeyboardFd >= 0 && FD_ISSET (kdKeyboardFd, pReadmask))
{
KdBlockSigio ();
......
......@@ -27,8 +27,8 @@
* live in this header file.
*/
#ifndef _KDKEYMP_H
#define _KDKEYMP_H
#ifndef _KKEYMAP_H
#define _KKEYMAP_H
/* Offset of MIN_SCANCODE to 8 (X minimum scancode value) */
#define KD_KEY_OFFSET (8 - kdMinScanCode)
......@@ -50,4 +50,9 @@ extern CARD8 kdModMap[MAP_LENGTH];
extern KeySymsRec kdKeySyms;
#endif /* _WINKEYMP_H */
typedef struct {
KeySym modsym;
int modbit;
} KdKeySymModsRec;
#endif /* _KKEYMAP_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment