/************************************************************
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 NullGrab ((GrabPtr)NULL)
#define PointerRootWin ((WindowPtr)PointerRoot)
#define NoneWin ((WindowPtr)None)
#define NullDevice ((DevicePtr)NULL)

#ifndef FollowKeyboard
#define FollowKeyboard 		3
#endif
#ifndef FollowKeyboardWin
#define FollowKeyboardWin  ((WindowPtr) FollowKeyboard)
#endif
#ifndef RevertToFollowKeyboard
#define RevertToFollowKeyboard	3
#endif

typedef unsigned long Leds;
typedef struct _OtherClients *OtherClientsPtr;
typedef struct _InputClients *InputClientsPtr;
typedef struct _GrabRec *GrabPtr;

typedef void (*ProcessInputProc)();

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

typedef int (*DeviceProc)(DevicePtr, int);

typedef struct _KeybdCtrl {
    int			click, bell, bell_pitch, bell_duration;
    Bool		autoRepeat;
    unsigned char	autoRepeats[32];
    Leds		leds;
} KeybdCtrl;

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

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

typedef struct _IntegerCtrl {
    int         resolution, min_value, max_value;
    int         integer_displayed;
} IntegerCtrl;

typedef struct _StringCtrl {
    int         max_symbols, num_symbols_supported;
    int         num_symbols_displayed;
    KeySym      *symbols;
} StringCtrl;

typedef struct _BellCtrl {
    int         percent, pitch, duration;
} BellCtrl;

typedef struct _LedCtrl {
    Leds        led_values;
} LedCtrl;

extern KeybdCtrl	_near defaultKeyboardControl;
extern PtrCtrl		_near defaultPointerControl;

extern DevicePtr AddInputDevice();
extern Bool EnableDevice();
extern Bool DisableDevice();
extern void RegisterPointerDevice();
extern void RegisterKeyboardDevice();
extern DevicePtr LookupKeyboardDevice();
extern DevicePtr LookupPointerDevice();

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

extern void InitInput(int, char **);

extern Bool InitKeyClassDeviceStruct();
extern Bool InitButtonClassDeviceStruct();
extern Bool InitFocusClassDeviceStruct();
extern Bool InitPtrFeedbackClassDeviceStruc();
extern Bool InitValuatorClassDeviceStruct();
//extern Bool InitPointerDeviceStruct();
//extern Bool InitKeyboardDeviceStruct();

extern void CloseDownDevices();

extern void WriteEventsToClient();
extern void ProcessInputEvents(void);

#endif /* INPUT_H */
