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>
class to represent stick events with the EID_STICK
Definition stick_event.h:29
vec2 difference
change in stick location
Definition stick_event.h:38
vec2 position
current stick location
Definition stick_event.h:36
unsigned char action
store stick action
Definition stick_event.h:34
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
the cgv namespace
Definition print.h:11