#pragma once
#define DIRECTINPUT_VERSION 0x0300
#include <dinput.h>
#include <time.h>

class ActivityTracker
{
public:
	ActivityTracker(void);
	~ActivityTracker(void);

	void Init(HINSTANCE hInstance, HWND hWnd);
	void Start();
	void Stop();
	void Loop();

	int GetTimeSinceLastEvent();

private:
	BOOL            InitInput(void);
	static BOOL CALLBACK DIEnumDevicesProc(LPCDIDEVICEINSTANCE lpddi, 
														LPVOID pvRef);
	void            CleanupInput(void);
	BOOL            ReacquireInputDevices(void);

	// the objects
	time_t TimeOfLastMouse;
	time_t TimeOfLastKey;
	int done;
	HINSTANCE hInstance;
	HWND hMainWindow;
	HANDLE hDoneEvent, hMouseEvent, hKeyEvent;

	static LPDIRECTINPUT  lpdi;            
	LPDIRECTINPUTDEVICE   lpdiMouse;   
	LPDIRECTINPUTDEVICE   lpdiKeyboard;   

	BOOL                  MouseAcquired; 
	BOOL                  KeyboardAcquired;   

	static GUID           MouseGUID;
	static GUID           KeyboardGUID;

	static BOOL           MouseFound;
	static BOOL           KeyboardFound;	
};
