/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/sgx/input/controller.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/input/input.hpp"

CSGXInputManager::CControllerJoypad::CControllerJoypad()
{
	m_Valid = FALSE;
}

CSGXInputManager::CControllerJoypad::CControllerJoypad(tUINT32 idx)
{
SGX_UNUSED(idx);
	m_Valid = FALSE;
	m_pRumble = new CSGXRumbleDevice();
}

tBOOL 
CSGXInputManager::CControllerJoypad::isPresent() const {
	return m_Valid;
}

void 
CSGXInputManager::CControllerJoypad::reset()
{
	tMEM_SIZE i;

	for(i=0;i<SGX_MAXINP_BUTTONS;i++)
	{
		m_Buttons[i].reset();
	}

	for(i=0;i<SGX_MAXINP_STICKS;i++)
	{
		m_Sticks[i].reset();
	}
}

void 
CSGXInputManager::CControllerJoypad::suspend(const tBOOL suspend) {
	m_pRumble->suspend(suspend);
}

void 
CSGXInputManager::CControllerJoypad::stopAllRumbles() {
	m_pRumble->stopAllRumbles();
}

void 
CSGXInputManager::CControllerJoypad::update(const tREAL32 telaps, CSGXInputManager::CControllerJoypad &genericResult)
{
	tMEM_SIZE i;

	sgxMemcpy(&genericResult, this, sizeof(genericResult));

	for(i=0;i<SGX_MAXINP_BUTTONS;i++)
	{
		m_Buttons[i].update(telaps);
	}

	for(i=0;i<SGX_MAXINP_STICKS;i++)
	{
		m_Sticks[i].update(telaps);
	}

}


