/*
 * @(#)sunevq.h 1.1 90/11/16
 */

#ifndef _sunevq_h
#define _sunevq_h

/* these should be moved after all the system header files
 * There is currently a conflict with input.h declaring
 * event_action as an enumerated type, and sunwindow/win_input.h
 * defining event_action as a macro. Therefore, input.h must
 * be included first.  someday.....
 */
#include <NeWS/PostScript.h>
#include <NeWS/input.h>
#include <NeWS/environ.h>

extern TimeStamp time_longTimeOut;

#define	INPBUFSIZE	256
#define MAX_ENTRIES 10
#define DEFAULTKBDDEV   "/dev/kbd"

/*
 * KIOCLAYOUT, etc. are only defined on 4.1 systems.
 * This allows us to build on 4.0.x
 */

#ifndef KIOCLAYOUT
#define KIOCLAYOUT	_IOR(k, 20, int)
#define KIOCSLED        _IOW(k, 14, char)
#define KIOCGLED        _IOR(k, 15, char)
#define LED_NUM_LOCK	0x01
#define LED_COMPOSE	0x02
#define LED_SCROLL_LOCK	0x04
#define LED_CAPS_LOCK	0x08
#endif

struct xnews_wsq_node {
    struct inputevent		wsqn_event;
    SCREENINFO			wsqn_screen;
    short			wsqn_prev;	/* Not currently used */
    short			wsqn_next;	/* Not currently used */
    char			devid;		/* Device Id */
};

struct xnews_wsq {
    struct xnews_wsq_node 	wsq_events[INPBUFSIZE];
    short			wsq_first;	/* Not currently used */
    short			wsq_last;
    int				wsq_kbdtrans;
};

enum kbd_translation {
    UNENCODED_KEYBOARD, NORMAL_KEYBOARD
};

struct  hosts_entry {
  char inet_num[20];
  char name[40];
};

struct  pos_struct {
    int x, y;
    int fd;
};

struct InputDevStruct {		/* Dynamic Input Device structure */
    int		fd;			/* file descriptor of device */
    char	devid;			/* Device Identification */
    char	devname[32];		/* eg. "/dev/kbd", "/dev/mouse" */
    char	libname[32];		/* shared library name */
    void	*dlhandle;		/* jw - not sure if this is useful */
    int		(*InitInputDev)();	/* Initialize device and library */
    int		(*InputPending)();	/* returns TRUE if pending input */
    void	(*ReadInputDev)();	/* sorts and stuffs events onto q */
    int		(*ProcessInput)();	/* process and send event up */
    int		(*CntrlInputDev)();	/* miscellaneous control */
    int		(*TerminateInputDev)();	/* clean up and close down device */
    caddr_t	privatedata;		/* just in case... */
};

/* jw - we should probably come up with something better than this,
 *	but for the time being, let's just get it working.
 */
#define MAXINPUTDEVS	8	/* PFA */
extern struct InputDevStruct  InputDevice[MAXINPUTDEVS];
extern int InputDevCount;

/* Hardcoded Device IDs */
#define	PRIVDEV		0	/* Used for sunwindowdev or evq device */
#define MSDEV		1	/* Mouse will always be entry 1 */
#define KBDDEV		2	/* Keyboard will always be entry 2 */

/* these routines are declared in osi_screen.c and defined by any one of
 * the shared libraries libSunWIN, libSunEVQ, libSunVUID, etc.
 */
extern void (*ringbell)();
extern int  (*svenv_get)();
extern void (*svenv_setserver)();
extern void (*lockdevice)();
extern void (*unlockdevice)();
extern void (*update_colors)();
extern void (*window_acquire)();
extern int  (*setscreenposition)();
extern void (*setmouseposition)();
extern int  (*setmstranslation)();
extern void (*startkbdandms)();
extern void (*enable_kbd_input)();
extern void (*enable_pick_input)();

#ifdef DEBUG
#	define PrintEventCode(a, b)		PrintEventCodeFunc(a, b)
#	define TraceEvent(cond, code)		if (cond) code
	extern int PrintEventCodeIsOn;
#else
#	define PrintEventCode(a, b)
#	define TraceEvent(cond, code) 
#endif


#endif /* _sunevq_h */

