/** 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/sgx/input/input_mouse.cpp

*/

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

//
// Application of data from the platform-specific loop
//
void 
CSGXInputManager::applyMouseButton(const tMouseButton button, tBOOL bState)
{
	tUINT32 b = sgxRange<tUINT32>(button, 0, SGX_MAXINP_MOUSEBUTTONS);

	if (bState) {
		m_pDeviceMouse->m_Buttons[b].applyButtonPressed();
	} else {
		m_pDeviceMouse->m_Buttons[b].applyButtonReleased();
	}
}

void 
CSGXInputManager::applyMousePosition(const tINT32 x, const tINT32 y)
{
	m_pDeviceMouse->x = x;
	m_pDeviceMouse->y = y;
}

//
// Cross-platform query functions
//
tBOOL
CSGXInputManager::isMouseButtonUp(const tMouseButton &button)
{
	tUINT32 b = sgxRange<tUINT32>(button, 0, SGX_MAXINP_MOUSEBUTTONS);
    return m_Mouse.m_Buttons[b].m_bIsUp;
}

tBOOL
CSGXInputManager::isMouseButtonDown(const tMouseButton &button)
{
	tUINT32 b = sgxRange<tUINT32>(button, 0, SGX_MAXINP_MOUSEBUTTONS);
    return m_Mouse.m_Buttons[b].m_bIsDown;
}

tBOOL
CSGXInputManager::isMouseButtonPressed(const tMouseButton &button)
{
	tUINT32 b = sgxRange<tUINT32>(button, 0, SGX_MAXINP_MOUSEBUTTONS);
    return m_Mouse.m_Buttons[b].m_bPressed;
}

tBOOL
CSGXInputManager::isMouseButtonReleased(const tMouseButton &button)
{
	tUINT32 b = sgxRange<tUINT32>(button, 0, SGX_MAXINP_MOUSEBUTTONS);
    return m_Mouse.m_Buttons[b].m_bReleased;
}

tINT32
CSGXInputManager::getMouseX()
{
	return m_Mouse.x;
}

tINT32
CSGXInputManager::getMouseY()
{
	return m_Mouse.y;
}

