RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Analog_5dtUSB.h
浏览该文件的文档.
1/** @file vrpn_Analog_5dtUSB.h
2 @brief header for 5DT USB (HID) dataglove driver
3
4 @date 2011
5
6 @author
7 Ryan Pavlik
8 <rpavlik@iastate.edu> and <abiryan@ryand.net>
9 http://academic.cleardefinition.com/
10 Iowa State University Virtual Reality Applications Center
11 Human-Computer Interaction Graduate Program
12*/
13
14#ifndef VRPN_ANALOG_5DTUSB_H
15#define VRPN_ANALOG_5DTUSB_H
16
17#include <stddef.h> // for size_t
18#include <string> // for string
19
20#include "vrpn_Analog.h" // for vrpn_Analog
21#include "vrpn_Configure.h" // for VRPN_API, VRPN_USE_HID
22#include "vrpn_Connection.h" // for vrpn_Connection (ptr only), etc
23#include "vrpn_HumanInterface.h" // for vrpn_HIDDEVINFO, etc
24#include "vrpn_Shared.h" // for timeval
25#include "vrpn_Types.h" // for vrpn_uint16, vrpn_uint32, etc
26
27#if defined(VRPN_USE_HID)
28
29/** @brief 5th Dimension Technologies (5dt) "Ultra" USB data glove driver
30
31 This supports connecting to 5dt gloves over USB that present a HID device interface.
32 This includes the 5DT Data Glove 5 Ultra and the 5DT Data Glove 14 Ultra, as well
33 as either of those using the wireless kit. (I, Ryan Pavlik, have only tested this
34 with the 5DT Data Glove 5 Ultras since that's all I have access to, but support based
35 on what I would expect from a 14-sensor glove is included.)
36
37 Each sensor's raw values are exposed as an analog channel (5 or 14) between 0.0 and 1.0.
38 Note that there is pretty significant need for calibration since the used range within the
39 entire representable range is pretty small and seemingly device-dependent.
40 Your code will probably have to at least perform some scaling based on establishing a
41 "min" and "max" for each sensor.
42
43 For serial 5dt glove access, see the vrpn_5DT16 (for the 16-sensor model) and
44 vrpn_5dt (for the 5-sensor wired or wireless model, in vrpn_Analog_5dt.h) classes.
45
46 The inherited method vrpn_Analog::getNumChannels()
47
48 This base class does all the work: the inherited classes just create the right filters
49 and input for the base class.
50*/
51class VRPN_API vrpn_Analog_5dtUSB : public vrpn_Analog, protected vrpn_HidInterface {
52 public:
53 /// Destructor
55
56 /// Standard VRPN mainloop method.
57 virtual void mainloop();
58
59 /// Returns a string description of the device we've connected to. Used internally,
60 /// but also possibly useful externally.
61 std::string get_description() const;
62
63 /// Accessor to know if this is a left hand glove.
64 bool isLeftHand() const { return _isLeftHand; }
65
66 /// Accessor to know if this is a right hand glove.
67 bool isRightHand() const { return !_isLeftHand; }
68
69 protected:
70 /// Protected constructor: use a subclass to specify the glove variant to use.
71 // NOTE: Because this can accept a variety of productIds, we cannot use the
72 // optimization of asking for a vendor and product ID in the constructor
73 // of the vrpn_HidInterface -- it will not understand about the masks.
74 vrpn_Analog_5dtUSB(vrpn_HidAcceptor *filter, int num_sensors,
75 bool isLeftHand, const char *name, vrpn_Connection *c = 0);
76 /// Extracts the sensor values from each report.
77 void on_data_received(size_t bytes, vrpn_uint8 *buffer);
78
79 /// Timestamp updated during mainloop()
80 struct timeval _timestamp;
81
82 /// The raw values extracted from the report: which ones we use to set
83 /// analog channels varies based on the kind of device this is.
84 double _rawVals[16];
85
86 /// Flag for left handedness.
88
89 /// Flag indicating whether we were connected last time through the mainloop.
90 /// Used to send a "normal"-severity message when we connect with info on the
91 /// device.
93
94 /// Send report iff changed
95 void report_changes(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
96 /// Send report whether or not changed
97 void report(vrpn_uint32 class_of_service = vrpn_CONNECTION_LOW_LATENCY);
98};
99
100/// Specialization of vrpn_Analog_5dtUSB for a 5-sensor, left-hand glove.
102 public:
103 vrpn_Analog_5dtUSB_Glove5Left(const char *name, vrpn_Connection *c = 0);
105};
106
107/// Specialization of vrpn_Analog_5dtUSB for a 5-sensor, right-hand glove.
109 public:
110 vrpn_Analog_5dtUSB_Glove5Right(const char *name, vrpn_Connection *c = 0);
112};
113
114/// Specialization of vrpn_Analog_5dtUSB for a 14-sensor, left-hand glove.
115/// Not tested as of 8-Mar-2011 because I don't have access to one.
117 public:
118 vrpn_Analog_5dtUSB_Glove14Left(const char *name, vrpn_Connection *c = 0);
120};
121
122/// Specialization of vrpn_Analog_5dtUSB for a 14-sensor, right-hand glove.
123/// Not tested as of 8-Mar-2011 because I don't have access to one.
125 public:
126 vrpn_Analog_5dtUSB_Glove14Right(const char *name, vrpn_Connection *c = 0);
128};
129
130/// HID acceptor subclass used by vrpn_Analog_5dtUSB since the bits of
131/// the product ID for these devices describe the device in a useful way.
133 public:
134 vrpn_HidProductMaskAcceptor(vrpn_uint16 vendorId, vrpn_uint16 productMask = 0x0000, vrpn_uint16 desiredProduct = 0x0000) :
135 vendor(vendorId),
136 product(desiredProduct),
137 mask(productMask) {}
138
140
141 bool accept(const vrpn_HIDDEVINFO &device) {
142 return (device.vendor == vendor) && ((device.product & mask) == (product & mask));
143 }
144 private:
145 vrpn_uint16 vendor;
146 vrpn_uint16 product;
147 vrpn_uint16 mask;
148};
149
150#endif // end of ifdef VRPN_USE_HID
151
152// end of VRPN_ANALOG_5DTUSB_H
153#endif
154
定义 vrpn_Analog_5dtUSB.h:116
定义 vrpn_Analog_5dtUSB.h:124
Specialization of vrpn_Analog_5dtUSB for a 5-sensor, left-hand glove.
定义 vrpn_Analog_5dtUSB.h:101
Specialization of vrpn_Analog_5dtUSB for a 5-sensor, right-hand glove.
定义 vrpn_Analog_5dtUSB.h:108
5th Dimension Technologies (5dt) "Ultra" USB data glove driver
定义 vrpn_Analog_5dtUSB.h:51
vrpn_Analog_5dtUSB(vrpn_HidAcceptor *filter, int num_sensors, bool isLeftHand, const char *name, vrpn_Connection *c=0)
Protected constructor: use a subclass to specify the glove variant to use.
virtual ~vrpn_Analog_5dtUSB()
Destructor
void on_data_received(size_t bytes, vrpn_uint8 *buffer)
Extracts the sensor values from each report.
bool _isLeftHand
Flag for left handedness.
定义 vrpn_Analog_5dtUSB.h:87
std::string get_description() const
virtual void mainloop()
Standard VRPN mainloop method.
bool _wasConnected
定义 vrpn_Analog_5dtUSB.h:92
void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
Send report iff changed
bool isRightHand() const
Accessor to know if this is a right hand glove.
定义 vrpn_Analog_5dtUSB.h:67
void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY)
Send report whether or not changed
bool isLeftHand() const
Accessor to know if this is a left hand glove.
定义 vrpn_Analog_5dtUSB.h:64
定义 vrpn_Analog.h:28
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_HumanInterface.h:56
定义 vrpn_HumanInterface.h:70
vrpn_uint16 product() const
vrpn_uint16 vendor() const
定义 vrpn_Analog_5dtUSB.h:132
定义 vrpn_HumanInterface.h:40