cgv
vr_state.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include "lib_begin.h"
7 
10 
16 namespace vr {
19  const unsigned max_nr_controllers = 8;
21  const unsigned max_nr_controller_inputs = 5;
23  const unsigned max_nr_controller_axes = 8;
24 
26  enum KeyAction {
27  KA_RELEASE,
28  KA_PRESS,
29  KA_REPEAT
30  };
32  enum VRKeys {
33  VR_UNKNOWN = 1024,
45  VR_A,
59  };
62  {
63  VRF_SYSTEM = 0x000001,
64  VRF_MENU = 0x000002,
65  VRF_GRIP = 0x000004,
66  VRF_DPAD_LEFT = 0x000008,
67  VRF_DPAD_RIGHT = 0x000010,
68  VRF_DPAD_DOWN = 0x000020,
69  VRF_DPAD_UP = 0x000040,
70  VRF_A = 0x000080,
71  VRF_INPUT0_TOUCH = 0x000100,
72  VRF_INPUT0 = 0x000200,
73  VRF_INPUT1_TOUCH = 0x000400,
74  VRF_INPUT1 = 0x000800,
75  VRF_INPUT2_TOUCH = 0x001000,
76  VRF_INPUT2 = 0x002000,
77  VRF_INPUT3_TOUCH = 0x004000,
78  VRF_INPUT3 = 0x008000,
79  VRF_INPUT4_TOUCH = 0x010000,
80  VRF_INPUT4 = 0x020000,
81  VRF_PROXIMITY = 0x040000
82  };
84  enum VRStatus
85  {
89  };
91 
93  struct CGV_API vr_trackable_state
94  {
98 
104  float pose[12];
106  bool operator == (const vr_trackable_state& state) const;
109  };
111 
117  struct CGV_API vr_controller_state : public vr_trackable_state
118  {
120  unsigned time_stamp;
122  unsigned button_flags;
126  float vibration[2];
128  bool operator == (const vr_controller_state& state) const;
132  void put_ray(float* ray_origin, float* ray_direction) const;
133  };
135 
138  struct CGV_API vr_kit_state
139  {
145  bool operator == (const vr_kit_state& state) const;
147  vr_kit_state();
148  };
150  extern CGV_API std::string get_key_string(unsigned short key);
152  extern CGV_API std::string get_state_flag_string(VRButtonStateFlags flags);
154  extern CGV_API std::string get_status_string(VRStatus status);
155 }
157 
158 #include <cgv/config/lib_end.h>
vr::VR_MENU
@ VR_MENU
VIVE: menu button; occulus: start button.
Definition: vr_state.h:35
vr::get_state_flag_string
std::string get_state_flag_string(VRButtonStateFlags flags)
convert flags to string
Definition: vr_state.cxx:110
vr::VRF_MENU
@ VRF_MENU
application menu button
Definition: vr_state.h:64
vr::VR_DPAD_LEFT
@ VR_DPAD_LEFT
direction pad left
Definition: vr_state.h:40
vr::vr_trackable_state::status
VRStatus status
whether trackable is currently tracked, only in case of true, the pose member contains useful informa...
Definition: vr_state.h:96
vr::VR_DPAD_RIGHT
@ VR_DPAD_RIGHT
direction pad right
Definition: vr_state.h:41
vr::VRS_TRACKED
@ VRS_TRACKED
trackable is connected and tracked
Definition: vr_state.h:88
vr::VRButtonStateFlags
VRButtonStateFlags
one flag for each vr controller button
Definition: vr_state.h:62
vr::VR_INPUT2
@ VR_INPUT2
input 2
Definition: vr_state.h:51
vr::VR_DPAD_UP_RIGHT
@ VR_DPAD_UP_RIGHT
direction pad diagonally up and right
Definition: vr_state.h:44
vr::VRF_INPUT0
@ VRF_INPUT0
button of input 0
Definition: vr_state.h:72
vr::VRF_DPAD_LEFT
@ VRF_DPAD_LEFT
direction pad left button
Definition: vr_state.h:66
vr::VRF_A
@ VRF_A
A button.
Definition: vr_state.h:70
vr::VRF_INPUT2
@ VRF_INPUT2
button of input 2
Definition: vr_state.h:76
vr
the vr namespace for virtual reality support
Definition: gl_vr_display.cxx:5
vr::VR_INPUT0_TOUCH
@ VR_INPUT0_TOUCH
touched input 0
Definition: vr_state.h:46
vr::VRS_ATTACHED
@ VRS_ATTACHED
trackable is connected via wireless but not tracked
Definition: vr_state.h:87
vr::VRF_INPUT1_TOUCH
@ VRF_INPUT1_TOUCH
touch sensor for input 1 which often is touchpad or stick
Definition: vr_state.h:73
vr::vr_controller_state::button_flags
unsigned button_flags
combination of flags in VRButtonStateFlags combined with the OR operation
Definition: vr_state.h:122
vr::VRF_INPUT3_TOUCH
@ VRF_INPUT3_TOUCH
touch sensor for input 3 which often is touchpad or stick
Definition: vr_state.h:77
vr::VR_INPUT3
@ VR_INPUT3
input 3
Definition: vr_state.h:53
vr::VRF_PROXIMITY
@ VRF_PROXIMITY
proximity sensor
Definition: vr_state.h:81
vr::VR_PROXIMITY
@ VR_PROXIMITY
proximity sensor
Definition: vr_state.h:56
vr::VR_DPAD_UP
@ VR_DPAD_UP
direction pad up
Definition: vr_state.h:43
vr::vr_kit_state::hmd
vr_trackable_state hmd
status and pose of hmd
Definition: vr_state.h:141
vr::max_nr_controller_axes
const unsigned max_nr_controller_axes
maximum number of axes per controller
Definition: vr_state.h:23
vr::get_key_string
std::string get_key_string(unsigned short key)
convert key to string
Definition: vr_state.cxx:78
vr::VR_A
@ VR_A
A button.
Definition: vr_state.h:45
vr::VR_SYSTEM
@ VR_SYSTEM
VIVE: system button; occulus: ???
Definition: vr_state.h:34
vr::VRF_INPUT1
@ VRF_INPUT1
button of input 1
Definition: vr_state.h:74
vr::VR_DPAD_DOWN_LEFT
@ VR_DPAD_DOWN_LEFT
direction pad diagonally down and left
Definition: vr_state.h:37
vr::VRF_INPUT4_TOUCH
@ VRF_INPUT4_TOUCH
touch sensor for input 4 which often is touchpad or stick
Definition: vr_state.h:79
vr::VR_INPUT4_TOUCH
@ VR_INPUT4_TOUCH
touched input 4
Definition: vr_state.h:54
vr::vr_trackable_state
a trackable knows whether it is tracked and its 6d pose stored as 3x4 matrix in column major format
Definition: vr_state.h:94
vr::VRF_INPUT0_TOUCH
@ VRF_INPUT0_TOUCH
touch sensor for input 0 which often is touchpad or stick
Definition: vr_state.h:71
vr::VR_INPUT0
@ VR_INPUT0
input 0
Definition: vr_state.h:47
vr::VRS_DETACHED
@ VRS_DETACHED
trackable is not reachable via wireless
Definition: vr_state.h:86
vr::VR_DPAD_DOWN
@ VR_DPAD_DOWN
direction pad down
Definition: vr_state.h:38
vr::VRF_INPUT4
@ VRF_INPUT4
button of input 4
Definition: vr_state.h:80
vr::VRF_INPUT3
@ VRF_INPUT3
button of input 3
Definition: vr_state.h:78
vr::VR_INPUT3_TOUCH
@ VR_INPUT3_TOUCH
touched input 3
Definition: vr_state.h:52
vr::VR_BEGIN
@ VR_BEGIN
begin marker used in for loops over all VR keys
Definition: vr_state.h:58
vr::VR_INPUT1
@ VR_INPUT1
input 1
Definition: vr_state.h:49
vr::VRF_DPAD_RIGHT
@ VRF_DPAD_RIGHT
direction pad right button
Definition: vr_state.h:67
vr::vr_controller_state
Extends the trackable state by information on the buttons, input axes and vibration strengths.
Definition: vr_state.h:118
vr::VR_DPAD_UP_LEFT
@ VR_DPAD_UP_LEFT
direction pad diagonally up and left
Definition: vr_state.h:42
vr::KeyAction
KeyAction
repeated definition from cgv/gui/key_event.h
Definition: vr_state.h:26
vr::VR_INPUT4
@ VR_INPUT4
input 4
Definition: vr_state.h:55
vr::VRF_DPAD_UP
@ VRF_DPAD_UP
direction pad up button
Definition: vr_state.h:69
vr::VRKeys
VRKeys
enumerate all VR keys starting at 1024
Definition: vr_state.h:32
vr::max_nr_controllers
const unsigned max_nr_controllers
maximum number of attachable controller and tracker devices
Definition: vr_state.h:19
vr::vr_controller_state::time_stamp
unsigned time_stamp
a unique time stamp for fast test whether state changed
Definition: vr_state.h:120
vr::vr_kit_state
structure that stores all information describing the state of a VR kit
Definition: vr_state.h:139
vr::VRF_DPAD_DOWN
@ VRF_DPAD_DOWN
direction pad down button
Definition: vr_state.h:68
vr::VR_GRIP
@ VR_GRIP
grip button
Definition: vr_state.h:36
vr::VR_END
@ VR_END
end marker used in for loops over all VR keys
Definition: vr_state.h:57
vr::max_nr_controller_inputs
const unsigned max_nr_controller_inputs
maximum number of inputs per controller
Definition: vr_state.h:21
vr::VRF_SYSTEM
@ VRF_SYSTEM
system button
Definition: vr_state.h:63
vr::VR_INPUT2_TOUCH
@ VR_INPUT2_TOUCH
touched input 2
Definition: vr_state.h:50
vr::VR_INPUT1_TOUCH
@ VR_INPUT1_TOUCH
touched input 1
Definition: vr_state.h:48
vr::VRF_INPUT2_TOUCH
@ VRF_INPUT2_TOUCH
touch sensor for input 2 which often is touchpad or stick
Definition: vr_state.h:75
vr::get_status_string
std::string get_status_string(VRStatus status)
convert flags to string
Definition: vr_state.cxx:166
vr::VR_DPAD_DOWN_RIGHT
@ VR_DPAD_DOWN_RIGHT
direction pad diagonally down and right
Definition: vr_state.h:39
vr::VRStatus
VRStatus
different status values for a trackable
Definition: vr_state.h:85
vr::VRF_GRIP
@ VRF_GRIP
grip button
Definition: vr_state.h:65