/*  $Id: input_device_win32keyboard.cpp,v 1.12 2004/04/20 12:43:48 sphair 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 <windows.h>
#include "Display/display_precomp.h"
#include "input_device_win32keyboard.h"
#include "display_window_win32.h"

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice_Win32Keyboard construction:

CL_InputDevice_Win32Keyboard::CL_InputDevice_Win32Keyboard(CL_DisplayWindow_Win32 *window) : window(window)
{
	type = CL_InputDevice::keyboard;
}

CL_InputDevice_Win32Keyboard::~CL_InputDevice_Win32Keyboard()
{
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice_Win32Keyboard attributes:

bool CL_InputDevice_Win32Keyboard::get_keycode(int keycode) const
{
	// Ignore all key events when we don't have focus
	if (!window->has_focus())
		return false;

	return (GetKeyState(keycode) & 0xfe) != 0;
}

std::string CL_InputDevice_Win32Keyboard::get_key_name(int virtual_key) const
{
	char name[1024];
	UINT scancode = MapVirtualKey(virtual_key, 0);
	int length = GetKeyNameText(scancode << 16, name, 1024);
	return std::string(name, length);
}

float CL_InputDevice_Win32Keyboard::get_axis(int index) const
{
	return 0.0f;
}

std::string CL_InputDevice_Win32Keyboard::get_name() const
{
	return "System Keyboard";
}

int CL_InputDevice_Win32Keyboard::get_axis_count() const
{
	return 0;
}

int CL_InputDevice_Win32Keyboard::get_button_count() const
{
	return -1;
}

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice_Win32Keyboard operations:

/////////////////////////////////////////////////////////////////////////////
// CL_InputDevice_Win32Keyboard implementation:
