#include "Core/Asura.h"

#ifdef AVP_USE_INPUT_SIMULATOR

// Asura
#include "Core/Asura_UserInput.h"
#include "Input/Asura_PlatformInput.h"

// AVP
#include "InputSimulator/AVP_InputSimulator_System.h"

void AVP_InputSimulator_System::Platform_SetFireButton( const bool bFire, u_char* ucCurrentInput )
{
	// Xbox360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_R_TRIGGER] = (bFire) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetSecondaryFireButton( const bool bFire, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_L_TRIGGER] = (bFire) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetTurnAxisHorizontal( const float fValue, float* pfAxisValue )
{
	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_RSTICK_H] = fValue * 0.2f;
}

void AVP_InputSimulator_System::Platform_SetTurnAxisVertical( const float fValue, float* pfAxisValue )
{
	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_RSTICK_V] = fValue * 0.2f;
}

void AVP_InputSimulator_System::Platform_SetMoveForwardsButton( const bool bMove, u_char* ucCurrentInput, float* pfAxisValue )
{
	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_LSTICK_V] = (bMove) ? 1.0f : 0.0f;
}

void AVP_InputSimulator_System::Platform_SetMoveBackwardsButton( const bool bMove, u_char* ucCurrentInput, float* pfAxisValue )
{
	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_LSTICK_V] = (bMove) ? -1.0f : 0.0f;
}

void AVP_InputSimulator_System::Platform_SetMoveLeftButton( const bool bMove, u_char* ucCurrentInput, float* pfAxisValue ) 
{
	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_LSTICK_H] = (bMove) ? -1.0f : 0.0f;
}

void AVP_InputSimulator_System::Platform_SetMoveRightButton( const bool bMove, u_char* ucCurrentInput, float* pfAxisValue )
{

	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_LSTICK_H] = (bMove) ? 1.0f : 0.0f;
}

void AVP_InputSimulator_System::Platform_SetJumpButton( const bool bJump, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_A] = (bJump) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetFocusMode( const bool bFocus, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_L_TRIGGER] = (bFocus) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetCloakButton( const bool bCloak, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_B] = (bCloak) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetSprintButton( const bool bSprint, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_L_THUMB] = (bSprint) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetStanceButton( const bool bChangeStance, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_L_BUMPER] = (bChangeStance) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetWalkButton( const bool bWalk, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_Y] = (bWalk) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetReloadButton(const bool bReload, u_char* ucCurrentInput )
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_X] = (bReload) ? 255 : 0;
}

void AVP_InputSimulator_System::Platform_SetDownButton(const bool bDown, u_char *ucCurrentInput, float* pfAxisValue)
{
	// XBOX360 Implementation
	pfAxisValue[ASURA_XBOX360_AXISID_PAD1_LSTICK_V] = (bDown) ? -1.0f : 0.0f;
}

void AVP_InputSimulator_System::Platform_SetAcceptButton(const bool bAccept, u_char *ucCurrentInput)
{
	// XBOX360 Implementation
	ucCurrentInput[ASURA_XBOX360_KEYID_PAD1_A] = (bAccept) ? 255 : 0;
}

#endif // AVP_USE_INPUT_SIMULATOR
