//

//CDInputManager.h Direct input manager class


/*******************************************************
//
//	Name: CDInputManager.h
//
//	Author: Dave Ratti
//
//	Date:3-11-00
//
//	Modified: Constantly
//
//	Notes: This class holds everything we need for
//	using Direct Input. It will handle the mouse
//  Keyboard and joystick. This class will be 
//	inheritid by CInputManager along with CTimer and CNetMessage
//
//
*********************************************************/
//watch for double include
#ifndef CDINPUTMANAGER_H
#define CDINPUTMANAGER_H

#include "singleton.h"

#define DIRECTINPUT_VERSION 0x0500
#include <dinput.h>
#include "CCommand.h"
#include "StringC.h"



///////////////////////////////////////////////////////////
#define g_DInputManager CDInputManager::GetSingleton()


class CDInputManager: public Singleton <CDInputManager>
{
	
	public:
	
	CDInputManager();
	~CDInputManager();
	
	void GetInput();								//this will call GetKeyboardInput, GetMouseInput, GetJoyInput
	UCHAR* GetKeystate(){	return Keystate; }
	DIMOUSESTATE GetMousestate(){ return Mousestate; }

	POINT				realMousePoint;
	POINT				mousePoint;
	POINT				offSet;
	void offsetMouse(POINT p);

	bool RightMouseDown();
	bool LeftMouseDown();

	
	STRINGC getText();	
	void clearText();
	int nextchar;
	
	char textBuffer[250];

	
	CCommand TextCommands[DIK_SLASH-DIK_1+1];
	CCommand SpaceCommand;

	
	
	protected:

	int scan2ascii(DWORD scancode, USHORT* result);



	LPDIRECTINPUT					lpdi;			//main direct input interface

	//Devices

	LPDIRECTINPUTDEVICE				lpdikey;		//interface for keyboard
	LPDIRECTINPUTDEVICE				lpdimouse;		//interface for mouse

	//State
	UCHAR				Keystate[256];							//contains keyboard state table. no structure needed, just a simple array
	DIMOUSESTATE		Mousestate;
	
	


	//methods//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	void GetKeyboardInput();
	void GetMouseInput();


	void AddChar(DWORD c);
	
	
};

#endif