MinVR  0.9.0
A multi-platform virtual reality library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InputDeviceVRPNAnalog.H
Go to the documentation of this file.
1 //========================================================================
2 // MinVR
3 // Platform: Any
4 // API version: 1.0
5 //------------------------------------------------------------------------
6 // The MIT License (MIT)
7 //
8 // Copyright (c) 2013 Regents of the University of Minnesota
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy of
11 // this software and associated documentation files (the "Software"), to deal in
12 // the Software without restriction, including without limitation the rights to
13 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14 // the Software, and to permit persons to whom the Software is furnished to do so,
15 // subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in all
18 // copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //========================================================================
27 
28 
29 #ifndef VRPNANALOGDEVICE_H
30 #define VRPNANALOGDEVICE_H
31 
32 // Note: This include ordering is important, don't screw with it!
33 #include <glm/glm.hpp>
34 #include <vector>
35 #include <iostream>
36 
38 #include "MVRCore/ConfigMap.H"
39 
40 #include <boost/log/trivial.hpp>
41 #define BOOST_ASSERT_MSG_OSTREAM std::cout
42 #include <boost/assert.hpp>
43 
44 #ifdef USE_VRPN
45 class vrpn_Analog_Remote;
46 #endif
47 
48 namespace MinVR {
49 
53 {
54 public:
55 
56 #ifdef USE_VRPN
57  InputDeviceVRPNAnalog(const std::string &vrpnAnalogDeviceName, const std::vector<std::string> &eventsToGenerate);
58  InputDeviceVRPNAnalog(const std::string name, const ConfigMapRef map);
59 
60  virtual ~InputDeviceVRPNAnalog();
61 
62  void pollForInput(std::vector<EventRef> &events);
63  void sendEventIfChanged(int channelNumber, double data);
64  std::string getEventName(int channelNumber);
65  int numChannels() { return _eventNames.size(); }
66 
67 private:
68  vrpn_Analog_Remote *_vrpnDevice;
69  std::vector<std::string> _eventNames;
70  std::vector<double> _channelValues;
71  std::vector<EventRef> _pendingEvents;
72 #else
73  InputDeviceVRPNAnalog(const std::string &vrpnAnalogDeviceName, const std::vector<std::string> &eventsToGenerate)
74  {
75  BOOST_ASSERT_MSG(false, "VRPN is currently unsupported. Set cmake option USE_VRPN to ON and recompile.");
76  }
77  InputDeviceVRPNAnalog(const std::string name, const ConfigMapRef map)
78  {
79  BOOST_ASSERT_MSG(false, "VRPN is currently unsupported. Set cmake option USE_VRPN to ON and recompile.");
80  }
81 
82  virtual ~InputDeviceVRPNAnalog() {};
83  void pollForInput(std::vector<EventRef> &events) {};
84 #endif
85 };
86 
87 } // end namespace
88 
89 
90 
91 #endif
92 
93