opensurgsim
SixenseScaffold.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_SIXENSE_SIXENSESCAFFOLD_H
17 #define SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
18 
19 #include <memory>
20 
21 #include "SurgSim/Framework/Logger.h"
22 #include "SurgSim/DataStructures/DataGroup.h"
23 
24 namespace SurgSim
25 {
26 namespace Devices
27 {
28 
29 class SixenseDevice;
30 class SixenseThread;
31 
36 {
37 public:
40 
44  static std::shared_ptr<SixenseScaffold> getOrCreateSharedInstance();
45 
46 private:
48  struct StateData;
50  struct DeviceData;
51 
52  friend class SixenseDevice;
53  friend class SixenseThread;
54  friend struct StateData;
55 
58 
64  bool registerDevice(SixenseDevice* device);
65 
71  bool unregisterDevice(const SixenseDevice* device);
72 
76  bool runInputFrame();
77 
80  bool updateDevice(const DeviceData& info);
81 
84  bool initializeSdk();
85 
88  bool finalizeSdk();
89 
98  bool findUnusedDeviceAndRegister(SixenseDevice* device, int* numUsedDevicesSeen, bool* fatalError);
99 
108  bool registerIfUnused(int baseIndex, int controllerIndex, SixenseDevice* device, int* numUsedDevicesSeen);
109 
112  bool createThread();
113 
117  bool destroyThread();
118 
120  static SurgSim::DataStructures::DataGroup buildDeviceInputData();
121 
122 
123 
125  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
127  std::unique_ptr<StateData> m_state;
128 
130  static int m_startupDelayMilliseconds;
132  static int m_startupRetryIntervalMilliseconds;
133 };
134 
135 }; // namespace Devices
136 }; // namespace SurgSim
137 
138 #endif // SURGSIM_DEVICES_SIXENSE_SIXENSESCAFFOLD_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A class that manages Sixense devices, such as the Razer Hydra.
Definition: SixenseScaffold.h:35
static std::shared_ptr< SixenseScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all SixenseDevice instances.
Definition: SixenseScaffold.cpp:468
Definition: SixenseScaffold.cpp:76
A class implementing the communication with one Sixense controller, for example one of the two on the...
Definition: SixenseDevice.h:53
A collection of NamedData objects.
Definition: DataGroup.h:68
~SixenseScaffold()
Destructor.
Definition: SixenseScaffold.cpp:110
A class implementing the thread context for sampling Sixense devices.
Definition: SixenseThread.h:33
Definition: SixenseScaffold.cpp:52