⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 input_device_linuxusbmouse.h

📁 这是一款2d游戏引擎
💻 H
字号:
/*  $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: ***

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -