opensurgsim
SystemInputDeviceHandle.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_SYSTEMINPUTDEVICEHANDLE_H
17 #define SURGSIM_DEVICES_MULTIAXIS_SYSTEMINPUTDEVICEHANDLE_H
18 
19 #include <string>
20 #include <memory>
21 #include <array>
22 #include <vector>
23 
24 namespace SurgSim
25 {
26 namespace Devices
27 {
28 
31 {
32 public:
34  static const size_t MAX_NUM_AXES = 6;
36  static const size_t MAX_NUM_BUTTONS = 4;
37 
39  typedef std::array<int, MAX_NUM_AXES> AxisStates;
41  typedef std::array<bool, MAX_NUM_BUTTONS> ButtonStates;
42 
43 
45  virtual ~SystemInputDeviceHandle();
46 
49  virtual std::string getDeviceName() const = 0;
50 
55  virtual bool getDeviceIds(int* vendorId, int* productId) const = 0;
56 
59  virtual bool hasTranslationAndRotationAxes() const = 0;
60 
67  virtual bool updateStates(AxisStates* axisStates, ButtonStates* buttonStates, bool* updated) = 0;
68 
72  virtual void prepareForShutdown();
73 
74 protected:
78 
79 private:
80  // Prevent copy construction and copy assignment. (VS2012 does not support "= delete" yet.)
81  SystemInputDeviceHandle(const SystemInputDeviceHandle& other) /*= delete*/;
82  SystemInputDeviceHandle& operator=(const SystemInputDeviceHandle& other) /*= delete*/;
83 };
84 
85 }; // namespace Devices
86 }; // namespace SurgSim
87 
88 #endif // SURGSIM_DEVICES_MULTIAXIS_SYSTEMINPUTDEVICEHANDLE_H
virtual bool hasTranslationAndRotationAxes() const =0
Queries if this device has 3 translation and 3 rotation axes.
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual bool updateStates(AxisStates *axisStates, ButtonStates *buttonStates, bool *updated)=0
Updates the axis and states from the device input, if any.
virtual ~SystemInputDeviceHandle()
Destructor.
Definition: SystemInputDeviceHandle.cpp:28
SystemInputDeviceHandle()
Default constructor.
Definition: SystemInputDeviceHandle.cpp:24
virtual void prepareForShutdown()
Prepares the handle for sampling thread shutdown.
Definition: SystemInputDeviceHandle.cpp:32
static const size_t MAX_NUM_BUTTONS
The maximum number of buttons supported by any device object.
Definition: SystemInputDeviceHandle.h:36
virtual std::string getDeviceName() const =0
Gets the name returned by the operating system for this device.
virtual bool getDeviceIds(int *vendorId, int *productId) const =0
Gets the device identifiers.
std::array< bool, MAX_NUM_BUTTONS > ButtonStates
Type used to store button states.
Definition: SystemInputDeviceHandle.h:41
A wrapper for system-dependent access to an input/HID device.
Definition: SystemInputDeviceHandle.h:30
std::array< int, MAX_NUM_AXES > AxisStates
Type used to store axis states.
Definition: SystemInputDeviceHandle.h:39
static const size_t MAX_NUM_AXES
The maximum number of axes supported by any device object.
Definition: SystemInputDeviceHandle.h:34