24#if defined(VRPN_USE_HID)
27static const vrpn_uint16 vrpn_OSVR_VENDOR = 0x1532;
28static const vrpn_uint16 vrpn_OSVR_HACKER_DEV_KIT_HMD = 0x0b00;
31static const vrpn_uint16 vrpn_OSVR_ALT_VENDOR = 0x03EB;
32static const vrpn_uint16 vrpn_OSVR_ALT_HACKER_DEV_KIT_HMD = 0x2421;
37static const vrpn_uint16 vrpn_HDK_STATUS_STRIDE = 400;
38static const vrpn_float64 vrpn_HDK_DT = 1.0 / 50;
46 vrpn_OSVR_HACKER_DEV_KIT_HMD),
48 vrpn_OSVR_ALT_HACKER_DEV_KIT_HMD));
49 }
catch (...) {
return NULL; }
64 , _wasConnected(false)
77 , _wasConnected(false)
107 fprintf(stderr,
"vrpn_Tracker_OSVRHackerDevKit::~vrpn_Tracker_OSVRHackerDevKit(): delete failed\n");
115 if (bytes != 32 && bytes != 16) {
117 <<
"Received a report " << bytes
118 <<
" in length, but expected it to be 32 or 16 bytes. Discarding. "
119 "(May indicate issues with HID!)";
123 vrpn_uint8 firstByte = vrpn_unbuffer_from_little_endian<vrpn_uint8>(buffer);
125 vrpn_uint8 version = vrpn_uint8(0x0f) & firstByte;
130 if (bytes != 32 && bytes != 16) {
132 <<
"Received a v1 report " << bytes
133 <<
" in length, but expected it to be 32 or 16 bytes. "
135 "(May indicate issues with HID!)";
142 <<
"Received a v2 report " << bytes
143 <<
" in length, but expected it to be 16 bytes. Discarding. "
144 "(May indicate issues with HID!)";
154 <<
"Received a v3 report " << bytes
155 <<
" in length, but expected it to be at least 16 bytes. "
157 "(May indicate issues with HID!)";
167 <<
"Received a report claiming to be version " << int(version)
168 <<
" that was " << bytes <<
" in length, but expected it to be "
169 "at least 16 bytes. Discarding. "
170 "(May indicate issues with HID!)";
179 vrpn_uint8 msg_seq = vrpn_unbuffer_from_little_endian<vrpn_uint8>(buffer);
184 FixedPointValue(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
185 .get<vrpn_float64>();
187 FixedPointValue(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
188 .get<vrpn_float64>();
190 FixedPointValue(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
191 .get<vrpn_float64>();
193 FixedPointValue(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
194 .get<vrpn_float64>();
203 fprintf(stderr,
"vrpn_Tracker_OSVRHackerDevKit: cannot write "
204 "message: tossing\n");
214 VelFixedPoint(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
215 .
get<vrpn_float64>();
217 VelFixedPoint(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
218 .get<vrpn_float64>();
220 VelFixedPoint(vrpn_unbuffer_from_little_endian<vrpn_int16>(buffer))
221 .get<vrpn_float64>();
229 q_type forward, inverse;
231 q_invert(inverse, forward);
238 delta[Q_X] = angVel[Q_X] * vrpn_HDK_DT * 0.5;
239 delta[Q_Y] = angVel[Q_Y] * vrpn_HDK_DT * 0.5;
240 delta[Q_Z] = angVel[Q_Z] * vrpn_HDK_DT * 0.5;
242 q_normalize(delta, delta);
246 q_mult(canonical, delta, inverse);
247 q_mult(
vel_quat, forward, canonical);
256 fprintf(stderr,
"vrpn_Tracker_OSVRHackerDevKit: cannot write "
257 "message: tossing\n");
266 bool gotVideo = (firstByte & (0x01 << 4)) != 0;
267 bool gotPortrait = (firstByte & (0x01 << 5)) != 0;
301 <<
"Successfully connected to OSVR Hacker Dev Kit HMD, receiving "
308 <<
"Connected to OSVR Hacker Dev Kit HMD, receiving "
311 <<
" reports, newer than what is specifically recognized. You "
312 "may want to update your server to best make use of this "
313 "new report format.";
A fixed-point value class.
T get() const
Returns a floating-point representation of this fixed-point value.
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
vrpn_Connection * d_connection
Connection that this object talks to.
vrpn_int32 d_sender_id
Sender ID registered with the connection.
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
Generic connection class not specific to the transport mechanism.
virtual int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if yo...
Accepts devices meeting at least one of two criteria. NOT SHORT-CIRCUIT. Another demonstration of acc...
virtual bool reconnect()
Tries to reconnect to an acceptable device. Call this if you suspect a hotplug event has occurred.
vrpn_HidAcceptor * m_acceptor
This is the HidAcceptor we use when reconnecting.
virtual void update()
Polls the device buffers and causes on_data_received callbacks if appropriate You NEED to call this f...
virtual bool connected() const
Returns true iff the last device I/O succeeded.
Accepts any device with the given vendor and product IDs.
bool _wasConnected
Flag indicating whether we were connected last time through the mainloop. Used to send a "normal"-sev...
void on_data_received(std::size_t bytes, vrpn_uint8 *buffer)
Extracts the sensor values from each report.
vrpn_Tracker_OSVRHackerDevKit(const char *name, hid_device *dev=NULL, vrpn_Connection *c=NULL)
Constructor.
vrpn_uint8 _reportVersion
vrpn_uint16 _messageCount
Used to forcibly send the analog update every so often.
@ STATUS_LANDSCAPE_VIDEO_INPUT
@ STATUS_PORTRAIT_VIDEO_INPUT
struct timeval _timestamp
Timestamp updated during mainloop()
virtual void mainloop()
Standard VRPN mainloop method.
virtual ~vrpn_Tracker_OSVRHackerDevKit()
Destructor.
virtual int encode_to(char *buf)
virtual int encode_vel_to(char *buf)
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
struct hid_device_ hid_device
Header allowing use of a output stream-style method of sending text messages from devices.
#define vrpn_gettimeofday
header for OSVR Hacker Dev Kit