#include "X.h"
#define NEED_EVENTS
#include "Xproto.h"
#include "misc.h"
#include "window.h"
#include "dix.h"
#include "input.h"
#include "inputstr.h"
#include "ibmmouse.h"
#include "ibmfuncs.h"
#include "funcs.h"

extern void mouseProcessInput(void);

u_long TimeLastInput;
extern u_char input_ready;

void
ProcessInputEvents()
{
	if (input_ready & INPUT_KBD)
		kbdProcessInput();
	if (input_ready & INPUT_MOUSE)
		mouseProcessInput();
}

void
InitInput(argc, argv)
int argc;
char **argv;
{
	DevicePtr dptr;

#ifdef notdef
	if (!pshared)
		if (glue_open())
			FatalError("Can't access device memory.");
#endif
	argc = argc;
	argv = argv;
	dptr = AddInputDevice(kbdproc, TRUE);
	if (dptr)
		RegisterKeyboardDevice(dptr);

	dptr = AddInputDevice(mouseproc, TRUE);
	if (dptr)
		RegisterPointerDevice(dptr);
	TimeLastInput = GetTimeInMillis();
}

u_long
TimeSinceLastInputEvent()
{

	return GetTimeInMillis() - TimeLastInput;
}
