1 /* 2 * OpenSCAD (www.openscad.org) 3 * Copyright (C) 2009-2015 Clifford Wolf <clifford@clifford.at> and 4 * Marius Kintel <marius@kintel.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * As a special exception, you have permission to link this program 12 * with the CGAL library and distribute executables, as long as you 13 * follow the requirements of the GNU GPL in regard to all of the 14 * software in the executable aside from CGAL. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 26 #pragma once 27 28 #include "InputDriver.h" 29 30 class JoystickInputDriver : public InputDriver 31 { 32 public: 33 JoystickInputDriver(); 34 ~JoystickInputDriver(); 35 void run() override; 36 bool open() override; 37 void close() override; 38 const std::string & get_name() const override; 39 std::string get_info() const override; 40 void setJoystickNr(std::string jnr); 41 getButtonCount()42 int getButtonCount() const override{ 43 return buttons; 44 } getAxisCount()45 int getAxisCount() const override{ 46 return axes; 47 } 48 49 private: 50 int fd; 51 int version; 52 std::string nr{"0"}; 53 unsigned char axes; 54 unsigned char buttons; 55 char name[1024]; 56 volatile bool stopRequest; 57 }; 58