vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Oculus.h
Go to the documentation of this file.
1
10// Based on the OSVR hacker dev kit driver by Kevin Godby.
11// Based on Oliver Kreylos' OculusRiftHIDReports.cpp.
12
13#pragma once
14
15#include "vrpn_HumanInterface.h"
16#include "vrpn_Analog.h"
17
18#if defined(VRPN_USE_HID)
19
22public:
26 virtual ~vrpn_Oculus();
27
28 virtual void mainloop();
29
30protected:
40 vrpn_Oculus(vrpn_uint16 product_id, vrpn_uint8 num_channels,
41 const char *name, vrpn_Connection *c = NULL, double keepAliveSeconds = 9.0);
42
44
45 //-------------------------------------------------------------
46 // Parsers for different report types.
47 // Override to define more parsers
48 virtual bool parse_message(std::size_t bytes, vrpn_uint8 *buffer);
49
51 void parse_message_type_1(std::size_t bytes, vrpn_uint8 *buffer);
52
55 void on_data_received(std::size_t bytes, vrpn_uint8 *buffer);
56
58 struct timeval d_timestamp;
59
63 struct timeval d_lastKeepAlive;
64
65 // Send a KeepAlive feature report to the Rift.
66 virtual void writeKeepAlive(
67 vrpn_uint16 interval = 10000 //< KeepAlive time in milliseconds
68 , vrpn_uint16 commandId = 0 //< Should always be zero
69 ) = 0;
70};
71
74public:
82 vrpn_Oculus_DK1(const char *name, vrpn_Connection *c = NULL,
83 double keepAliveSeconds = 9.0);
84
85protected:
86
87 // Send a KeepAlive feature report to the Rift.
88 virtual void writeKeepAlive(
89 vrpn_uint16 interval = 10000 //< KeepAlive time in milliseconds
90 , vrpn_uint16 commandId = 0 //< Should always be zero
91 );
92};
93
97protected:
105 vrpn_Oculus_DK2(bool enableLEDs, const char *name, vrpn_Connection *c = NULL,
106 double keepAliveSeconds = 9.0);
107
108 //-------------------------------------------------------------
109 // Parsers for different report types. The DK2 sends type-1
110 // reports in response to inertial-only keep-alive messages
111 // and type-11 reports in response to LED-enabled keep-alive
112 // messages.
113 //
114 bool parse_message(std::size_t bytes, vrpn_uint8 *buffer);
115
117 void parse_message_type_11(std::size_t bytes, vrpn_uint8 *buffer);
118
121
122 // Send a KeepAlive feature report to the Rift.
123 virtual void writeKeepAlive(
124 vrpn_uint16 interval = 10000 //< KeepAlive time in milliseconds
125 , vrpn_uint16 commandId = 0 //< Should always be zero
126 );
127};
128
131public:
139 vrpn_Oculus_DK2_inertial(const char *name, vrpn_Connection *c = NULL,
140 double keepAliveSeconds = 9.0)
141 : vrpn_Oculus_DK2(false, name, c, keepAliveSeconds) {};
142};
143
146public:
154 vrpn_Oculus_DK2_LEDs(const char *name, vrpn_Connection *c = NULL,
155 double keepAliveSeconds = 9.0)
156 : vrpn_Oculus_DK2(true, name, c, keepAliveSeconds) {};
157};
158
159#endif // VRPN_USE_HID
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Generic connection class not specific to the transport mechanism.
virtual void on_data_received(size_t bytes, vrpn_uint8 *buffer)=0
Derived class reimplements this callback.
Oculus Rift DK1 head-mounted display.
Definition vrpn_Oculus.h:73
Oculus Rift DK2 head-mounted display (LEDs enabled)
vrpn_Oculus_DK2_LEDs(const char *name, vrpn_Connection *c=NULL, double keepAliveSeconds=9.0)
Constructor.
Oculus Rift DK2 head-mounted display (inertial measurement unit only)
vrpn_Oculus_DK2_inertial(const char *name, vrpn_Connection *c=NULL, double keepAliveSeconds=9.0)
Constructor.
Oculus Rift DK2 head-mounted display base class for both intertial- only and LED-enabled version.
Definition vrpn_Oculus.h:96
bool d_enableLEDs
Whether to trigger the LEDs.
Oculus Rift head-mounted display base class.
Definition vrpn_Oculus.h:21
double d_keepAliveSeconds
How often to send the keepAlive message to the Rift (triggers the LEDs if available)
Definition vrpn_Oculus.h:62
vrpn_HidAcceptor * m_filter
Definition vrpn_Oculus.h:43
virtual void writeKeepAlive(vrpn_uint16 interval=10000, vrpn_uint16 commandId=0)=0
#define VRPN_API