cgv
Loading...
Searching...
No Matches
event.h
1#pragma once
2
3#include <string>
4#include <iostream>
5
6#include "lib_begin.h"
7
9namespace cgv {
11 namespace gui {
12
27
30{
31 EF_NONE = 0,
33 EF_DND = 2,
34 EF_PAD = 4,
35 EF_VR = 8,
36 EF_NUI = 16,
37};
38
41{
43 EM_ALT = 2,
44 EM_CTRL = 4,
46};
47
55
58class CGV_API event
59{
60protected:
62 unsigned char kind;
64 unsigned char flags;
66 unsigned char modifiers;
68 unsigned char toggle_keys;
70 double time;
71public:
73 event(unsigned int _kind = EID_NONE, unsigned char _modifiers = 0, unsigned char _toggle_keys = 0, double _time = 0);
75 virtual ~event();
77 virtual void stream_out(std::ostream& os) const;
79 virtual void stream_in(std::istream& is);
81 virtual void* get_device_id() const;
83 void set_kind(unsigned char _kind);
85 unsigned get_kind() const;
88 void set_flags(unsigned char _flags);
90 unsigned get_flags() const;
92 void set_modifiers(unsigned char _modifiers);
94 unsigned char get_modifiers() const;
96 void set_toggle_keys(unsigned char _toggle_keys);
98 unsigned char get_toggle_keys() const;
100 void set_time(const double& _time);
102 double get_time() const;
103};
104
106extern CGV_API std::string get_modifier_string(EventModifier modifiers);
107
109extern CGV_API std::string get_toggle_keys_string(EventToggleKeys toggle_keys);
110
112extern CGV_API unsigned char stream_in_modifiers(std::istream& is);
113
115extern CGV_API void stream_in_toggle_keys(std::istream& is, unsigned char& toggle_keys);
116
118extern CGV_API unsigned char& ref_current_modifiers();
119
120 }
121}
122
123#include <cgv/config/lib_end.h>
double get_time() const
return the time of the event in seconds
Definition event.cxx:247
void set_toggle_keys(unsigned char _toggle_keys)
set the state of the toggle keys
Definition event.cxx:220
void set_modifiers(unsigned char _modifiers)
set the modifiers
Definition event.cxx:232
virtual void * get_device_id() const
return the device id, by default returns 0
Definition event.cxx:31
unsigned get_kind() const
return, what kind of event this is, typically a value from the EventId enum
Definition event.cxx:202
unsigned char get_toggle_keys() const
return the state of the toggle keys as values from EventToggleKeys combined with a logical or-operati...
Definition event.cxx:226
virtual void stream_out(std::ostream &os) const
write to stream
Definition event.cxx:139
unsigned char kind
store which kind of event we have
Definition event.h:62
unsigned char toggle_keys
store the active toggle keys
Definition event.h:68
void set_kind(unsigned char _kind)
set the kind of the event
Definition event.cxx:197
unsigned char modifiers
store the active modifiers
Definition event.h:66
unsigned get_flags() const
return the event flags
Definition event.cxx:214
double time
store the time of the event in seconds
Definition event.h:70
unsigned char flags
store event flags
Definition event.h:64
unsigned char get_modifiers() const
return the active modifiers as values from EventModifier combined with a logical or-operation
Definition event.cxx:237
virtual void stream_in(std::istream &is)
read from stream
Definition event.cxx:191
void set_flags(unsigned char _flags)
return the set the event flags
Definition event.cxx:208
event(unsigned int _kind=EID_NONE, unsigned char _modifiers=0, unsigned char _toggle_keys=0, double _time=0)
construct event from its kind
Definition event.cxx:20
void set_time(const double &_time)
set the time of the event
Definition event.cxx:242
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
unsigned char stream_in_modifiers(std::istream &is)
read modifiers in string format from a stream and set the passed reference to EventModifier s ored to...
Definition event.cxx:126
std::string get_modifier_string(EventModifier modifiers)
convert a modifier combination into a readable string ending on a '+' sign if not empty,...
Definition event.cxx:37
unsigned char & ref_current_modifiers()
read out the current modifiers
Definition event.cxx:252
EventToggleKeys
define constants for toggle keys
Definition event.h:50
@ ETK_NUM_LOCK
num lock
Definition event.h:52
@ ETK_SCROLL_LOCK
scroll lock
Definition event.h:53
@ ETK_CAPS_LOCK
caps lock
Definition event.h:51
EventModifier
define constants for event modifiers
Definition event.h:41
@ EM_SHIFT
shift modifier
Definition event.h:42
@ EM_ALT
alt modifier
Definition event.h:43
@ EM_META
meta modifier (windows or mac key)
Definition event.h:45
@ EM_CTRL
ctrl modifier
Definition event.h:44
EventId
define the ids of the most common events
Definition event.h:15
@ EID_NONE
undefined event id
Definition event.h:16
@ EID_POSE
id for a 6D pose change events
Definition event.h:21
@ EID_STICK
id of a stick event describing a two axis controller that optionally can be touched and pressed
Definition event.h:20
@ EID_KEY
id for key event
Definition event.h:17
@ EID_LIFETIME
id for nui life time
Definition event.h:25
@ EID_MOUSE
id for mouse event
Definition event.h:18
@ EID_ACTION
id for nui action events
Definition event.h:24
@ EID_CHOICE
id for focus or selection change events
Definition event.h:22
@ EID_THROTTLE
id of throttle event describing a one axis controller
Definition event.h:19
@ EID_APPROACH
id for nui approach events
Definition event.h:23
std::string get_toggle_keys_string(EventToggleKeys toggle_keys)
convert a toggle key combination into a readable string separated by '+' signs, i....
Definition event.cxx:47
EventFlags
flags
Definition event.h:30
@ EF_DND
whether mouse has a drag and drop target attached
Definition event.h:33
@ EF_MULTI
whether event is tagged with id of the device that generated the event
Definition event.h:32
@ EF_NUI
whether event is nature user interface event
Definition event.h:36
@ EF_VR
whether event is from VR kit
Definition event.h:35
@ EF_PAD
whether event is from gamepad
Definition event.h:34
this header is dependency free
Definition print.h:11