cgv
Loading...
Searching...
No Matches
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
10namespace cgv {
12 namespace gui {
13
23
25extern CGV_API std::string get_stick_action_string(StickAction action);
26
28class CGV_API stick_event : public event
29{
30protected:
31 // store different indices to uniquely define stick
32 unsigned char player_index, controller_index, stick_index;
34 unsigned char action;
39public:
41 stick_event(StickAction _action, float _x, float _y, float _dx, float _dy,
42 unsigned _player_index = 0, unsigned _controller_index = 0, unsigned _stick_index = 0, double _time = 0);
44 void stream_out(std::ostream& os) const;
46 void stream_in(std::istream& is);
48 StickAction get_action() const;
50 unsigned get_player_index() const;
52 unsigned get_controller_index() const;
54 unsigned get_stick_index() const;
56 float get_x() const;
58 float get_y() const;
60 const vec2& get_position() const;
62 float get_dx() const;
64 float get_dy() const;
66 const vec2& get_difference() const;
68 float get_last_x() const;
70 float get_last_y() const;
72 vec2 get_last_position() const;
73};
74
75 }
76}
77
78#include <cgv/config/lib_end.h>
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
vec2 difference
change in stick location
Definition stick_event.h:38
unsigned get_stick_index() const
return stick index
const vec2 & get_position() const
return current position
float get_last_x() const
return the last x value of the stick
float get_y() const
return the current y value of the stick
void stream_in(std::istream &is)
read from stream
const vec2 & get_difference() const
return the vector of coordinate differences (dx,dy)
vec2 position
current stick location
Definition stick_event.h:36
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
float get_dy() const
return the current change in y value of the stick
float get_last_y() const
return the last y value of the stick
unsigned get_controller_index() const
return controller index
unsigned char action
store stick action
Definition stick_event.h:34
void stream_out(std::ostream &os) const
write to stream
float get_dx() const
return the current change in x value of the stick
vec2 get_last_position() const
return last position
unsigned get_player_index() const
return player index
StickAction get_action() const
return the stick action
float get_x() const
return the current x value of the stick
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
std::string get_stick_action_string(StickAction action)
convert a key action into a readable string
StickAction
different actions that a stick can perform
Definition stick_event.h:15
@ SA_DRAG
stick moved in pressed state
Definition stick_event.h:21
@ SA_RELEASE
stick release action
Definition stick_event.h:19
@ SA_PRESS
stick press action
Definition stick_event.h:17
@ SA_TOUCH
stick touch action
Definition stick_event.h:16
@ SA_UNPRESS
stick unpress repeated press action
Definition stick_event.h:18
@ SA_MOVE
stick moved with respect to last event
Definition stick_event.h:20
this header is dependency free
Definition print.h:11
cgv::math::fvec< float, 2 > vec2
declare type of 2d single precision floating point vectors
Definition fvec.h:692