Blue Brain BioExplorer
VRPNPlugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  *
5  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 3.0 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #pragma once
22 
23 #include <Defines.h>
24 
28 
29 #include <vrpn_Analog.h>
30 #include <vrpn_Tracker.h>
31 
32 #ifdef BRAYNSVRPN_USE_LIBUV
33 #include <uv.h>
34 #endif
35 
36 namespace core
37 {
38 struct VrpnStates
39 {
40  float axisX = 0.0f;
41  float axisZ = 0.0f;
43 };
44 
46 {
47 public:
48  VRPNPlugin(const std::string& vrpnName);
49  ~VRPNPlugin();
50 
51  void init() final;
52 
53  void preRender() final;
54 
55 #ifdef BRAYNSVRPN_USE_LIBUV
56  void resumeRenderingIfTrackerIsActive();
57 #endif
58 
59 private:
60  std::unique_ptr<vrpn_Tracker_Remote> _vrpnTracker;
61  std::unique_ptr<vrpn_Analog_Remote> _vrpnAnalog;
62  const std::string _vrpnName;
63  Timer _timer;
64  VrpnStates _states;
65 
66 #ifdef BRAYNSVRPN_USE_LIBUV
67  struct LibuvDeleter
68  {
69  void operator()(uv_timer_t* timer)
70  {
71  uv_timer_stop(timer);
72  uv_close(reinterpret_cast<uv_handle_t*>(timer), [](uv_handle_t* handle) { delete handle; });
73  }
74  };
75  std::unique_ptr<uv_timer_t, LibuvDeleter> _idleTimer;
76 
77  void _setupIdleTimer();
78 #endif
79 };
80 } // namespace core
void preRender() final
Definition: VRPNPlugin.cpp:104
VRPNPlugin(const std::string &vrpnName)
Definition: VRPNPlugin.cpp:73
void init() final
Definition: VRPNPlugin.cpp:83
glm::quat flyStickOrientation
Definition: VRPNPlugin.h:42