/*  $Id: input_device_linuxusbmouse.h,v 1.1 2003/10/30 11:44:27 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
*/

#ifndef header_input_device_usbmouse
#define header_input_device_usbmouse

#include "API/Core/Math/point.h"
#include "API/Core/System/keep_alive.h"
#include "../../Display/input_device_generic.h"

class CL_DisplayWindow_Generic;

class CL_InputDevice_LinuxUSBMouse : public CL_InputDevice_Generic,
												 public CL_KeepAlive
{
private:
	CL_DisplayWindow_Generic* parent;
	int fd;

	std::vector<bool> buttons;
	CL_Point mouse_pos;
public:
	CL_InputDevice_LinuxUSBMouse(CL_DisplayWindow_Generic* parent, 
										  const std::string& dev);
	~CL_InputDevice_LinuxUSBMouse();

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

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

	//: Returns true if the passed key code is down for this device.
	bool get_keycode(int keycode) const;
	
	std::string get_key_name(int id) const { return "mouse-button"; };

	virtual float get_axis(int index) const { return 0; }

	//: Returns the name of the device (i.e. 'Microsoft Sidewinder 3D').
	std::string get_name() const { return "Linux USB Mouse"; }

	//: Returns the number of axes available on this device.
	int get_axis_count() const { return 0; }

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

private:
        void send_pointer_move(const CL_Point& pos);
        void send_ball_move(int delta_x, int delta_y);
        void send_key_event(int key, bool press);
        
	//: Init device to Microsoft Explorer so that all buttons are accessible
	void init_explorer_ps2();

	void keep_alive();
};

#endif

// Local Variables: ***
// mode: clanlib ***
// End: ***
