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

📄 input_device_linuxjoystick.h

📁 这是一款2d游戏引擎
💻 H
字号:
/*  $Id: input_device_linuxjoystick.h,v 1.2 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_linuxjoystick
#define header_input_device_linuxjoystick

#include <vector>
#include <string>

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

class CL_InputDevice_LinuxJoystick : public CL_InputDevice_Generic,
												 public CL_KeepAlive
{
private:
	int fd;
	std::string name;

	std::vector<float> axes_states;
	std::vector<bool>  button_states;

public:
	CL_InputDevice_LinuxJoystick(const std::string& device);
	~CL_InputDevice_LinuxJoystick();

	std::string get_key_name(int num) const;

	float get_axis(int num)   const { return axes_states[num]; }
	bool  get_keycode(int num) const { return button_states[num]; }
	
	int get_axis_count()   const { return axes_states.size(); }
	int get_button_count() const { return button_states.size(); }

	std::string get_name() const { return name; }

	void process_event(struct js_event event);
	void keep_alive();

private:
	void send_button_event(const struct js_event& event);
	void send_axis_event(const struct js_event& event);
};

#endif

// EOF //

⌨️ 快捷键说明

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