cgv
stick_event.h
1 #pragma once
2 
3 #include "event.h"
4 #include "shortcut.h"
5 #include <cgv/math/fvec.h>
6 
7 #include "lib_begin.h"
8 
10 namespace cgv {
12  namespace gui {
13 
15 enum StickAction {
21  SA_DRAG
22 };
23 
25 extern CGV_API std::string get_stick_action_string(StickAction action);
26 
28 class CGV_API stick_event : public event
29 {
30 public:
33 protected:
34  // store different indices to uniquely define stick
35  unsigned char player_index, controller_index, stick_index;
37  unsigned char action;
42 public:
44  stick_event(StickAction _action, float _x, float _y, float _dx, float _dy,
45  unsigned _player_index = 0, unsigned _controller_index = 0, unsigned _stick_index = 0, double _time = 0);
47  void stream_out(std::ostream& os) const;
49  void stream_in(std::istream& is);
51  StickAction get_action() const;
53  unsigned get_player_index() const;
55  unsigned get_controller_index() const;
57  unsigned get_stick_index() const;
59  float get_x() const;
61  float get_y() const;
63  const vec2& get_position() const;
65  float get_dx() const;
67  float get_dy() const;
69  const vec2& get_difference() const;
71  float get_last_x() const;
73  float get_last_y() const;
75  vec2 get_last_position() const;
76 };
77 
78  }
79 }
80 
81 #include <cgv/config/lib_end.h>
cgv::gui::StickAction
StickAction
different actions that a stick can perform
Definition: stick_event.h:15
cgv::gui::stick_event::action
unsigned char action
store stick action
Definition: stick_event.h:37
cgv::gui::stick_event::vec2
cgv::math::fvec< float, 2 > vec2
declare 2d vector type
Definition: stick_event.h:32
cgv::gui::SA_TOUCH
@ SA_TOUCH
stick touch action
Definition: stick_event.h:16
cgv::gui::SA_DRAG
@ SA_DRAG
stick moved in pressed state
Definition: stick_event.h:21
cgv::gui::stick_event::difference
vec2 difference
change in stick location
Definition: stick_event.h:41
cgv::math::fvec< float, 2 >
cgv::gui::SA_UNPRESS
@ SA_UNPRESS
stick unpress repeated press action
Definition: stick_event.h:18
cgv::gui::stick_event::position
vec2 position
current stick location
Definition: stick_event.h:39
cgv::gui::SA_RELEASE
@ SA_RELEASE
stick release action
Definition: stick_event.h:19
cgv::gui::event
Definition: event.h:59
cgv::gui::get_stick_action_string
std::string get_stick_action_string(StickAction action)
convert a key action into a readable string
Definition: stick_event.cxx:8
cgv::gui::stick_event
class to represent stick events with the EID_STICK
Definition: stick_event.h:29
cgv::gui::SA_PRESS
@ SA_PRESS
stick press action
Definition: stick_event.h:17
cgv::gui::SA_MOVE
@ SA_MOVE
stick moved with respect to last event
Definition: stick_event.h:20
cgv
the cgv namespace
Definition: vr_calib.cxx:9