/*  $Id: input_button_generic.cpp,v 1.5 2003/09/19 10:33:02 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 "input_button_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_InputButton_Generic construction:

/////////////////////////////////////////////////////////////////////////////
// CL_InputButton_Generic attributes:

/////////////////////////////////////////////////////////////////////////////
// CL_InputButton_Generic operations:

void CL_InputButton_Generic::bind(const CL_KeyBinding &key)
{
	bindings.push_back(key);
	
	slots.connect(key.get_device().sig_key_down(), this, &CL_InputButton_Generic::on_input_down);
}

void CL_InputButton_Generic::unbind(const CL_KeyBinding &key)
{
	// TODO: Remove slot
	
	bindings.remove(key);
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputButton_Generic implementation:

void CL_InputButton_Generic::on_input_down(const CL_InputEvent &key)
{
	for(std::list<CL_KeyBinding>::iterator it = bindings.begin(); it != bindings.end();it++)
	{
		if(key.id == it->get_keycode())
		{
			presses++;
			return;
		}
	}
}

void CL_InputButton_Generic::on_input_up(const CL_InputEvent &key)
{
	// TODO:
	// What needs to be done exactly?
	// --MSR April 22, 2003
}
