/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     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: src/skeleton/wintel32/input/wintel32mouseskeleton.cpp

*/

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

void init_input(void *, void *) {
}

void skelMouseHandler::update()
{
	//
	m_bLeftDown = CSGXInputManager::get()->isMouseButtonDown(CSGXInputManager::eMouseButtonLeft);
	m_bLeftPressed = CSGXInputManager::get()->isMouseButtonPressed(CSGXInputManager::eMouseButtonLeft);
	m_bRightDown = CSGXInputManager::get()->isMouseButtonDown(CSGXInputManager::eMouseButtonRight);
	m_bRightPressed = CSGXInputManager::get()->isMouseButtonPressed(CSGXInputManager::eMouseButtonRight);
	//
	m_MouseX = m_MousePoint.x = CSGXInputManager::get()->getMouseX();
	m_MouseY = m_MousePoint.y = CSGXInputManager::get()->getMouseY();
	//
	if (CSGXInputManager::get()->isMouseButtonPressed(CSGXInputManager::eMouseButtonLeft)) {
		bMouseMoveCamera = TRUE;
		bMouseLeftButton = TRUE;
		iMouseMoveX = m_MouseX;
		iMouseMoveY = m_MouseY;
	} else if (CSGXInputManager::get()->isMouseButtonPressed(CSGXInputManager::eMouseButtonRight)) {
		bMouseMoveCamera = TRUE;
		bMouseLeftButton = FALSE;
		iMouseMoveX = m_MouseX;
		iMouseMoveY = m_MouseY;
	} else if (CSGXInputManager::get()->isMouseButtonReleased(CSGXInputManager::eMouseButtonLeft)) {
		bMouseMoveCamera = FALSE;
	}

	if (bMouseMoveCamera) {
		m_MouseDX = CSGXInputManager::get()->getMouseX() - iMouseMoveX;
		m_MouseDY = CSGXInputManager::get()->getMouseY() - iMouseMoveY;
		
		iMouseMoveX = m_MouseX;
		iMouseMoveY = m_MouseY;
	}
}
