//////////////////////////////////////////////////////////////////////////////
//
// AVP_PS3_External_Camera.cpp
//
// Created by Catalin Arsenescu - 14/11/07
//
// Copyright (c) 2007 Rebellion. All rights reserved.
//
//		PS3-specific external camera functions.
//
//////////////////////////////////////////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header.
#include "Camera/AVP_External_Camera.h"

// Asura headers
#include "Input/Asura_ControlManager.h"
#include "Input/Asura_ControlMap.h"

// Asura Xbox 360
#include "Input/Asura_PlatformInput.h"

// Game headers
#include "Core/AVP_Game_Core.h"


// Debugvars
DEBUGVAR float dbg_fTiltRampUpTime = 0.25f;
DEBUGVAR float dbg_fTiltRampDownTime = 0.05f;
DEBUGVAR float dbg_fTiltExponent = 2.0f;

DEBUGVAR float dbg_fTurnRampUpTime = 0.5f;
DEBUGVAR float dbg_fTurnRampDownTime = 0.10f;

/////////////////////
// Input functions //
/////////////////////

void AVP_External_Camera::Platform_FillControlMap()
{
	if (!m_pxControlMap) { return; }

	// Just do pad 1

	Asura_ControlMap& xMap = *m_pxControlMap;

	xMap.AddAxisMapping(AVP_External_Camera::LOOK_UP_DOWN, ASURA_AXIS_PAD1_RSTICK_V, -1.0f, &dbg_fTiltRampUpTime, &dbg_fTiltRampDownTime, ASURA_CONTROLMAPPING_AXIS_MASK_ALL, &dbg_fTiltExponent);
	xMap.AddAxisMapping(AVP_External_Camera::LOOK_LEFT_RIGHT, ASURA_AXIS_PAD1_RSTICK_H, 1.0f, &dbg_fTurnRampUpTime, &dbg_fTurnRampDownTime, ASURA_CONTROLMAPPING_AXIS_MASK_ALL, &dbg_fTiltExponent);

	xMap.AddAxisMapping(AVP_External_Camera::MOVE_FORWARDS_BACKWARDS, ASURA_AXIS_PAD1_LSTICK_V);
	xMap.AddAxisMapping(AVP_External_Camera::MOVE_LEFT_RIGHT, ASURA_AXIS_PAD1_LSTICK_H);
	xMap.AddKeyMapping(AVP_External_Camera::MOVE_UP_DOWN, ASURA_PS3_KEYID_PAD1_R2, Asura_ControlMapping::ON_PRESS, -1.0f);
	xMap.AddKeyMapping(AVP_External_Camera::MOVE_UP_DOWN, ASURA_PS3_KEYID_PAD1_L2, Asura_ControlMapping::ON_PRESS, 1.0f);

	xMap.AddKeyMapping(AVP_External_Camera::RESPAWN, ASURA_PS3_KEYID_PAD1_CROSS, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_MENU, ASURA_PS3_KEYID_PAD1_START, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
	xMap.AddKeyMapping(AVP_External_Camera::SCOREBOARD, ASURA_PS3_KEYID_PAD1_SELECT, Asura_ControlMapping::ON_PRESS);
}

#ifdef AVP_SECOND_CONTROL_FLY_CAM
void AVP_External_Camera::Platform_FillSecondControlMap()
{
	if (!m_pxControlMap) { return; }

	// Setting the controls for the second controler when we are using it as a flycam

	Asura_ControlMap& xMap = *m_pxControlMap;

	xMap.AddAxisMapping(AVP_External_Camera::LOOK_UP_DOWN, ASURA_AXIS_PAD2_RSTICK_V, -1.0f, &dbg_fTiltRampUpTime, &dbg_fTiltRampDownTime, ASURA_CONTROLMAPPING_AXIS_MASK_ALL, &dbg_fTiltExponent);
	xMap.AddAxisMapping(AVP_External_Camera::LOOK_LEFT_RIGHT, ASURA_AXIS_PAD2_RSTICK_H, 1.0f, &dbg_fTurnRampUpTime, &dbg_fTurnRampDownTime, ASURA_CONTROLMAPPING_AXIS_MASK_ALL, &dbg_fTiltExponent);

	xMap.AddAxisMapping(AVP_External_Camera::MOVE_FORWARDS_BACKWARDS, ASURA_AXIS_PAD2_LSTICK_V);
	xMap.AddAxisMapping(AVP_External_Camera::MOVE_LEFT_RIGHT, ASURA_AXIS_PAD2_LSTICK_H);
	xMap.AddKeyMapping(AVP_External_Camera::MOVE_UP_DOWN, ASURA_PS3_KEYID_PAD2_R2, Asura_ControlMapping::ON_PRESS, -1.0f);
	xMap.AddKeyMapping(AVP_External_Camera::MOVE_UP_DOWN, ASURA_PS3_KEYID_PAD2_L2, Asura_ControlMapping::ON_PRESS, 1.0f);

	xMap.AddKeyMapping(AVP_External_Camera::SCREENSHOT, ASURA_PS3_KEYID_PAD2_START, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_FREEZE, ASURA_PS3_KEYID_PAD2_CROSS, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_FLY_CAM, ASURA_PS3_KEYID_PAD2_CIRCLE, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_RENDER_ALL, ASURA_PS3_KEYID_PAD2_SQUARE, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_TIME, ASURA_PS3_KEYID_PAD2_L1, Asura_ControlMapping::ON_DEBOUNCED_PRESS, -0.1f);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_TIME, ASURA_PS3_KEYID_PAD2_R1, Asura_ControlMapping::ON_DEBOUNCED_PRESS, 0.1f);
	xMap.AddKeyMapping(AVP_External_Camera::TOGGLE_WIREFRAME, ASURA_PS3_KEYID_PAD2_TRIANGLE, Asura_ControlMapping::ON_DEBOUNCED_PRESS);
}
#endif

/// End of file. ///
