/*  $Id: input_device.cpp,v 1.9 2003/10/29 13:12:42 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_device.h"
#include "input_device_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice construction:

CL_InputDevice::CL_InputDevice()
: impl(0)
{
}

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

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

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice attributes:

CL_InputDevice::Type CL_InputDevice::get_type() const
{
	return impl->type;
}

std::string CL_InputDevice::get_key_name(int id) const
{
	return impl->get_key_name(id);
}

int CL_InputDevice::get_x() const
{
	return impl->get_x();
}

int CL_InputDevice::get_y() const
{
	return impl->get_y();
}

bool CL_InputDevice::get_keycode(int keycode) const
{
	return impl->get_keycode(keycode);
}

std::string CL_InputDevice::keyid_to_string(int keycode) const
{
	return impl->keyid_to_string(keycode);
}

int CL_InputDevice::keyid_to_string(const std::string &str) const
{
	return impl->keyid_to_string(str);
}

float CL_InputDevice::get_axis(int index) const
{
	return impl->get_axis(index);
}

std::string CL_InputDevice::get_name() const
{
	return impl->get_name();
}

int CL_InputDevice::get_axis_count() const
{
	return impl->get_axis_count();
}

int CL_InputDevice::get_button_count() const
{
	return impl->get_button_count();
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice operations:

CL_InputDevice &CL_InputDevice::operator =(const CL_InputDevice &copy)
{
	if (impl) impl->release_ref();
	impl = copy.impl;
	if (impl) impl->add_ref();

	return *this;
}

void CL_InputDevice::set_position(int x, int y)
{
	impl->set_position(x, y);
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice signals:

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_key_down()
{
	return impl->sig_key_down;
}

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_key_up()
{
	return impl->sig_key_up;
}

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_key_dblclk()
{
	return impl->sig_key_dblclk;
}

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_pointer_move()
{
	return impl->sig_pointer_move;
}

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_axis_move()
{
	return impl->sig_axis_move;
}

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_ball_move()
{
	return impl->sig_ball_move;
}

CL_Signal_v1<const CL_InputEvent &> &CL_InputDevice::sig_move()
{
	return impl->sig_pointer_move;
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice implementation:

CL_InputDevice::CL_InputDevice(CL_InputDevice_Generic *impl)
: impl(impl)
{
	if (impl) impl->add_ref();
}
