/*  $Id: input_device_generic.h,v 1.10 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
*/

#ifndef header_input_device_generic
#define header_input_device_generic

#if _MSC_VER > 1000
#pragma once
#endif

#include "API/Display/input_device.h"

class CL_InputDevice_Generic
{
//! Construction:
public:
	CL_InputDevice_Generic();

	virtual ~CL_InputDevice_Generic();

//! Attributes:
public:
	//: The input device type.
	CL_InputDevice::Type type;

	//: Returns the x position of the device.
	virtual int get_x() const { return 0; }

	//: Returns the y position of the device.
	virtual int get_y() const { return 0; }

	//: Returns true if the passed key code is down for this device.
	virtual bool get_keycode(int keycode) const { return false; }

	//: Key name for specified identifier (A, B, C, Space, Enter, Backspace).
	virtual std::string get_key_name(int id) const = 0;

	//: Returns a generic string name for the specified key code. 
	virtual std::string keyid_to_string(int keycode) const;

	//: Returns the key code for the specified generic string key name.
	virtual int keyid_to_string(const std::string &str) const;

	//: Returns the the current position of a joystick axis.
	virtual float get_axis(int index) const = 0;

	//: Returns the name of the device (i.e. 'Microsoft Sidewinder 3D').
	virtual std::string get_name() const = 0;

	//: Returns the number of axes available on this device.
	virtual int get_axis_count() const = 0;

	//: Returns the number of buttons available on this device.
	//- <p>If used on a keyboard, this function returns -1.</p>
	virtual int get_button_count() const = 0;

//! Operations:
public:
	//: Sets the position of the device.
	//- <p>Only valid for mouse.</p>
	virtual void set_position(int x, int y) {};

	void add_ref();

	void release_ref();

//! Signals:
public:
	CL_Signal_v1<const CL_InputEvent &> sig_key_down;

	CL_Signal_v1<const CL_InputEvent &> sig_key_up;
	
	CL_Signal_v1<const CL_InputEvent &> sig_key_dblclk;
	
	CL_Signal_v1<const CL_InputEvent &> sig_pointer_move;

	CL_Signal_v1<const CL_InputEvent &> sig_axis_move;

	CL_Signal_v1<const CL_InputEvent &> sig_ball_move;

//! Implementation:
private:
	int ref_count;
};

#endif
