//CCommand

//includes///////////////////////////////


#include <winsock2.h>
#include <windows.h>   // include important windows stuff
#include <windowsx.h> 
#include <mmsystem.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h> 
#include <math.h>
#include <io.h>
#include <fcntl.h>



#include "CCommand.h"
#include "CDInputManager.h"

void CCommand::Init(int key)
{

	Key = key;
	mustRelease=true;
	Mouse=false;
	//lastAction=

}

void CCommand::Init(int key, bool _Mouse)
{

	Key = key;
	mustRelease=true;
	Mouse=_Mouse;
	//lastAction=

}

bool CCommand::isActive()
{
	
	UCHAR* keystate = g_DInputManager.GetKeystate();
	DIMOUSESTATE mstate = g_DInputManager.GetMousestate();
	bool active=false;



	//keyboard command

	if((Mouse==false && keystate[Key]) || (Mouse==true && mstate.rgbButtons[Key]))
	{
		if(mustRelease==true)
		{
			if(isReleased==true)
				active=true;
		}
		else
		{
			//do the timer thing
			active=true;
		}

		isReleased=false;

	}
	else
	{	
		isReleased=true;
		
	}
	

	return active;


}