TOBI SignalServer
0.1
|
00001 /* 00002 This file is part of the TOBI SignalServer. 00003 00004 Commercial Usage 00005 Licensees holding valid Graz University of Technology Commercial 00006 licenses may use this file in accordance with the Graz University 00007 of Technology Commercial License Agreement provided with the 00008 Software or, alternatively, in accordance with the terms contained in 00009 a written agreement between you and Graz University of Technology. 00010 00011 -------------------------------------------------- 00012 00013 GNU General Public License Usage 00014 Alternatively, this file may be used under the terms of the GNU 00015 General Public License version 3.0 as published by the Free Software 00016 Foundation and appearing in the file gpl.txt included in the 00017 packaging of this file. Please review the following information to 00018 ensure the GNU General Public License version 3.0 requirements will be 00019 met: http://www.gnu.org/copyleft/gpl.html. 00020 00021 In case of GNU General Public License Usage ,the TOBI SignalServer 00022 is distributed in the hope that it will be useful, 00023 but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 GNU General Public License for more details. 00026 00027 You should have received a copy of the GNU General Public License 00028 along with the TOBI SignalServer. If not, see <http://www.gnu.org/licenses/>. 00029 00030 Copyright 2010 Graz University of Technology 00031 Contact: SignalServer@tobi-project.org 00032 */ 00033 00041 #ifndef MOUSE_H 00042 #define MOUSE_H 00043 00044 #include <boost/cstdint.hpp> 00045 #include <set> 00046 #include <sstream> 00047 00048 #include "hw_thread.h" 00049 #include "hw_thread_builder.h" 00050 00051 namespace tobiss 00052 { 00053 //----------------------------------------------------------------------------- 00054 00060 class MouseBase : public HWThread 00061 { 00062 public: 00063 00067 MouseBase(ticpp::Iterator<ticpp::Element> hw); 00068 00072 virtual ~MouseBase(); 00073 00082 virtual SampleBlock<double> getAsyncData(); 00083 00087 virtual void run(); 00088 00092 virtual void stop(); 00093 00094 //----------------------------------------------- 00095 protected: 00096 00097 virtual void setDeviceSettings(ticpp::Iterator<ticpp::Element>const &father); 00098 00099 virtual void setChannelSettings(ticpp::Iterator<ticpp::Element>const &father); 00100 00101 virtual SampleBlock<double> getSyncData() {return data_; } 00102 00103 00107 virtual int blockKernelDriver() = 0; 00108 00112 virtual int freeKernelDriver() = 0; 00113 00117 virtual void acquireData() = 0; 00118 00119 private: 00120 00124 void initMouse(); 00125 00129 void setVendorId(ticpp::Iterator<ticpp::Element>const &elem); 00130 00134 void setProductId(ticpp::Iterator<ticpp::Element>const &elem); 00135 00139 void setUsbPort(ticpp::Iterator<ticpp::Element>const &elem); 00140 00141 int giveDecimalRepresentation(std::string); 00142 00143 template <class T> bool fromString( T& t, const std::string& s, 00144 std::ios_base& (*f)(std::ios_base&) ) 00145 { 00146 std::istringstream iss(s); 00147 return !(iss >> f >> t).fail(); 00148 } 00149 00150 //----------------------------------------------- 00151 00152 protected: 00153 00154 boost::uint32_t vid_; 00155 boost::uint32_t pid_; 00156 boost::uint32_t usb_port_; 00157 00158 SampleBlock<double> empty_block_; 00159 00160 boost::thread* async_acqu_thread_; 00161 // std::vector<boost::int16_t> raw_data_; 00162 int async_data_x_; 00163 int async_data_y_; 00164 int async_data_buttons_; 00165 00166 private: 00167 00168 static std::set<boost::uint16_t> used_ids_; 00169 boost::uint16_t id_; 00170 00171 static const std::string str_hw_vid_; 00172 static const std::string str_hw_pid_; 00173 static const std::string str_usb_port_; 00174 00175 boost::uint16_t buttons_; 00176 std::vector<bool> buttons_values_; 00177 00178 boost::uint16_t axes_; 00179 std::vector<boost::int16_t> axes_values_; 00180 00181 }; 00182 00183 } // Namespace tobiss 00184 00185 #endif // MOUSE_H 00186 00187 //-----------------------------------------------------------------------------