// -----------------------------------------------------------------------
/*
	\author: Jaap Suter
   
	Copyright (C) Electronic Arts Canada Inc. 2002.  All rights reserved.	
*/
// -----------------------------------------------------------------------

/*! \file */

#ifndef REVEAL_REAL_5_INPUT_STATE_IMPL_PS2_H
#define REVEAL_REAL_5_INPUT_STATE_IMPL_PS2_H

#ifdef NGC

#include <stddef.h>
#include <assert.h>
#include <realinput.h>

#include <dolphin/pad.h>
extern PADStatus gPadData[4];

namespace Reveal {
	namespace Impl {

// -----------------------------------------------------------------------
/*!
	\brief Simple Real 5 implementation of the InputState 
		   class for the NGC
*/
// -----------------------------------------------------------------------
class RealInputImpl
{
public:

	RealInputImpl( size_t padId ) : mPadId( padId ) {}

	int DoMouseRelX() const 
	{ 
		return gPadData[ mPadId ].stickX;
	}

	int	DoMouseRelY() const 
	{ 
		return -gPadData[ mPadId ].stickY;
	}

	Reveal::uint32_t DoDown() const 
	{ 
		Reveal::uint32_t down = 0;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_A 		) down |= InputState::CONFIRM;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_B		) down |= InputState::BACK;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_X		) down |= InputState::AUX_1;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_Y		) down |= InputState::AUX_2;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_LEFT	) down |= InputState::LEFT;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_RIGHT	) down |= InputState::RIGHT;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_UP		) down |= InputState::UP;
		if ( gPadData[ mPadId ].button & PAD_BUTTON_DOWN	) down |= InputState::DOWN;
		if ( gPadData[ mPadId ].button & PAD_TRIGGER_Z		) down |= InputState::SELECT;		
		return down;
	}

	int DoAuxRelX() const 
	{ 
		return gPadData[ mPadId ].substickX;
	}

	int	DoAuxRelY() const 
	{ 
		return gPadData[ mPadId ].substickY;
	}

	int	DoLeftShoulder() const 
	{ 
		return -gPadData[ mPadId ].triggerLeft;
	}
	
	int	DoRightShoulder() const 
	{ 
		return -gPadData[ mPadId ].triggerRight;
	}

private:		
	size_t mPadId;
};

	} // Namespace Impl;
} // Namespace Reveal;

#endif
#endif

