cgv
Loading...
Searching...
No Matches
vr_events.h
1#pragma once
2
3#include <cgv/gui/key_event.h>
4#include <cgv/gui/throttle_event.h>
5#include <cgv/gui/stick_event.h>
6#include <cgv/gui/pose_event.h>
7#include <vr/vr_state.h>
8#include <cgv/gui/window.h>
9#include <cgv/signal/signal.h>
10#include <cgv/signal/bool_signal.h>
11
12#include "lib_begin.h"
13
16
18namespace cgv {
20 namespace gui {
21
23 class CGV_API vr_event_extension
24 {
25 protected:
30 public:
32 vr_event_extension(void* _device_handle, const vr::vr_kit_state& _state);
34 void* get_device_handle() const { return device_handle; }
36 const vr::vr_kit_state& get_state() const { return state; }
37 };
40 {
41 protected:
43 unsigned short controller_index;
45 unsigned short player_index;
46 public:
48 vr_key_event(void* _device_handle, unsigned _player_index, unsigned _controller_index, const vr::vr_kit_state& _state,
49 unsigned short _key = 0, KeyAction _action = KA_PRESS, unsigned char _char = 0,
50 unsigned char _modifiers = 0, double _time = 0);
52 void* get_device_id() const { return get_device_handle(); }
54 unsigned get_controller_index() const { return controller_index; }
56 unsigned get_player_index() const { return player_index; }
58 void stream_out(std::ostream& os) const;
60 void stream_in(std::istream& is);
61 };
62
65 {
66 public:
68 vr_throttle_event(void* _device_handle, unsigned _controller_index, const vr::vr_kit_state& _state,
69 float _x, float _dx, unsigned _player_index = 0, unsigned _throttle_index = 0, double _time = 0);
71 void* get_device_id() const { return get_device_handle(); }
73 void stream_out(std::ostream& os) const;
74 };
75
77 class CGV_API vr_stick_event : public stick_event, public vr_event_extension
78 {
79 public:
81 vr_stick_event(void* _device_handle, unsigned _controller_index, const vr::vr_kit_state& _state,
82 StickAction _action, float _x, float _y, float _dx, float _dy,
83 unsigned _player_index = 0, unsigned _stick_index = 0, double _time = 0);
85 void* get_device_id() const { return get_device_handle(); }
87 void stream_out(std::ostream& os) const;
88 };
89
91 class CGV_API vr_pose_event : public pose_event, public vr_event_extension
92 {
93 public:
95 vr_pose_event(void* _device_handle, short _trackable_index, const vr::vr_kit_state& _state,
96 const float *_pose, const float *_last_pose, unsigned short _player_index, double _time = 0);
98 void* get_device_id() const { return get_device_handle(); }
100 void stream_out(std::ostream& os) const;
101 };
102
103 }
104}
105
107
108#include <cgv/config/lib_end.h>
class to represent all possible keyboard events with the EID_KEY
Definition key_event.h:23
class to represent all pose events from tracking systems with the EID_POSE
Definition pose_event.h:16
class to represent stick events with the EID_STICK
Definition stick_event.h:29
class to represent events that inform on a change in a one axis controller with the EID_THROTTLE
interface common to vr events
Definition vr_events.h:24
const vr::vr_kit_state & state
access to current vr state
Definition vr_events.h:29
void * get_device_handle() const
return the device id, by default returns 0
Definition vr_events.h:34
void * device_handle
store device handle
Definition vr_events.h:27
const vr::vr_kit_state & get_state() const
return the state of vr kit
Definition vr_events.h:36
vr key events use the key codes defined in vr::VRKeys
Definition vr_events.h:40
unsigned get_player_index() const
return player index
Definition vr_events.h:56
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:52
unsigned short controller_index
store index of controller (0 .. vr::max_nr_controllers-1), controllers with left and right hand role ...
Definition vr_events.h:43
unsigned short player_index
store player index
Definition vr_events.h:45
unsigned get_controller_index() const
return controller index (0 .. vr::max_nr_controllers-1), controllers with left and right hand role ar...
Definition vr_events.h:54
vr extension of pose events
Definition vr_events.h:92
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:98
vr extension of stick event
Definition vr_events.h:78
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:85
vr extension of throttle event
Definition vr_events.h:65
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:71
KeyAction
different actions that a key can perform
Definition key_event.h:12
StickAction
different actions that a stick can perform
Definition stick_event.h:15
the cgv namespace
Definition print.h:11
structure that stores all information describing the state of a VR kit
Definition vr_state.h:139
defines types to store the state vr::vr_kit_state of a vr kit, which is split into sub states for the...