/*  $Id: input_context.cpp,v 1.12 2003/10/05 11:07:12 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#include "Display/display_precomp.h"
#include "API/Display/input_context.h"
#include "input_context_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_InputContext Construction:

CL_InputContext::CL_InputContext() : impl(new CL_InputContext_Generic)
{
	impl->add_ref();
}

CL_InputContext::CL_InputContext(const CL_InputContext &copy) : impl(copy.impl)
{
	if (impl) impl->add_ref();
}

CL_InputContext::~CL_InputContext()
{
	if (impl) impl->release_ref();
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputContext Attributes:

int CL_InputContext::get_keyboard_count() const
{
	return impl->keyboards.size();
}

int CL_InputContext::get_mouse_count() const
{
	return impl->mice.size();
}

int CL_InputContext::get_joystick_count() const
{
	return impl->joysticks.size();
}

CL_InputDevice &CL_InputContext::get_keyboard(int keyboard)
{
	return impl->keyboards[keyboard];
}

CL_InputDevice &CL_InputContext::get_mouse(int mouse)
{
	return impl->mice[mouse];
}

CL_InputDevice &CL_InputContext::get_joystick(int joystick)
{
	return impl->joysticks[joystick];
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputContext operations:

CL_InputContext &CL_InputContext::operator =(CL_InputContext &copy)
{
	if (impl == copy.impl) return *this;
	if (impl) impl->release_ref();
	impl = copy.impl;
	if (impl) impl->add_ref();
	return *this;
}

void CL_InputContext::clear()
{
	impl->clear();
}

void CL_InputContext::add_keyboard(const CL_InputDevice &keyboard)
{
	impl->add_keyboard(keyboard);
}

void CL_InputContext::add_mouse(const CL_InputDevice &mouse)
{
	impl->add_mouse(mouse);
}

void CL_InputContext::add_joystick(const CL_InputDevice &joystick)
{
	impl->add_joystick(joystick);
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputContext implementation:

