opensurgsim
InputDeviceHandle.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_LINUX_INPUTDEVICEHANDLE_H
17 #define SURGSIM_DEVICES_MULTIAXIS_LINUX_INPUTDEVICEHANDLE_H
18 
19 #include <string>
20 #include <memory>
21 #include <array>
22 #include <vector>
23 
24 #include "SurgSim/Devices/MultiAxis/SystemInputDeviceHandle.h"
25 
26 
27 namespace SurgSim
28 {
29 namespace Framework
30 {
31 class Logger;
32 }; // namespace Framework
33 
34 namespace Devices
35 {
36 
40 {
41 public:
44 
48  static std::vector<std::string> enumeratePaths(SurgSim::Framework::Logger* logger);
49 
54  static std::unique_ptr<InputDeviceHandle> open(const std::string& path,
55  std::shared_ptr<SurgSim::Framework::Logger> logger);
56 
57  std::string getDeviceName() const override;
58 
59  bool getDeviceIds(int* vendorId, int* productId) const override;
60 
61  bool hasTranslationAndRotationAxes() const override;
62 
63  bool updateStates(AxisStates* axisStates, ButtonStates* buttonStates, bool* updated) override;
64 
65 private:
69  explicit InputDeviceHandle(std::shared_ptr<SurgSim::Framework::Logger>&& logger);
70 
71  // Prevent copy construction and copy assignment.
72  InputDeviceHandle(const InputDeviceHandle& other) = delete;
73  InputDeviceHandle& operator=(const InputDeviceHandle& other) = delete;
74 
77  std::vector<int> getDeviceButtonsAndKeys();
78 
81  bool hasAbsoluteTranslationAndRotationAxes() const;
84  bool hasRelativeTranslationAndRotationAxes() const;
85 
86  struct State;
87  std::unique_ptr<State> m_state;
88 };
89 
90 }; // namespace Devices
91 }; // namespace SurgSim
92 
93 #endif // SURGSIM_DEVICES_MULTIAXIS_LINUX_INPUTDEVICEHANDLE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Definition: InputDeviceHandle.cpp:36
std::array< bool, MAX_NUM_BUTTONS > ButtonStates
Type used to store button states.
Definition: SystemInputDeviceHandle.h:41
An object that can be used to control logging parameters, such as verbosity and log output destinatio...
Definition: Logger.h:51
Access to an input/HID device using the Input API in Linux.
Definition: InputDeviceHandle.h:39
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