RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Freespace.h
1/**
2 * This provides an interface to devices powered by Hillcrest Lab's Freespace.
3 * Freespace is a sensor technology for tracking relative movement of a handheld device.
4 * A Freespace device exposes itself as a combination of 3 VRPN interfaces.
5 * as a tracker, with linear acceleration and angular velocity,
6 * as a Dial, with a single dial for an on-board scroll wheel (loop pointer)
7 * and as a Button for the various buttons on the device.
8 *
9 * The implementation here uses the synchronous API to read data from the device,
10 * but could fairly easily be modified to use the asynchronous API. This may be desired as
11 * a cleaner way to provide access to multiple Freespace devices and/or handle hot-plugging
12 * of devices (such as the loop, which uses a USB dongle for communications).
13 *
14 * More info on libfreespace can be found at https://launchpad.net/libfreespace
15 * or http://hillcrestlabs.com/products/tools/
16 *
17 */
18
19#ifndef VRPN_FREESPACE_H
20#define VRPN_FREESPACE_H
21
22#include "vrpn_Configure.h" // IWYU pragma: keep
23
24#ifdef VRPN_USE_FREESPACE
25
26#include <freespace/freespace.h>
27
28#include "vrpn_Button.h"
29#include "vrpn_Dial.h"
30#include "vrpn_Tracker.h"
31
32
33class VRPN_API vrpn_Freespace :
34 public vrpn_Tracker_Server, // for the positional data
35 public vrpn_Button_Filter, // for the actual buttons
36 public vrpn_Dial // for the scroll wheel
37{
38public:
39 /**
40 * Create a freespace server using the given FreespaceDeviceId. This
41 * factory will automatically initialize the libfreespace library as needed.
42 * This method will open the device and configure it to receive relavant
43 * messages. See the test_freespace.C, or libfreespace-examples, for steps to
44 * initialize the library and enumerate devices.
45 */
46
47 // Freespace devices may report User frames (position and orientation in a quaternion),
48 // Body frames (angular velocity and linear acceleration), Mouse reports (delta X, delta Y)
49 // or some combination of them. You will probably want at least body or user frame
50 // messages.
51 // Another thing to note is that for some devices, enabling multiple reports diminishes
52 // the effective rate of data since the device can only send so many bits per second.
53 // This could fairly easily get added as a configuration setting.
54
55 static vrpn_Freespace* create(const char *name,
56 vrpn_Connection *conn,
57 int device_index = 0,
58 bool send_body_frames = false,
59 bool send_user_frames = true);
60 virtual ~vrpn_Freespace(void);
61 /**
62 * Main loop. This will try to read data from the loop, and send
63 * appropriate messages
64 * to a VRPN client.
65 */
66 virtual void mainloop(void);
67
68private:
69 static bool _freespace_initialized;
70 static void freespaceInit();
71 /**
72 * private constructor since opening of the device can fail.
73 */
74 vrpn_Freespace(FreespaceDeviceId freespaceId,
75 struct FreespaceDeviceInfo* deviceInfo,
76 const char *name,
78
79 void handleUserFrame(const struct freespace_UserFrame&);
80 void handleBodyFrame(const struct freespace_BodyFrame&);
81 void handleLinkStatus(const struct freespace_LinkStatus&);
82
83 void deviceSetConfiguration(bool send_body_frames, bool send_user_frames);
84 void deviceConfigure();
85 void deviceUnconfigure();
86
87 bool _sendBodyFrames;
88 bool _sendUserFrames;
89 struct timeval _timestamp;
90
91protected:
92 FreespaceDeviceId _freespaceDevice;
93 FreespaceDeviceInfo _deviceInfo;
94 vrpn_float64 _lastBodyFrameTime;
95};
96#endif //VRPN_USE_FREESPACE
97
98#endif // VRPN_FREESPACE_H
定义 vrpn_Button.h:66
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Dial.h:21
定义 vrpn_Tracker.h:273
virtual void mainloop()
This function should be called each time through app mainloop.