opensurgsim
RawMultiAxisScaffold.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
17 #define SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "SurgSim/Framework/Logger.h"
23 #include "SurgSim/DataStructures/DataGroup.h"
24 
25 namespace SurgSim
26 {
27 namespace Devices
28 {
29 
30 class RawMultiAxisDevice;
31 class RawMultiAxisThread;
32 class SystemInputDeviceHandle;
33 
38 {
39 public:
42 
45 
49  static std::shared_ptr<RawMultiAxisScaffold> getOrCreateSharedInstance();
50 
51 private:
53  struct StateData;
55  struct DeviceData;
56 
57  friend class RawMultiAxisDevice;
58  friend class RawMultiAxisThread;
59  friend struct StateData;
60 
66  bool registerDevice(RawMultiAxisDevice* device);
67 
73  bool unregisterDevice(const RawMultiAxisDevice* device);
74 
76  void setPositionScale(const RawMultiAxisDevice* device, double scale);
77 
79  void setOrientationScale(const RawMultiAxisDevice* device, double scale);
80 
82  void setAxisDominance(const RawMultiAxisDevice* device, bool onOff);
83 
88  bool runInputFrame(DeviceData* info);
89 
94  bool runAfterLastFrame(DeviceData* info);
95 
98  bool updateDevice(DeviceData* info);
99 
106  bool findUnusedDeviceAndRegister(RawMultiAxisDevice* device, int* numUsedDevicesSeen);
107 
115  bool registerIfUnused(const std::string& path, RawMultiAxisDevice* device, int* numUsedDevicesSeen);
116 
119  bool createPerDeviceThread(DeviceData* data);
120 
123  bool destroyPerDeviceThread(DeviceData* data);
124 
127  std::unique_ptr<SystemInputDeviceHandle> openDevice(const std::string& path);
128 
130  static SurgSim::DataStructures::DataGroup buildDeviceInputData();
131 
132 
133 
135  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
137  std::unique_ptr<StateData> m_state;
138 };
139 
140 }; // namespace Devices
141 }; // namespace SurgSim
142 
143 #endif // SURGSIM_DEVICES_MULTIAXIS_RAWMULTIAXISSCAFFOLD_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A class implementing the thread context for sampling RawMultiAxis devices.
Definition: RawMultiAxisThread.h:33
A class that implements the behavior of RawMultiAxisDevice objects.
Definition: RawMultiAxisScaffold.h:37
A class implementing the communication with a multi-axis controller input device, for example a 3DCon...
Definition: RawMultiAxisDevice.h:56
static std::shared_ptr< RawMultiAxisScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all RawMultiAxisDevice instances.
Definition: RawMultiAxisScaffold.cpp:559
~RawMultiAxisScaffold()
Destructor.
Definition: RawMultiAxisScaffold.cpp:180
A collection of NamedData objects.
Definition: DataGroup.h:68
Definition: RawMultiAxisScaffold.cpp:152
Definition: RawMultiAxisScaffold.cpp:59
RawMultiAxisScaffold()
Constructor.
Definition: RawMultiAxisScaffold.cpp:173