cgv
Loading...
Searching...
No Matches
vr_server.cxx
1#include <cgv/base/base.h>
2#include <vr/vr_driver.h>
3#include "vr_server.h"
4#include "vr_events.h"
5#include <cgv/gui/application.h>
6#include <cgv/signal/rebind.h>
7#include <cgv/gui/trigger.h>
8#include <cgv/gui/choice_event.h>
9#include <cassert>
10
11namespace cgv {
12 namespace gui {
13 // some helper function to compare arrays
14 bool array_unequal(const float* a1, const float* a2, unsigned n) {
15 for (unsigned i = 0; i < n; ++i)
16 if (a1[i] != a2[i])
17 return true;
18 return false;
19 }
22 {
23 last_device_scan = -1;
24 device_scan_interval = 1;
25 event_type_flags = VRE_ALL;
26 last_time_stamps.resize(vr_kit_handles.size(), 0);
27 }
30 {
31 device_scan_interval = duration;
32 }
34 {
36 vr::VRKeys key;
37 };
39 bool vr_server::grab_focus(VRFocus _focus_type, event_handler* handler)
40 {
41 choice_event ce(CET_LOOSE_FOCUS, 0, 0, trigger::get_current_time());
42 ce.set_flags(EF_VR);
43 if (focus) {
44 if (handler == focus)
45 return true;
46 if ((focus_type & VRF_PERMANENT) != 0)
47 return false;
48 focus->handle(ce);
49 focus = 0;
50 }
51 ce.set_type(CET_GRAB_FOCUS);
52 focus = handler;
53 focus_type = _focus_type;
54 focus->handle(ce);
55 return true;
56 }
59 {
60 if (!focus || focus != handler)
61 return false;
62 focus_type = VRF_RELEASED;
63 focus = 0;
64 return true;
65 }
68 {
69 return event_type_flags;
70 }
73 {
74 event_type_flags = flags;
75 }
77 float vr_server::correct_deadzone_and_precision(float value, const vr::controller_input_config& IC)
78 {
79 if (IC.precision > 0)
80 value = IC.precision * floor(value / IC.precision + 0.5f);
81 if (IC.dead_zone > 0)
82 if (std::abs(value) < IC.dead_zone)
83 value = 0;
84 else
85 value = (value - IC.dead_zone) / (1.0f - IC.dead_zone);
86 return value;
87 }
89 vec2 vr_server::correct_deadzone_and_precision(const vec2& position, const vr::controller_input_config& IC)
90 {
91 vec2 result = position;
92 if (IC.precision > 0)
93 result = IC.precision*round(result/IC.precision+0.5f);
94 if (IC.dead_zone > 0)
95 if (result.length() < IC.dead_zone)
96 result.zeros();
97 return result;
98 }
100 void vr_server::emit_events_and_update_state(void* kit_handle, const vr::vr_kit_state& new_state, int kit_index, VREventTypeFlags flags, double time)
101 {
102 static button_mapping button_keys[19] = {
110 { vr::VRF_A, vr::VR_A },
122 };
123 vr::vr_kit* kit_ptr = vr::get_vr_kit(kit_handle);
124 vr::vr_kit_state& last_state = last_states[kit_index];
125 // check for status changes and emit signal for found status changes
126 if ((flags & VRE_STATUS) != 0) {
127 if (new_state.hmd.status != last_state.hmd.status)
128 on_status_change(kit_handle, -1, last_state.hmd.status, new_state.hmd.status);
129 for (int ci = 0; ci < vr::max_nr_controllers; ++ci) {
130 if (new_state.controller[ci].status != last_state.controller[ci].status)
131 on_status_change(kit_handle, ci, last_state.controller[ci].status, new_state.controller[ci].status);
132 }
133 }
134 // check for key changes and emit key_event
136 for (int ci = 0; ci < vr::max_nr_controllers; ++ci) {
137 const auto& CS_new = new_state.controller[ci];
138 const auto& CS_lst = last_state.controller[ci];
139 // ignore cases when controller changed attachment
140 if (CS_new.status == vr::VRS_DETACHED || CS_lst.status == vr::VRS_DETACHED)
141 continue;
142 // ensure that a key changed
143 if (CS_new.button_flags == CS_lst.button_flags)
144 continue;
145 // first check direct key events
146 if ((flags & VRE_KEY) != 0) {
147 for (unsigned j = 0; j < 19; ++j) {
148 if ((button_keys[j].flag == vr::VRF_INPUT0) && ((flags & VRE_TWO_AXES_GENERATES_DPAD) != 0))
149 continue;
150 if ((CS_new.button_flags & button_keys[j].flag) != (CS_lst.button_flags & button_keys[j].flag)) {
151 // construct and emit event
152 vr_key_event vrke(kit_handle, kit_index, ci, new_state,
153 button_keys[j].key,
154 (CS_new.button_flags & button_keys[j].flag) != 0 ? KA_PRESS : KA_RELEASE,
155 0, 0, time);
156 dispatch(vrke);
157 }
158 }
159 }
160 // next check for dpad events
161 if (((flags & VRE_TWO_AXES_GENERATES_DPAD) != 0) && ((CS_new.button_flags & vr::VRF_INPUT0) != (CS_lst.button_flags & vr::VRF_INPUT0))) {
162 // dpad keys are ordered from left to right and bottom to top with VR_INPUT0 in center
163 // compute key offset relative to VR_INPUT0
164 short key_offset = 0;
165 float th = kit_ptr ? kit_ptr->get_controller_input_config(ci, 0).threshold : 0.5f;
166 int x = CS_new.axes[0] > th ? 1 : (CS_new.axes[0] < -th ? -1 : 0);
167 int y = CS_new.axes[1] > th ? 1 : (CS_new.axes[1] < -th ? -1 : 0);
168 //std::cout << x << "|" << CS_new.axes[0] << ":" << th << "; " << y << "|" << CS_new.axes[1] << ":" << th << std::endl;
169 key_offset = 3 * y + x;
171 if (key_offset != 0) {
172 if (key_offset > 0)
173 --key_offset;
174 key = vr::VRKeys(vr::VR_DPAD_RIGHT + key_offset);
175 }
176 // construct and emit event
177 vr_key_event vrke(kit_handle, kit_index, ci, new_state, key,
178 (CS_new.button_flags & vr::VRF_INPUT0) != 0 ? KA_PRESS : KA_RELEASE, 0, 0, time);
179 dispatch(vrke);
180 }
181 }
182 }
183 // check for axes input events
184 if (kit_ptr && ((flags & (VRE_ONE_AXIS|VRE_TWO_AXES)) != 0)) {
185 for (int ci = 0; ci < vr::max_nr_controllers; ++ci) {
186 const auto& CS_new = new_state.controller[ci];
187 const auto& CS_lst = last_state.controller[ci];
188 // iterate all controller inputs
191 int ai = 0;
192 for (int ii = 0; ii < vr::max_nr_controller_inputs; ++ii,
193 input_flag = vr::VRButtonStateFlags(4 * input_flag),
194 touch_flag = vr::VRButtonStateFlags(4 * touch_flag)) {
195 // determine input type
197 if (it == vr::VRI_NONE)
198 continue;
199 if (it == vr::VRI_TRIGGER) {
200 if ((flags & VRE_ONE_AXIS) != 0) {
201 const auto& CIC = kit_ptr->get_controller_input_config(ci, ii);
202 float x = correct_deadzone_and_precision(CS_new.axes[ai], CIC);
203 float dx = x - correct_deadzone_and_precision(CS_lst.axes[ai], CIC);
204 if (dx != 0) {
206 vr_throttle_event vrte(kit_handle, ci, new_state, x, dx, kit_index, ii, time);
207 dispatch(vrte);
208 }
209 }
210 ++ai;
211 continue;
212 }
213 // check for pad/stick touch / press / release / untouch events
214 else {
215 if ((flags & VRE_TWO_AXES) != 0) {
216 // check if press/touch state changed
217 int new_p_or_t = ((CS_new.button_flags & touch_flag) != 0) ? 1 : 0;
218 if ((CS_new.button_flags & input_flag) != 0)
219 new_p_or_t = 2;
220 int old_p_or_t = ((CS_lst.button_flags & touch_flag) != 0) ? 1 : 0;
221 if ((CS_lst.button_flags & input_flag) != 0)
222 old_p_or_t = 2;
223 if (new_p_or_t != old_p_or_t) {
224 static StickAction actions[9] = {
228 };
229 StickAction action = actions[new_p_or_t + 3 * old_p_or_t];
230 float x = new_state.controller[ci].axes[ai];
231 float y = new_state.controller[ci].axes[ai + 1];
232 vr_stick_event vrse(kit_handle, ci, new_state,
233 action, x, y, 0, 0, kit_index, 0, time);
234 dispatch(vrse);
235 }
236 // otherwise check for move or drag event
237 else {
238 const auto& CIC = kit_ptr->get_controller_input_config(ci, ii);
239 vec2 p(CS_new.axes[ai], CS_new.axes[ai + 1]);
240 p = correct_deadzone_and_precision(p, CIC);
241 vec2 last_p(CS_lst.axes[ai], CS_lst.axes[ai + 1]);
242 last_p = correct_deadzone_and_precision(last_p, CIC);
243 vec2 diff = p - last_p;
244 if (diff(0) != 0 || diff(1) != 0) {
245 StickAction action = SA_MOVE;
246 if ((CS_new.button_flags & input_flag) != 0)
247 action = SA_DRAG;
248 vr_stick_event vrse(kit_handle, ci, new_state,
249 action, p(0), p(1), diff(0), diff(1), kit_index, ii, time);
250 dispatch(vrse);
251 }
252 }
253 }
254 ai += 2;
255 continue;
256 }
257 }
258 }
259 }
260 // finally check for pose events
261 if ((flags & VRE_POSE) != 0) {
262 if (array_unequal(new_state.hmd.pose, last_state.hmd.pose, 12)) {
263 vr_pose_event vrpe(kit_handle, -1, new_state, new_state.hmd.pose, last_state.hmd.pose, kit_index, time);
264 dispatch(vrpe);
265 }
266 for (int c = 0; c < vr::max_nr_controllers; ++c)
267 if (new_state.controller[c].status == vr::VRS_TRACKED) {
268 if (array_unequal(new_state.controller[c].pose, last_state.controller[c].pose, 12)) {
269 vr_pose_event vrpe(kit_handle, c, new_state, new_state.controller[c].pose, last_state.controller[c].pose, kit_index, time);
270 dispatch(vrpe);
271 }
272 }
273 }
274
275 //write log
276 if (log_data[kit_index] && !(new_state == last_state)) {
277 log_data[kit_index]->log_vr_state(new_state,time);
278 }
279 last_state = new_state;
280 }
281
283 {
284 std::vector<bool> is_first_state(vr_kit_handles.size(), false);
285 if (last_device_scan < 0 ||
286 ((device_scan_interval > 0) && (time > last_device_scan + device_scan_interval))) {
287 last_device_scan = time;
288 std::vector<void*> new_handles = vr::scan_vr_kits();
289 std::vector<vr::vr_kit_state> new_last_states(new_handles.size());
290 is_first_state.resize(new_handles.size(), false);
291 // detect device disconnect events
292 if ((get_event_type_flags() & VRE_DEVICE) != 0)
293 for (void* h1 : vr_kit_handles)
294 if (std::find(new_handles.begin(), new_handles.end(), h1) == new_handles.end())
295 on_device_change(h1, false);
296 // keep vector of parameter pairs for on_device change events
297 std::vector<std::pair<void*, bool> > on_device_change_params;
298 // go through new devices
299 unsigned i = 0;
300 for (void* h2 : new_handles) {
301 auto iter = std::find(vr_kit_handles.begin(), vr_kit_handles.end(), h2);
302 // detect device connect events
303 if (iter == vr_kit_handles.end()) {
304 if ((get_event_type_flags() & VRE_DEVICE) != 0)
305 on_device_change_params.push_back(std::pair<void*, bool>(h2, true));
306 is_first_state.at(i) = true;
307 }
308 else {
309 new_last_states[i] = last_states.at(iter - vr_kit_handles.begin());
310 }
311 ++i;
312 }
313 vr_kit_handles = new_handles;
314 last_states = new_last_states;
315 for (auto pp : on_device_change_params)
316 on_device_change(pp.first, pp.second);
317 }
318 }
321 {
323 // loop all devices
324 unsigned i;
325 for (i = 0; i < vr_kit_handles.size(); ++i) {
326 vr::vr_kit* kit = vr::get_vr_kit(vr_kit_handles[i]);
327 if (!kit)
328 continue;
329 // query current state
330 vr::vr_kit_state state;
331 kit->query_state(state, 1);
332 emit_events_and_update_state(vr_kit_handles[i], state, i, event_type_flags, time);
333 }
334 }
335
337 bool vr_server::check_new_state(void* kit_handle, const vr::vr_kit_state& new_state, double time)
338 {
339 return check_new_state(kit_handle, new_state, time, event_type_flags);
340 }
342 bool vr_server::check_new_state(void* kit_handle, const vr::vr_kit_state& new_state, double time, VREventTypeFlags flags)
343 {
344 auto iter = std::find(vr_kit_handles.begin(), vr_kit_handles.end(), kit_handle);
345 if (iter == vr_kit_handles.end())
346 return false;
347 size_t i = iter - vr_kit_handles.begin();
348 emit_events_and_update_state(kit_handle, new_state, (int)i, flags, time);
349 return true;
350 }
352 {
353 if (focus && focus_type != VRF_RELEASED) {
354 if (focus->handle(e))
355 return true;
356 if ((focus_type & VRF_EXCLUSIVE) != 0)
357 return false;
358 }
359 return on_event(e);
360 }
361 void vr_server::enable_log(std::string fn, bool in_memory_log, int filter, int kit_index)
362 {
363 auto it = log_data.find(kit_index);
364 if (log_data[kit_index]) {
365 log_data[kit_index]->disable_log();
366 log_data[kit_index] = nullptr;
367 }
368 log_data[kit_index] = new vr::vr_log();
369 vr::vr_log& log = *log_data[kit_index];
370
371 if (fn.size() > 0) {
372 auto p = std::make_shared<std::ofstream>(fn);
373 log.enable_ostream_log(p);
374 }
375 if (in_memory_log)
377
378 log.set_filter(filter);
379 log.lock_settings();
380 }
381 void vr_server::disable_log(int kit_index)
382 {
383 auto it = log_data.find(kit_index);
384 if (it != log_data.end() && it->second)
385 it->second->disable_log();
386 }
387
388 vr::vr_log& vr_server::ref_log(const int kit_index)
389 {
390 return *log_data[kit_index];
391 }
393 {
394 return log_data[kit_index];
395 }
398 {
399 static vr_server server;
400 return server;
401 }
402
403 window_ptr& ref_dispatch_window_pointer_vr()
404 {
405 static window_ptr w;
406 return w;
407 }
408 bool dispatch_vr_event(cgv::gui::event& e)
409 {
411 }
412
414 void connect_vr_server(bool connect_device_change_only_to_animation_trigger, cgv::gui::window_ptr w)
415 {
416 if (w.empty())
418 if (ref_dispatch_window_pointer_vr() != w) {
419 ref_dispatch_window_pointer_vr() = w;
420 connect(ref_vr_server().on_event, dispatch_vr_event);
421 if (connect_device_change_only_to_animation_trigger)
422 connect_copy(get_animation_trigger().shoot, cgv::signal::rebind(&ref_vr_server(), &vr_server::check_device_changes, cgv::signal::_1));
423 else
424 connect_copy(get_animation_trigger().shoot, cgv::signal::rebind(&ref_vr_server(), &vr_server::check_and_emit_events, cgv::signal::_1));
425 }
426 }
427
428 }
429}
reference counted pointer, which can work together with types that are derived from ref_counted,...
Definition ref_ptr.h:160
bool empty() const
check if pointer is not yet set
Definition ref_ptr.h:230
static window_ptr get_window(unsigned int i)
return the i-th created window
class to represent choice events that include focus change and selection change events
void set_type(ChoiceEventType _type)
set the type of the choice event
interface for all classes that want to receive events
virtual bool handle(event &e)=0
overload and implement this method to handle events
void set_flags(unsigned char _flags)
return the set the event flags
Definition event.cxx:208
static double get_current_time()
return the current time
Definition trigger.cxx:70
vr key events use the key codes defined in vr::VRKeys
Definition vr_events.h:40
vr extension of pose events
Definition vr_events.h:92
server for vr events
Definition vr_server.h:136
bool dispatch(cgv::gui::event &e)
dispatch an event to focus handler and or signal attachments
void enable_log(const std::string fn="", const bool in_memory_log=true, const int filter=vr::vr_log::F_ALL, const int kit_index=0)
cgv::signal::signal< void *, int, vr::VRStatus, vr::VRStatus > on_status_change
signal emitted to notify about status changes of trackables, first argument is handle,...
Definition vr_server.h:183
void disable_log(const int kit_index=0)
disable logging and close log file
void check_device_changes(double time)
check which vr_kits are present and emit on_device_change events
bool grab_focus(VRFocus focus, event_handler *handler)
grab the event focus to the given event handler and return whether this was possible
Definition vr_server.cxx:39
bool release_focus(event_handler *handler)
release focus of handler and return whether handler had the focus
Definition vr_server.cxx:58
cgv::data::ref_ptr< vr::vr_log > get_log(const int kit_index=0)
returns a pointer to the active log data container, meant for extending the lifetime of the log data ...
vr_server()
construct server with default configuration
Definition vr_server.cxx:21
void set_event_type_flags(VREventTypeFlags flags)
set the event type flags of to be emitted events
Definition vr_server.cxx:72
vr::vr_log & ref_log(const int kit_index=0)
return a reference to the used vr_log object
cgv::signal::signal< void *, bool > on_device_change
signal emitted to notify about device changes, first argument is handle and second a flag telling whe...
Definition vr_server.h:181
void emit_events_and_update_state(void *kit_handle, const vr::vr_kit_state &new_state, int kit_index, VREventTypeFlags flags, double time)
void check_and_emit_events(double time)
check which vr_kits are present, query their current states and dispatch events through on_event,...
void set_device_scan_interval(double duration)
set time interval in seconds to check for device connection changes
Definition vr_server.cxx:29
bool check_new_state(void *kit_handle, const vr::vr_kit_state &new_state, double time)
in case the current vr state of a kit had been queried somewhere else, use this function to communica...
VREventTypeFlags get_event_type_flags() const
query the currently set event type flags
Definition vr_server.cxx:67
cgv::signal::bool_signal< cgv::gui::event & > on_event
signal emitted to dispatch events
Definition vr_server.h:179
vr extension of stick event
Definition vr_events.h:78
vr extension of throttle event
Definition vr_events.h:65
virtual bool dispatch_event(event &e)
dispatch a cgv event
Definition window.cxx:20
T length() const
length of the vector L2-Norm
Definition fvec.h:249
void zeros()
fill the vector with zeros
Definition fvec.h:133
a vr kit is composed of headset, two controllers, and two trackers, where all devices can be attached...
Definition vr_kit.h:69
const controller_input_config & get_controller_input_config(int controller_index, int input_index) const
query the configuration of a controller input
Definition vr_kit.cxx:126
bool query_state(vr_kit_state &state, int pose_query=2)
query current state of vr kit and return whether this was successful
Definition vr_kit.cxx:103
const vr_kit_info & get_device_info() const
return information on the currently attached devices
Definition vr_kit.cxx:117
helper struct for logging vr events
Definition vr_log.h:19
void enable_in_memory_log()
enable in memory log
Definition vr_log.cxx:115
void lock_settings()
prevent changes to settings and enables log_vr_state methods
Definition vr_log.cxx:300
void set_filter(int f)
define what data should be recorded.
Definition vr_log.h:82
void enable_ostream_log(const std::shared_ptr< std::ostream > &stream)
enable writing to ostream.
Definition vr_log.cxx:121
data::ref_ptr< window > window_ptr
ref counted pointer to &window
Definition window.h:31
vr_server & ref_vr_server()
return a reference to gamepad server singleton
@ KA_PRESS
key press action
Definition key_event.h:14
@ KA_RELEASE
key release action
Definition key_event.h:13
StickAction
different actions that a stick can perform
Definition stick_event.h:15
@ SA_DRAG
stick moved in pressed state
Definition stick_event.h:21
@ SA_RELEASE
stick release action
Definition stick_event.h:19
@ SA_PRESS
stick press action
Definition stick_event.h:17
@ SA_TOUCH
stick touch action
Definition stick_event.h:16
@ SA_UNPRESS
stick unpress repeated press action
Definition stick_event.h:18
@ SA_MOVE
stick moved with respect to last event
Definition stick_event.h:20
VRFocus
different types of event focus grabbing
Definition vr_server.h:42
VREventTypeFlags
flags to define which events should be generated by server
Definition vr_server.h:27
@ VRE_POSE
pose events
Definition vr_server.h:36
@ VRE_ONE_AXIS_GENERATES_KEY
whether one axis events should generate a key event when passing inputs threshold value
Definition vr_server.h:34
@ VRE_TWO_AXES
pad / stick events
Definition vr_server.h:33
@ VRE_ALL
all event types
Definition vr_server.h:37
@ VRE_ONE_AXIS
trigger / throttle / pedal events
Definition vr_server.h:32
@ VRE_KEY
key events
Definition vr_server.h:31
@ VRE_STATUS
status change events
Definition vr_server.h:30
@ VRE_TWO_AXES_GENERATES_DPAD
whether two axes input generates direction pad keys when presses
Definition vr_server.h:35
@ VRE_DEVICE
device change events
Definition vr_server.h:29
void connect_vr_server(bool connect_device_change_only_to_animation_trigger, cgv::gui::window_ptr w)
connect the gamepad server to the given window or the first window of the application,...
trigger & get_animation_trigger()
return the global trigger used for animation, which runs by default with 60 Hz
Definition trigger.cxx:81
@ EF_VR
whether event is from VR kit
Definition event.h:35
the cgv namespace
Definition print.h:11
VRButtonStateFlags
one flag for each vr controller button
Definition vr_state.h:62
@ VRF_INPUT0
button of input 0
Definition vr_state.h:72
@ VRF_MENU
application menu button
Definition vr_state.h:64
@ VRF_DPAD_LEFT
direction pad left button
Definition vr_state.h:66
@ VRF_A
A button.
Definition vr_state.h:70
@ VRF_INPUT1_TOUCH
touch sensor for input 1 which often is touchpad or stick
Definition vr_state.h:73
@ VRF_DPAD_RIGHT
direction pad right button
Definition vr_state.h:67
@ VRF_GRIP
grip button
Definition vr_state.h:65
@ VRF_INPUT3_TOUCH
touch sensor for input 3 which often is touchpad or stick
Definition vr_state.h:77
@ VRF_DPAD_UP
direction pad up button
Definition vr_state.h:69
@ VRF_INPUT1
button of input 1
Definition vr_state.h:74
@ VRF_SYSTEM
system button
Definition vr_state.h:63
@ VRF_PROXIMITY
proximity sensor
Definition vr_state.h:81
@ VRF_INPUT4_TOUCH
touch sensor for input 4 which often is touchpad or stick
Definition vr_state.h:79
@ VRF_INPUT0_TOUCH
touch sensor for input 0 which often is touchpad or stick
Definition vr_state.h:71
@ VRF_INPUT2
button of input 2
Definition vr_state.h:76
@ VRF_INPUT2_TOUCH
touch sensor for input 2 which often is touchpad or stick
Definition vr_state.h:75
@ VRF_INPUT4
button of input 4
Definition vr_state.h:80
@ VRF_DPAD_DOWN
direction pad down button
Definition vr_state.h:68
@ VRF_INPUT3
button of input 3
Definition vr_state.h:78
vr_kit * get_vr_kit(void *handle)
query a pointer to a vr kit by its device handle, function can return null pointer in case that no vr...
std::vector< void * > scan_vr_kits()
iterate all registered vr drivers to scan for vr kits and return vector of vr kit handles
@ VRS_TRACKED
trackable is connected and tracked
Definition vr_state.h:88
@ VRS_DETACHED
trackable is not reachable via wireless
Definition vr_state.h:86
const unsigned max_nr_controllers
maximum number of attachable controller and tracker devices
Definition vr_state.h:19
VRInputType
different controller input types
Definition vr_info.h:103
const unsigned max_nr_controller_inputs
maximum number of inputs per controller
Definition vr_state.h:21
VRKeys
enumerate all VR keys starting at 1024
Definition vr_state.h:32
@ VR_INPUT4
input 4
Definition vr_state.h:55
@ VR_INPUT3_TOUCH
touched input 3
Definition vr_state.h:52
@ VR_PROXIMITY
proximity sensor
Definition vr_state.h:56
@ VR_DPAD_RIGHT
direction pad right
Definition vr_state.h:41
@ VR_INPUT2_TOUCH
touched input 2
Definition vr_state.h:50
@ VR_INPUT1_TOUCH
touched input 1
Definition vr_state.h:48
@ VR_DPAD_LEFT
direction pad left
Definition vr_state.h:40
@ VR_MENU
VIVE: menu button; occulus: start button.
Definition vr_state.h:35
@ VR_INPUT2
input 2
Definition vr_state.h:51
@ VR_A
A button.
Definition vr_state.h:45
@ VR_DPAD_DOWN
direction pad down
Definition vr_state.h:38
@ VR_INPUT1
input 1
Definition vr_state.h:49
@ VR_INPUT0_TOUCH
touched input 0
Definition vr_state.h:46
@ VR_DPAD_UP
direction pad up
Definition vr_state.h:43
@ VR_INPUT0
input 0
Definition vr_state.h:47
@ VR_INPUT4_TOUCH
touched input 4
Definition vr_state.h:54
@ VR_INPUT3
input 3
Definition vr_state.h:53
@ VR_GRIP
grip button
Definition vr_state.h:36
@ VR_SYSTEM
VIVE: system button; occulus: ???
Definition vr_state.h:34
configuration of a controller input axis
Definition vr_kit.h:20
float precision
if precision is larger than zero, values are rounded to multiples of precision.
Definition vr_kit.h:27
float dead_zone
all input values below dead_zone are clamped to 0.
Definition vr_kit.h:24
float threshold
if value gets larger than threshold a key press event is triggered if this is enabled.
Definition vr_kit.h:30
VRInputType input_type[max_nr_controller_inputs]
type of up to 5vr::max_nr_controller_inputs inputs built into the controller
Definition vr_info.h:128
float axes[max_nr_controller_axes]
up to vr::max_nr_controller_axes axis values in the range [-1,1] or [0,1] (VIVE: 0|1....
Definition vr_state.h:124
vr_controller_info controller[max_nr_controllers]
information for attached controllers and trackers
Definition vr_info.h:152
structure that stores all information describing the state of a VR kit
Definition vr_state.h:139
vr_controller_state controller[max_nr_controllers]
status, pose, button, axes, and vibration information of up to vr::max_nr_controllers controller and ...
Definition vr_state.h:143
vr_trackable_state hmd
status and pose of hmd
Definition vr_state.h:141
VRStatus status
whether trackable is currently tracked, only in case of true, the pose member contains useful informa...
Definition vr_state.h:96
float pose[12]
pose as 3x4 matrix in column major format, where each column is a vector in world coordinates
Definition vr_state.h:104
defines the class vr::vr_driver class and gives access to the driver registry with the functions vr::...