//
// Asura_DirectInput.cpp
//
// Created by Kevin Lea - 05/10/2001 16:40:18
// 
// Copyright (C) 2001 Rebellion, All Rights Reserved.
//

#include "Core/Asura.h"

#include "Input/Asura_DirectInput.h"
#include "Core/Asura_Windows.h"

DirectInput_Object* Asura_DirectInput::DIObject = NULL;

// (AAM - 14.01.2004) now returns a bool indicating success
bool Asura_DirectInput::Initialise(void)
{
	HRESULT hr = DirectInput8Create
				(
					Asura_Windows::GetWindowhInstance(),
					DIRECTINPUT_VERSION,
					IID_IDirectInput8,
					(void**)&DIObject,
					NULL
				); 

	if FAILED(hr) 
	{ 
		// DirectInput not available; take appropriate action 

		// (AAM - 14.01.2004) return false
		// may want to have a Windows message-based fallback, but probably not worth it

		return false;
	} 

	return true;
}

void Asura_DirectInput::Shutdown(void)
{
	if (DIObject)
	{
		DIObject->Release();
		DIObject = NULL;
	}
}
