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 };
38
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
pose_event(const float *_pose, const float *_last_pose, unsigned short _player_index, short _trackable_index=0, double _time=0)
construct a key event from its textual description
Definition pose_event.cxx:8
stick_event(StickAction _action, float _x, float _y, float _dx, float _dy, unsigned _player_index=0, unsigned _controller_index=0, unsigned _stick_index=0, double _time=0)
construct a key event from its textual description
throttle_event(float _x, float _dx, unsigned _player_index=0, unsigned _controller_index=0, unsigned _throttle_index=0, double _time=0)
construct a throttle event from value and value change
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
vr_event_extension(void *_device_handle, const vr::vr_kit_state &_state)
construct extension from device handle and vr state
Definition vr_events.cxx:7
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
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
vr_key_event(void *_device_handle, unsigned _player_index, unsigned _controller_index, const vr::vr_kit_state &_state, unsigned short _key=0, KeyAction _action=KA_PRESS, unsigned char _char=0, unsigned char _modifiers=0, double _time=0)
construct a key event from given parameters
Definition vr_events.cxx:13
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
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:98
vr_pose_event(void *_device_handle, short _trackable_index, const vr::vr_kit_state &_state, const float *_pose, const float *_last_pose, unsigned short _player_index, double _time=0)
construct a pose event from given parameters
Definition vr_events.cxx:80
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:85
vr_stick_event(void *_device_handle, unsigned _controller_index, const vr::vr_kit_state &_state, StickAction _action, float _x, float _y, float _dx, float _dy, unsigned _player_index=0, unsigned _stick_index=0, double _time=0)
construct stick event from given parameters
Definition vr_events.cxx:65
void * get_device_id() const
return the device id, by default returns 0
Definition vr_events.h:71
vr_throttle_event(void *_device_handle, unsigned _controller_index, const vr::vr_kit_state &_state, float _x, float _dx, unsigned _player_index=0, unsigned _throttle_index=0, double _time=0)
construct a throttle event from value and value change
Definition vr_events.cxx:51
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
KeyAction
different actions that a key can perform
Definition key_event.h:12
@ KA_PRESS
key press action
Definition key_event.h:14
StickAction
different actions that a stick can perform
Definition stick_event.h:15
this header is dependency free
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...