/************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
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 names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  

DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL 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.

********************************************************/
#ifndef INPUT←H
#define INPUT←H

#include "misc.h"

#define DEVICE←INIT	0
#define DEVICE←ON	1
#define DEVICE←OFF	2
#define DEVICE←CLOSE	3

#define MAP←LENGTH	256
#define DOWN←LENGTH	32	/* 256/8 => number of bytes to hold 256 bits */
#define OTHERCLIENTS(win) ((OtherClientsPtr)(win)->otherClients)
#define NullGrab ((GrabPtr)NULL)
#define PASSIVEGRABS(win) ((GrabPtr)(win)->passiveGrabs)
#define PointerRootWin ((WindowPtr)PointerRoot)
#define NoneWin ((WindowPtr)None)
#define NullDevice ((DevicePtr)NULL)

typedef unsigned long Leds;
typedef struct ←OtherClients *OtherClientsPtr;
typedef struct ←GrabRec *GrabPtr;

typedef int (*DeviceProc)();
typedef void (*ProcessInputProc)();

typedef struct ←DeviceRec {
    pointer	devicePrivate;
    ProcessInputProc processInputProc;
    Bool	on;			/* used by DDX to keep state */
} DeviceRec, *DevicePtr;

typedef struct {
	int		count;
	DevicePtr	*devices;
} DevicesDescriptor;

typedef struct {
    int			click, bell, bell←pitch, bell←duration;
    Bool		autoRepeat;
    unsigned char	autoRepeats[32];
    Leds		leds;
} KeybdCtrl;

typedef struct {
    KeyCode lock;
    KeyCode shiftA, shiftB;
    KeyCode controlA, controlB;
    KeyCode mod1A, mod1B;
    KeyCode mod2A, mod2B;
    KeyCode mod3A, mod3B;
    KeyCode mod4A, mod4B;
    KeyCode mod5A, mod5B;
}  ModifierMapRec, *ModifierMapPtr;

typedef struct {
    KeySym  *map;
    KeyCode minKeyCode,
	    maxKeyCode;
    int     mapWidth;
} KeySymsRec, *KeySymsPtr;

typedef struct {
    int		num, den, threshold;
} PtrCtrl;

extern KeybdCtrl	defaultKeyboardControl;
extern PtrCtrl		defaultPointerControl;

extern int DeliverEvents(/* WindowPtr, xEvent*, int, WindowPtr */);
extern int MaybeDeliverEventsToClient(/*
	WindowPtr, xEvent *, int, Mask, ClientPtr */);

extern DevicePtr AddInputDevice(/* DeviceProc, Bool */);
extern void RegisterPointerDevice();
extern void RegisterKeyboardDevice();

extern void ProcessPointerEvent();
extern void ProcessKeyboardEvent();
extern void ProcessOtherEvent();

extern void InitPointerDeviceStruct();
extern void InitKeyboardDeviceStruct();
extern void InitOtherDeviceStruct();
extern GrabPtr SetDeviceGrab();

extern DevicesDescriptor GetInputDevices();
extern DevicePtr LookupInputDevice();
extern DevicePtr LookupKeyboardDevice();
extern DevicePtr LookupPointerDevice();

extern void CloseDownDevices();
extern int InitAndStartDevices();
extern int NumMotionEvents();

extern void WriteEventToClient();
extern int EventSelectForWindow();
extern int EventSupressForWindow();

#endif /* INPUT←H */