/*  $Id: keyboard.cpp,v 1.2 2003/07/20 22:31:49 grumbel 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/keyboard.h"
#include "API/Display/display.h"
#include "API/Display/display_window.h"
#include "API/Display/input_context.h"
#include "API/Display/input_device.h"

/////////////////////////////////////////////////////////////////////////////
// CL_Keyboard construction:

/////////////////////////////////////////////////////////////////////////////
// CL_Keyboard attributes:

#define get_ic() CL_Display::get_current_window()->get_ic()

int CL_Keyboard::get_device_count()
{
	return get_ic()->get_keyboard_count();
}

CL_InputDevice &CL_Keyboard::get_device(int keyboard)
{
	return get_ic()->get_keyboard(keyboard);
}
	
bool CL_Keyboard::get_keycode(int keycode, int keyboard)
{
	return get_ic()->get_keyboard(keyboard).get_keycode(keycode);
}

std::string CL_Keyboard::get_key_name(int id)
{
	return get_ic()->get_keyboard().get_key_name(id);
}

/////////////////////////////////////////////////////////////////////////////
// CL_Keyboard operations:

/////////////////////////////////////////////////////////////////////////////
// CL_Keyboard signals:

CL_Signal_v1<const CL_InputEvent &> &CL_Keyboard::sig_key_down(int keyboard)
{
	return get_ic()->get_keyboard(keyboard).sig_key_down();
}

CL_Signal_v1<const CL_InputEvent &> &CL_Keyboard::sig_key_up(int keyboard)
{
	return get_ic()->get_keyboard(keyboard).sig_key_up();
}

CL_Signal_v1<const CL_InputEvent &> &CL_Keyboard::sig_key_dblclk(int keyboard)
{
	return get_ic()->get_keyboard(keyboard).sig_key_dblclk();
}

/////////////////////////////////////////////////////////////////////////////
// CL_Input implementation:
